@@ -58,3 +58,82 @@ test('tests run according to the group order', async () => {
5858 ✓ |1| example.1.test.ts > 1 <time>"
5959 ` )
6060} )
61+
62+ test ( 'the next group does not reuse a pool id that is still in use' , async ( ) => {
63+ const uniquePoolId = /* ts */ `
64+ import { mkdirSync, rmSync } from 'node:fs'
65+ import { onTestFinished, test } from 'vitest'
66+
67+ test('unique pool id', async () => {
68+ const locks = import.meta.dirname + '/../.locks'
69+ mkdirSync(locks, { recursive: true })
70+ const lock = locks + '/' + process.env.VITEST_POOL_ID
71+ mkdirSync(lock)
72+ onTestFinished(() => rmSync(lock, { recursive: true }))
73+ await new Promise(resolve => setTimeout(resolve, 200))
74+ })
75+ `
76+ const { stderr, testTree } = await runInlineTests (
77+ {
78+ // starts first with pool id 1 and finishes last in its group
79+ 'first/slow.test.ts' : `test('slow', () => new Promise(resolve => setTimeout(resolve, 500)))` ,
80+ 'first/fast-1.test.ts' : `test('fast', () => {})` ,
81+ 'first/fast-2.test.ts' : `test('fast', () => {})` ,
82+ 'first/fast-3.test.ts' : `test('fast', () => {})` ,
83+ 'second/1.test.ts' : uniquePoolId ,
84+ 'second/2.test.ts' : uniquePoolId ,
85+ 'second/3.test.ts' : uniquePoolId ,
86+ 'second/4.test.ts' : uniquePoolId ,
87+ } ,
88+ {
89+ $cliOptions : { globals : true , maxWorkers : 4 } ,
90+ projects : [
91+ {
92+ test : {
93+ name : 'first' ,
94+ include : [ './first/*.test.ts' ] ,
95+ } ,
96+ } ,
97+ {
98+ test : {
99+ name : 'second' ,
100+ include : [ './second/*.test.ts' ] ,
101+ sequence : {
102+ groupOrder : 1 ,
103+ } ,
104+ } ,
105+ } ,
106+ ] ,
107+ } ,
108+ )
109+
110+ expect ( stderr ) . toBe ( '' )
111+ expect ( testTree ( ) ) . toMatchInlineSnapshot ( `
112+ {
113+ "first/fast-1.test.ts": {
114+ "fast": "passed",
115+ },
116+ "first/fast-2.test.ts": {
117+ "fast": "passed",
118+ },
119+ "first/fast-3.test.ts": {
120+ "fast": "passed",
121+ },
122+ "first/slow.test.ts": {
123+ "slow": "passed",
124+ },
125+ "second/1.test.ts": {
126+ "unique pool id": "passed",
127+ },
128+ "second/2.test.ts": {
129+ "unique pool id": "passed",
130+ },
131+ "second/3.test.ts": {
132+ "unique pool id": "passed",
133+ },
134+ "second/4.test.ts": {
135+ "unique pool id": "passed",
136+ },
137+ }
138+ ` )
139+ } )
0 commit comments