@abide/harness 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abide/harness",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "Ratios against hand-written code, counts of the work an op did, and gates whose revert can be run — three measurement lanes for anything that renders, on bun",
6
6
  "license": "MIT",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@playwright/test": "^1.64.0",
58
- "@abide/abide": ">=0.106.0"
58
+ "@abide/abide": ">=0.108.0"
59
59
  },
60
60
  "peerDependenciesMeta": {
61
61
  "@playwright/test": {
@@ -25,21 +25,29 @@ import type { TestCase } from '../rows/index.ts'
25
25
  // in `afterAll`, which a stopped file never reaches — so each suite leads a group of its own and
26
26
  // the group is what is signaled. Its own group is also why a Ctrl-C at this runner's terminal is
27
27
  // passed on rather than reaching the suites directly.
28
+ //
29
+ // INSTALLED WITH THE FIRST SUITE rather than on import: a process that only reads this module's
30
+ // parser has no suite to pass a signal on to, and is not this module's to exit.
28
31
  const LIVE = new Set<Bun.Subprocess>()
29
- for (const [signal, code] of [
30
- ['SIGTERM', 143],
31
- ['SIGINT', 130],
32
- ] as const)
33
- process.on(signal, () => {
34
- for (const child of LIVE) {
35
- try {
36
- process.kill(-child.pid, 'SIGINT')
37
- } catch {
38
- // The group emptied between its suite ending and this signal.
32
+ let passingSignals = false
33
+ function passSignalsOn(): void {
34
+ if (passingSignals) return
35
+ passingSignals = true
36
+ for (const [signal, code] of [
37
+ ['SIGTERM', 143],
38
+ ['SIGINT', 130],
39
+ ] as const)
40
+ process.on(signal, () => {
41
+ for (const child of LIVE) {
42
+ try {
43
+ process.kill(-child.pid, 'SIGINT')
44
+ } catch {
45
+ // The group emptied between its suite ending and this signal.
46
+ }
39
47
  }
40
- }
41
- process.exit(code)
42
- })
48
+ process.exit(code)
49
+ })
50
+ }
43
51
 
44
52
  export type Suite = {
45
53
  file: string
@@ -63,10 +71,20 @@ function unescapeXml(value: string): string {
63
71
  .replaceAll('&amp;', '&')
64
72
  }
65
73
 
66
- /** One `Suite` per `<testsuite>` in a JUnit report, bun's or playwright's. */
74
+ /**
75
+ * One `Suite` per top-level `<testsuite>` in a JUnit report, bun's or playwright's.
76
+ *
77
+ * A NESTED `<testsuite>` IS A `describe`, not a file: bun writes one inside its file's suite, whose
78
+ * own counts already include it, so its cases join the file's and its counts are not added again.
79
+ */
67
80
  export function parseJUnit(xml: string): Suite[] {
68
81
  const suites: Suite[] = []
82
+ // How many `<testsuite>`s are open where the next one starts.
83
+ let depth = 0
69
84
  for (const block of xml.split('<testsuite ').slice(1)) {
85
+ const nested = depth > 0
86
+ // This one opens, and every `</testsuite>` before the next one closes.
87
+ depth += 2 - block.split('</testsuite>').length
70
88
  const head = block.slice(0, block.indexOf('>'))
71
89
  const cases: TestCase[] = []
72
90
  for (const entry of block.split('<testcase ').slice(1)) {
@@ -81,6 +99,11 @@ export function parseJUnit(xml: string): Suite[] {
81
99
  failure: failure ? unescapeXml(failure[1] ?? '') : null,
82
100
  })
83
101
  }
102
+ const enclosing = suites[suites.length - 1]
103
+ if (nested && enclosing !== undefined) {
104
+ for (const one of cases) enclosing.cases.push(one)
105
+ continue
106
+ }
84
107
  suites.push({
85
108
  file: attribute(head, 'name'),
86
109
  tests: Number.parseInt(attribute(head, 'tests'), 10) || 0,
@@ -127,6 +150,7 @@ export async function runSuite(spec: {
127
150
  }): Promise<{ suites: Suite[]; milliseconds: number }> {
128
151
  const report = `${tmpdir()}/abide-suite-${crypto.randomUUID()}.xml`
129
152
  const pointed = spec.reportTo(report)
153
+ passSignalsOn()
130
154
  const startedAt = Bun.nanoseconds()
131
155
  const child = Bun.spawn({
132
156
  cmd: [...spec.command, ...pointed.args],