Skip to content

Commit d747f98

Browse files
committed
run integration tests serially by default
1 parent 3296c22 commit d747f98

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

integrations/utils.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ interface TestFlags {
6565
only?: boolean
6666
skip?: boolean
6767
debug?: boolean
68+
concurrent?: boolean
6869
}
6970

7071
type SpawnActor = { predicate: (message: string) => boolean; resolve: () => void }
@@ -85,7 +86,7 @@ export function test(
8586
name: string,
8687
config: TestConfig,
8788
testCallback: TestCallback,
88-
{ only = false, skip = false, debug = false }: TestFlags = {},
89+
{ only = false, skip = false, debug = false, concurrent = false }: TestFlags = {},
8990
) {
9091
return defaultTest(
9192
name,
@@ -94,7 +95,7 @@ export function test(
9495
retry: process.env.CI ? 2 : 0,
9596
only: only || (!process.env.CI && debug),
9697
skip,
97-
concurrent: true,
98+
concurrent,
9899
},
99100
async (options) => {
100101
let rootDir = debug ? path.join(REPO_ROOT, '.debug') : TMP_ROOT
@@ -435,11 +436,18 @@ export function test(
435436
let disposables: (() => Promise<void>)[] = []
436437

437438
async function dispose() {
438-
await Promise.all(disposables.map((dispose) => dispose()))
439+
let results = await Promise.allSettled(disposables.map((dispose) => dispose()))
439440

440441
if (!debug) {
441442
await gracefullyRemove(root)
442443
}
444+
445+
let errors = results.flatMap((result) =>
446+
result.status === 'rejected' ? [result.reason] : [],
447+
)
448+
if (errors.length > 0) {
449+
throw new AggregateError(errors, 'Failed to clean up spawned processes')
450+
}
443451
}
444452

445453
options.onTestFinished(dispose)
@@ -468,6 +476,9 @@ test.only = (name: string, config: TestConfig, testCallback: TestCallback) => {
468476
test.skip = (name: string, config: TestConfig, testCallback: TestCallback) => {
469477
return test(name, config, testCallback, { skip: true })
470478
}
479+
test.concurrent = (name: string, config: TestConfig, testCallback: TestCallback) => {
480+
return test(name, config, testCallback, { concurrent: true })
481+
}
471482
test.debug = (name: string, config: TestConfig, testCallback: TestCallback) => {
472483
return test(name, config, testCallback, { debug: true })
473484
}

0 commit comments

Comments
 (0)