fix: make tempDir unique across fast test runs
Use a counter to ensure each tempDir call gets a unique directory name, preventing collisions when tests run within the same millisecond.
This commit is contained in:
@@ -15,8 +15,9 @@ function makeSpawn(result: MockSpawnResult) {
|
|||||||
return mock(async (_cmd: string, _args: string[], _opts: SpawnCliConfig) => result);
|
return mock(async (_cmd: string, _args: string[], _opts: SpawnCliConfig) => result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tempDirCounter = 0;
|
||||||
function tempDir(): string {
|
function tempDir(): string {
|
||||||
const dir = join(tmpdir(), `differ-test-${Date.now()}`);
|
const dir = join(tmpdir(), `differ-test-${Date.now()}-${tempDirCounter++}`);
|
||||||
mkdirSync(dir, { recursive: true });
|
mkdirSync(dir, { recursive: true });
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user