@abide/harness 0.3.2 → 0.4.0
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/engine/traceOp.ts +5 -5
- package/src/gate/inAFreshProcess.ts +2 -3
- package/src/measure/install.ts +21 -24
- package/src/measure/measure.ts +14 -22
- package/src/report/batch.ts +1 -1
- package/src/report/index.ts +2 -8
- package/src/report/substrate.ts +2 -1
- package/src/rows/index.ts +5 -33
- package/src/runner/harnessBench.ts +2 -2
- package/src/runner/runBenches.ts +2 -1
- package/src/runner/runSuite.ts +36 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abide/harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@playwright/test": "^1.64.0",
|
|
61
|
-
"@abide/abide": ">=0.
|
|
61
|
+
"@abide/abide": ">=0.126.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"@playwright/test": {
|
package/src/engine/traceOp.ts
CHANGED
|
@@ -119,15 +119,15 @@ async function traced(
|
|
|
119
119
|
})),
|
|
120
120
|
)
|
|
121
121
|
|
|
122
|
-
const
|
|
123
|
-
(
|
|
122
|
+
const delta = (name: string): number =>
|
|
123
|
+
(after[name] ?? 0) - (before[name] ?? 0)
|
|
124
|
+
const since = (name: string): number => delta(name) * 1e9
|
|
124
125
|
return {
|
|
125
126
|
op,
|
|
126
127
|
measures,
|
|
127
128
|
counters: {
|
|
128
|
-
recalcStyle:
|
|
129
|
-
|
|
130
|
-
layout: (after.LayoutCount ?? 0) - (before.LayoutCount ?? 0),
|
|
129
|
+
recalcStyle: delta('RecalcStyleCount'),
|
|
130
|
+
layout: delta('LayoutCount'),
|
|
131
131
|
paint,
|
|
132
132
|
forcedLayout,
|
|
133
133
|
},
|
|
@@ -12,9 +12,8 @@ const DEFAULT_TIMEOUT_MILLISECONDS = 30_000
|
|
|
12
12
|
* it: it is taken in a child.
|
|
13
13
|
*
|
|
14
14
|
* PART OF THE VOCABULARY RATHER THAN OF THIS PACKAGE'S TESTS, which is where it started and where
|
|
15
|
-
* it could not do its job.
|
|
16
|
-
*
|
|
17
|
-
* only reach by copying. It belongs beside `gate()` for the same reason `gate()` is a fifth
|
|
15
|
+
* it could not do its job. A gate needing this same preload-free invocation in another package
|
|
16
|
+
* could only reach a helper sitting in `packages/harness/tests/` by copying it. It belongs beside `gate()` for the same reason `gate()` is a fifth
|
|
18
17
|
* entry: both need `bun:test`, and neither is a lane.
|
|
19
18
|
*
|
|
20
19
|
* It is also the only place a HANG can be gated. `bun test`'s own per-test timeout is a timer, so
|
package/src/measure/install.ts
CHANGED
|
@@ -30,10 +30,9 @@
|
|
|
30
30
|
import type { Work } from './Work.ts'
|
|
31
31
|
|
|
32
32
|
type Role =
|
|
33
|
-
| '
|
|
33
|
+
| 'eachArg'
|
|
34
34
|
| 'insertFirstArg'
|
|
35
35
|
| 'insertSecondArg'
|
|
36
|
-
| 'removeArgs'
|
|
37
36
|
| 'removeReceiver'
|
|
38
37
|
| 'replaceChild'
|
|
39
38
|
| 'replaceReceiver'
|
|
@@ -55,31 +54,31 @@ type Role =
|
|
|
55
54
|
// both-substrates gate compares the two.
|
|
56
55
|
const DECLARED: [interfaceName: string, member: string, role: Role][] = [
|
|
57
56
|
['Node', 'insertBefore', 'insertFirstArg'],
|
|
58
|
-
['Node', 'appendChild', '
|
|
59
|
-
['Node', 'removeChild', '
|
|
57
|
+
['Node', 'appendChild', 'eachArg'],
|
|
58
|
+
['Node', 'removeChild', 'eachArg'],
|
|
60
59
|
['Node', 'replaceChild', 'replaceChild'],
|
|
61
60
|
['Node', 'cloneNode', 'clone'],
|
|
62
61
|
['Node', 'textContent', 'textContent'],
|
|
63
62
|
['Element', 'textContent', 'textContent'],
|
|
64
63
|
['CharacterData', 'textContent', 'textContent'],
|
|
65
64
|
['Element', 'remove', 'removeReceiver'],
|
|
66
|
-
['Element', 'before', '
|
|
67
|
-
['Element', 'after', '
|
|
65
|
+
['Element', 'before', 'eachArg'],
|
|
66
|
+
['Element', 'after', 'eachArg'],
|
|
68
67
|
['Element', 'replaceWith', 'replaceReceiver'],
|
|
69
68
|
['CharacterData', 'remove', 'removeReceiver'],
|
|
70
|
-
['CharacterData', 'before', '
|
|
71
|
-
['CharacterData', 'after', '
|
|
69
|
+
['CharacterData', 'before', 'eachArg'],
|
|
70
|
+
['CharacterData', 'after', 'eachArg'],
|
|
72
71
|
['CharacterData', 'replaceWith', 'replaceReceiver'],
|
|
73
|
-
['Element', 'append', '
|
|
74
|
-
['Element', 'prepend', '
|
|
72
|
+
['Element', 'append', 'eachArg'],
|
|
73
|
+
['Element', 'prepend', 'eachArg'],
|
|
75
74
|
['Element', 'replaceChildren', 'replaceChildren'],
|
|
76
75
|
// A KEYED REORDER IN CHROMIUM IS THIS CALL (`moveNode`), so leaving it off read
|
|
77
76
|
// every reorder there as 0 moves. One node moves, as with `insertBefore`.
|
|
78
77
|
['Element', 'moveBefore', 'insertFirstArg'],
|
|
79
78
|
['Document', 'moveBefore', 'insertFirstArg'],
|
|
80
79
|
['DocumentFragment', 'moveBefore', 'insertFirstArg'],
|
|
81
|
-
['Document', 'append', '
|
|
82
|
-
['Document', 'prepend', '
|
|
80
|
+
['Document', 'append', 'eachArg'],
|
|
81
|
+
['Document', 'prepend', 'eachArg'],
|
|
83
82
|
['Document', 'replaceChildren', 'replaceChildren'],
|
|
84
83
|
['Element', 'setAttribute', 'attribute'],
|
|
85
84
|
['Element', 'setAttributeNS', 'attribute'],
|
|
@@ -204,6 +203,12 @@ const TEXT_NODE = 3
|
|
|
204
203
|
const COMMENT_NODE = 8
|
|
205
204
|
const DOCUMENT_FRAGMENT_NODE = 11
|
|
206
205
|
|
|
206
|
+
/** A write to a text node's or a comment's data, and whether it wrote what was already there. */
|
|
207
|
+
function tallyDataWrite(receiver: CharacterData, value: unknown): void {
|
|
208
|
+
live.dataWrites += 1
|
|
209
|
+
if (receiver.data === String(value)) live.redundantDataWrites += 1
|
|
210
|
+
}
|
|
211
|
+
|
|
207
212
|
function tallyNode(node: unknown): void {
|
|
208
213
|
if (typeof node === 'string') {
|
|
209
214
|
// A string handed to `append` becomes a text node the call created.
|
|
@@ -280,7 +285,7 @@ function tallyBefore(
|
|
|
280
285
|
member: string,
|
|
281
286
|
): void {
|
|
282
287
|
switch (role) {
|
|
283
|
-
case '
|
|
288
|
+
case 'eachArg':
|
|
284
289
|
for (const argument of args) tallyNode(argument)
|
|
285
290
|
return
|
|
286
291
|
case 'insertFirstArg':
|
|
@@ -291,9 +296,6 @@ function tallyBefore(
|
|
|
291
296
|
case 'insertSecondArg':
|
|
292
297
|
tallyNode(args[1])
|
|
293
298
|
return
|
|
294
|
-
case 'removeArgs':
|
|
295
|
-
for (const argument of args) tallyNode(argument)
|
|
296
|
-
return
|
|
297
299
|
case 'removeReceiver':
|
|
298
300
|
tallyNode(receiver)
|
|
299
301
|
return
|
|
@@ -325,19 +327,14 @@ function tallyBefore(
|
|
|
325
327
|
case 'styleObject':
|
|
326
328
|
// Counted by the proxy the getter hands back, not here.
|
|
327
329
|
return
|
|
328
|
-
case 'data':
|
|
329
|
-
|
|
330
|
-
if ((receiver as CharacterData).data === String(args[0]))
|
|
331
|
-
live.redundantDataWrites += 1
|
|
330
|
+
case 'data':
|
|
331
|
+
tallyDataWrite(receiver as CharacterData, args[0])
|
|
332
332
|
return
|
|
333
|
-
}
|
|
334
333
|
case 'textContent': {
|
|
335
334
|
// On a text node or a comment this IS a data write, and counting it as a
|
|
336
335
|
// subtree replacement would report a creation that never happened.
|
|
337
336
|
if (isCharacterData(receiver)) {
|
|
338
|
-
|
|
339
|
-
if ((receiver as CharacterData).data === String(args[0]))
|
|
340
|
-
live.redundantDataWrites += 1
|
|
337
|
+
tallyDataWrite(receiver as CharacterData, args[0])
|
|
341
338
|
return
|
|
342
339
|
}
|
|
343
340
|
tallyChildren(receiver)
|
package/src/measure/measure.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// A CASE IS ARMED AND DISARMED,
|
|
1
|
+
// A CASE IS ARMED AND DISARMED around a body, with the published counters zeroed before and copied after.
|
|
2
2
|
|
|
3
3
|
import { arm, blankWork, disarm } from './install.ts'
|
|
4
4
|
import { PUBLISHED_WORK_KEY, type PublishedWork } from './PUBLISHED_WORK.ts'
|
|
@@ -18,17 +18,14 @@ function sources(): PublishedWork | null {
|
|
|
18
18
|
return record as PublishedWork
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
let openCase: Work | null = null
|
|
22
|
-
|
|
23
21
|
/**
|
|
24
|
-
*
|
|
22
|
+
* Zeroes every published counter as a case opens.
|
|
25
23
|
*
|
|
26
24
|
* ONLY A FIELD THAT IS THERE AND IS A NUMBER IS ZEROED. Writing a field the source never declared
|
|
27
25
|
* would create it at 0 and read it back at 0, and every gate asserting it would pass against a
|
|
28
26
|
* counter nothing increments — so a missing field stays missing, and `publishedBy` names it.
|
|
29
27
|
*/
|
|
30
|
-
function
|
|
31
|
-
const record = blankWork()
|
|
28
|
+
function zeroPublished(): void {
|
|
32
29
|
const published = sources()
|
|
33
30
|
if (published)
|
|
34
31
|
for (const source in published) {
|
|
@@ -36,16 +33,10 @@ function armCase(): void {
|
|
|
36
33
|
for (const field in counters)
|
|
37
34
|
if (typeof counters[field] === 'number') counters[field] = 0
|
|
38
35
|
}
|
|
39
|
-
openCase = record
|
|
40
|
-
arm(record)
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
/**
|
|
44
|
-
function
|
|
45
|
-
const record = openCase
|
|
46
|
-
if (!record) throw new Error('disarmCase() was called with no case armed.')
|
|
47
|
-
disarm()
|
|
48
|
-
openCase = null
|
|
38
|
+
/** Copies every published source's numbers into `record` as its case closes. */
|
|
39
|
+
function copyPublished(record: Work): void {
|
|
49
40
|
const published = sources()
|
|
50
41
|
if (published) {
|
|
51
42
|
const copied: PublishedWork = {}
|
|
@@ -60,21 +51,22 @@ function disarmCase(): Work {
|
|
|
60
51
|
}
|
|
61
52
|
record.published = copied
|
|
62
53
|
}
|
|
63
|
-
return record
|
|
64
54
|
}
|
|
65
55
|
|
|
66
56
|
/** Runs `body` inside an armed case and returns the `Work` it did. */
|
|
67
57
|
export function measure(body: () => void): Work {
|
|
68
|
-
|
|
58
|
+
const record = blankWork()
|
|
59
|
+
zeroPublished()
|
|
60
|
+
arm(record)
|
|
61
|
+
// The case is closed before a throw leaves, or the next `measure()` reports that one is
|
|
62
|
+
// already armed and the real failure is two frames down.
|
|
69
63
|
try {
|
|
70
64
|
body()
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// that one is already armed and the real failure is two frames down.
|
|
74
|
-
disarmCase()
|
|
75
|
-
throw error
|
|
65
|
+
} finally {
|
|
66
|
+
disarm()
|
|
76
67
|
}
|
|
77
|
-
|
|
68
|
+
copyPublished(record)
|
|
69
|
+
return record
|
|
78
70
|
}
|
|
79
71
|
|
|
80
72
|
/**
|
package/src/report/batch.ts
CHANGED
package/src/report/index.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
// NOT A LANE. All three lanes need every name in here, in both
|
|
2
2
|
// substrates, and they ship into the browser injectable — so a lane is a DEPENDENCY
|
|
3
3
|
// partition and this depends on nothing, which makes it a leaf rather than a fourth
|
|
4
|
-
// question.
|
|
5
|
-
//
|
|
6
|
-
// What is NOT here: the LOC counter and the `example.json` writer. Both run once, on
|
|
7
|
-
// bun, from a script, and both touch the filesystem — a `Bun.Glob` parked here would
|
|
8
|
-
// make the leaf bun-only, contradicting the one property it is justified by, and an
|
|
9
|
-
// import edge is priced by the module it lands on, so `measure` reaching for a clock
|
|
10
|
-
// would drag a glob into the module the injectable is built from. They live in
|
|
11
|
-
// `bun run bench`.
|
|
4
|
+
// question. Nothing here touches the filesystem: a `Bun.Glob` parked here would make the
|
|
5
|
+
// leaf bun-only, contradicting the one property it is justified by.
|
|
12
6
|
|
|
13
7
|
export { type Batched, type BatchSpec, batch } from './batch.ts'
|
|
14
8
|
export { emulatedDom } from './environment.ts'
|
package/src/report/substrate.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { underBun } from './environment.ts'
|
|
2
|
+
import type { Sample } from './Sample.ts'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Which JS engine this is, read off the user agent rather than probed.
|
|
@@ -14,7 +15,7 @@ import { underBun } from './environment.ts'
|
|
|
14
15
|
* panel that measures in the reader's own browser meets all three engines. Reporting `v8` for
|
|
15
16
|
* Safari would let `ratio()` compare two of them.
|
|
16
17
|
*/
|
|
17
|
-
export function substrate(): '
|
|
18
|
+
export function substrate(): Sample['substrate'] {
|
|
18
19
|
// Bun IS JSC, and it is the one case with no user agent worth reading.
|
|
19
20
|
if (underBun()) return 'jsc'
|
|
20
21
|
const agent = globalThis.navigator?.userAgent ?? ''
|
package/src/rows/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// WHAT
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// WHAT A ROW RUNNER WRITES AND A PAGE READS. A runner is a subprocess printing one JSON row per
|
|
2
|
+
// line; the docs app pipes those lines to the page without reading them, so this module is the
|
|
3
|
+
// whole of the contract between the two packages.
|
|
4
4
|
//
|
|
5
5
|
// PURE, AND IMPORTED BY THE PAGE: the filter a reader types and the filter the runner applies are
|
|
6
6
|
// this one function, so "run what I can see" runs exactly the rows on screen.
|
|
@@ -10,27 +10,11 @@ export type RowItem = { id: string; section: string; name: string }
|
|
|
10
10
|
/**
|
|
11
11
|
* Where a row is in its run.
|
|
12
12
|
*
|
|
13
|
-
* `broken` is the RUNNER failing — no report, a
|
|
13
|
+
* `broken` is the RUNNER failing — no report, or a suite stopped at its deadline (43.27) — and is
|
|
14
|
+
* not a red result.
|
|
14
15
|
*/
|
|
15
16
|
export type RowState = 'queued' | 'running' | 'done' | 'broken'
|
|
16
17
|
|
|
17
|
-
export type BenchRow = {
|
|
18
|
-
id: string
|
|
19
|
-
state: RowState
|
|
20
|
-
unit: string
|
|
21
|
-
/** The code under measurement's figure, in `unit`. */
|
|
22
|
-
subject: number | null
|
|
23
|
-
/** The hand-written arm's figure, in `unit`. */
|
|
24
|
-
handWritten: number | null
|
|
25
|
-
/** subject / handWritten as the lane is allowed to say it: a number, or why there is none. */
|
|
26
|
-
claim: string
|
|
27
|
-
/** The operations batched into one sample — `null` for a row that counts rather than times. */
|
|
28
|
-
n: number | null
|
|
29
|
-
/** The A/A floor as a fraction — `null` for a row that counts rather than times. */
|
|
30
|
-
floor: number | null
|
|
31
|
-
note: string
|
|
32
|
-
}
|
|
33
|
-
|
|
34
18
|
export type TestRow = {
|
|
35
19
|
id: string
|
|
36
20
|
state: RowState
|
|
@@ -55,18 +39,6 @@ export type TestCase = {
|
|
|
55
39
|
failure: string | null
|
|
56
40
|
}
|
|
57
41
|
|
|
58
|
-
/**
|
|
59
|
-
* The line the docs app writes after the rows it did send when a runner died part way.
|
|
60
|
-
*
|
|
61
|
-
* A stream whose head has gone out cannot fail with a status, and cut off it reads as a network
|
|
62
|
-
* error that says nothing of the runner's own.
|
|
63
|
-
*/
|
|
64
|
-
export type RunnerFailure = { failure: string }
|
|
65
|
-
|
|
66
|
-
export function isRunnerFailure(line: object): line is RunnerFailure {
|
|
67
|
-
return typeof (line as { failure?: unknown }).failure === 'string'
|
|
68
|
-
}
|
|
69
|
-
|
|
70
42
|
/**
|
|
71
43
|
* Whether `item` falls in `scope`: `all`, `section:<name>`, `item:<id>`, or nothing at all.
|
|
72
44
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// block each, and exit 1 after listing every arm over its ceiling and every ceiling naming no arm
|
|
4
4
|
// or no bench.
|
|
5
5
|
|
|
6
|
-
import { runBenches } from './runBenches.ts'
|
|
6
|
+
import { milliseconds, runBenches } from './runBenches.ts'
|
|
7
7
|
|
|
8
8
|
const over: string[] = []
|
|
9
9
|
for (const bench of await runBenches(process.cwd(), process.argv[2])) {
|
|
@@ -13,7 +13,7 @@ for (const bench of await runBenches(process.cwd(), process.argv[2])) {
|
|
|
13
13
|
if (bench.case === '') continue
|
|
14
14
|
let times = ''
|
|
15
15
|
for (const [arm, nanoseconds] of Object.entries(bench.arms))
|
|
16
|
-
times += `${times === '' ? '' : ' · '}${arm} ${(nanoseconds
|
|
16
|
+
times += `${times === '' ? '' : ' · '}${arm} ${milliseconds(nanoseconds)}`
|
|
17
17
|
console.log(
|
|
18
18
|
`${bench.file} ${bench.name}: ${bench.case}\n ${times}\n ${bench.claim}`,
|
|
19
19
|
)
|
package/src/runner/runBenches.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Batched, claimOf, ratio } from '../report/index.ts'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** `nanoseconds` as the milliseconds a bench line prints. */
|
|
4
|
+
export const milliseconds = (nanoseconds: number) =>
|
|
4
5
|
`${(nanoseconds / 1e6).toFixed(3)} ms`
|
|
5
6
|
|
|
6
7
|
/**
|
package/src/runner/runSuite.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
// whole job is showing what is red cannot fall over when something is. It throws only when the
|
|
9
9
|
// runner produced no report at all, which is a different thing and one the page has to say out
|
|
10
10
|
// loud: a suite that HANGS reports nothing, and "0 failures" read off an absent file is the worst
|
|
11
|
-
// answer available.
|
|
11
|
+
// answer available. So a hung suite is STOPPED at a deadline rather than waited on — its row would
|
|
12
|
+
// otherwise read "running" for as long as the page stays open (RULEBOOK 43.27).
|
|
12
13
|
|
|
13
14
|
import { tmpdir } from 'node:os' // bun has no temporary-directory lookup of its own
|
|
14
15
|
|
|
@@ -30,6 +31,19 @@ import type { TestCase } from '../rows/index.ts'
|
|
|
30
31
|
// INSTALLED WITH THE FIRST SUITE rather than on import: a process that only reads this module's
|
|
31
32
|
// parser has no suite to pass a signal on to, and is not this module's to exit.
|
|
32
33
|
const LIVE = new Set<Bun.Subprocess>()
|
|
34
|
+
|
|
35
|
+
// Several times the slowest file on record — a docs spec across both of its projects, ~1.2 min.
|
|
36
|
+
const SUITE_DEADLINE_MILLISECONDS = 10 * 60_000
|
|
37
|
+
// What a suite gets to tear down its own servers after SIGINT before its group is killed outright.
|
|
38
|
+
const TEARDOWN_MILLISECONDS = 10_000
|
|
39
|
+
|
|
40
|
+
function signalGroup(child: Bun.Subprocess, signal: NodeJS.Signals): void {
|
|
41
|
+
try {
|
|
42
|
+
process.kill(-child.pid, signal)
|
|
43
|
+
} catch {
|
|
44
|
+
// The group emptied between its suite ending and this signal.
|
|
45
|
+
}
|
|
46
|
+
}
|
|
33
47
|
let passingSignals = false
|
|
34
48
|
function passSignalsOn(): void {
|
|
35
49
|
if (passingSignals) return
|
|
@@ -39,13 +53,7 @@ function passSignalsOn(): void {
|
|
|
39
53
|
['SIGINT', 130],
|
|
40
54
|
] as const)
|
|
41
55
|
process.on(signal, () => {
|
|
42
|
-
for (const child of LIVE)
|
|
43
|
-
try {
|
|
44
|
-
process.kill(-child.pid, 'SIGINT')
|
|
45
|
-
} catch {
|
|
46
|
-
// The group emptied between its suite ending and this signal.
|
|
47
|
-
}
|
|
48
|
-
}
|
|
56
|
+
for (const child of LIVE) signalGroup(child, 'SIGINT')
|
|
49
57
|
process.exit(code)
|
|
50
58
|
})
|
|
51
59
|
}
|
|
@@ -141,14 +149,17 @@ export const PLAYWRIGHT_REPORT: ReportTo = (path) => ({
|
|
|
141
149
|
/**
|
|
142
150
|
* Runs one test command with a JUnit reporter and returns its parsed suites and wall time.
|
|
143
151
|
*
|
|
144
|
-
* A red run resolves;
|
|
152
|
+
* A red run resolves; a missing report throws, and so does a run past `deadline` — see the file
|
|
153
|
+
* header.
|
|
145
154
|
*/
|
|
146
155
|
export async function runSuite(spec: {
|
|
147
156
|
command: string[]
|
|
148
157
|
reportTo: ReportTo
|
|
149
158
|
cwd: string
|
|
150
159
|
environment?: Record<string, string>
|
|
160
|
+
deadline?: number
|
|
151
161
|
}): Promise<{ suites: Suite[]; milliseconds: number }> {
|
|
162
|
+
const deadline = spec.deadline ?? SUITE_DEADLINE_MILLISECONDS
|
|
152
163
|
const report = `${tmpdir()}/abide-suite-${crypto.randomUUID()}.xml`
|
|
153
164
|
const pointed = spec.reportTo(report)
|
|
154
165
|
passSignalsOn()
|
|
@@ -162,12 +173,28 @@ export async function runSuite(spec: {
|
|
|
162
173
|
detached: true,
|
|
163
174
|
})
|
|
164
175
|
LIVE.add(child)
|
|
176
|
+
let pastDeadline = false
|
|
177
|
+
let killing: Timer | undefined
|
|
178
|
+
const stopping = setTimeout(() => {
|
|
179
|
+
pastDeadline = true
|
|
180
|
+
signalGroup(child, 'SIGINT')
|
|
181
|
+
killing = setTimeout(
|
|
182
|
+
() => signalGroup(child, 'SIGKILL'),
|
|
183
|
+
TEARDOWN_MILLISECONDS,
|
|
184
|
+
)
|
|
185
|
+
}, deadline)
|
|
165
186
|
const [stderr] = await Promise.all([
|
|
166
187
|
new Response(child.stderr).text(),
|
|
167
188
|
child.exited,
|
|
168
189
|
])
|
|
190
|
+
clearTimeout(stopping)
|
|
191
|
+
clearTimeout(killing)
|
|
169
192
|
LIVE.delete(child)
|
|
170
193
|
const milliseconds = (Bun.nanoseconds() - startedAt) / 1e6
|
|
194
|
+
if (pastDeadline)
|
|
195
|
+
throw new Error(
|
|
196
|
+
`the suite ran past its ${deadline} ms deadline and was stopped.\n${stderr.slice(-2000)}`,
|
|
197
|
+
)
|
|
171
198
|
|
|
172
199
|
const file = Bun.file(report)
|
|
173
200
|
if (!(await file.exists()))
|