@abide/harness 0.2.0 → 0.2.2
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 +2 -2
- package/src/measure/install.ts +3 -3
- package/src/runner/runSuite.ts +38 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abide/harness",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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.
|
|
58
|
+
"@abide/abide": ">=0.113.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependenciesMeta": {
|
|
61
61
|
"@playwright/test": {
|
package/src/measure/install.ts
CHANGED
|
@@ -82,6 +82,7 @@ const DECLARED: [interfaceName: string, member: string, role: Role][] = [
|
|
|
82
82
|
['Document', 'prepend', 'insertArgs'],
|
|
83
83
|
['Document', 'replaceChildren', 'replaceChildren'],
|
|
84
84
|
['Element', 'setAttribute', 'attribute'],
|
|
85
|
+
['Element', 'setAttributeNS', 'attribute'],
|
|
85
86
|
['Element', 'removeAttribute', 'attribute'],
|
|
86
87
|
['Element', 'toggleAttribute', 'attribute'],
|
|
87
88
|
['Element', 'className', 'attribute'],
|
|
@@ -91,13 +92,14 @@ const DECLARED: [interfaceName: string, member: string, role: Role][] = [
|
|
|
91
92
|
// happy-dom gives `HTMLTemplateElement` its OWN `innerHTML`, which shadows the one
|
|
92
93
|
// above — so a `template.innerHTML` write reaches no patched member, the
|
|
93
94
|
// outermost-only guard never engages, and the parse's internal `createElementNS`
|
|
94
|
-
//
|
|
95
|
+
// calls are counted as creates of their own instead. The compiled arm makes every row from a
|
|
95
96
|
// template, so that is the whole arm. Chromium has no own descriptor here and the
|
|
96
97
|
// installer shadows, which is how the two lists stay identical.
|
|
97
98
|
['HTMLTemplateElement', 'innerHTML', 'html'],
|
|
98
99
|
['Element', 'outerHTML', 'html'],
|
|
99
100
|
['CharacterData', 'data', 'data'],
|
|
100
101
|
['Document', 'createElement', 'create'],
|
|
102
|
+
['Document', 'createElementNS', 'create'],
|
|
101
103
|
['Document', 'createTextNode', 'create'],
|
|
102
104
|
['Document', 'createComment', 'create'],
|
|
103
105
|
['Document', 'importNode', 'create'],
|
|
@@ -127,7 +129,6 @@ const DECLARED: [interfaceName: string, member: string, role: Role][] = [
|
|
|
127
129
|
['Node', 'normalize', 'refused'],
|
|
128
130
|
['Node', 'nodeValue', 'refused'],
|
|
129
131
|
['Element', 'insertAdjacentText', 'refused'],
|
|
130
|
-
['Element', 'setAttributeNS', 'refused'],
|
|
131
132
|
['Element', 'removeAttributeNS', 'refused'],
|
|
132
133
|
['Element', 'setAttributeNode', 'refused'],
|
|
133
134
|
['Element', 'removeAttributeNode', 'refused'],
|
|
@@ -138,7 +139,6 @@ const DECLARED: [interfaceName: string, member: string, role: Role][] = [
|
|
|
138
139
|
['CharacterData', 'replaceData', 'refused'],
|
|
139
140
|
['Text', 'splitText', 'refused'],
|
|
140
141
|
['Document', 'write', 'refused'],
|
|
141
|
-
['Document', 'createElementNS', 'refused'],
|
|
142
142
|
]
|
|
143
143
|
|
|
144
144
|
/** A fresh `Work` with every counted row at 0 and the three published rows at `null`. */
|
package/src/runner/runSuite.ts
CHANGED
|
@@ -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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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('&', '&')
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
/**
|
|
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],
|