Skip to content

Commit 439685f

Browse files
authored
chore(cli-repl): use separate tmpdir for userId persistence test (#453)
With a similar purpose like #449.
1 parent 8d95a6b commit 439685f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/cli-repl/src/cli-repl.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { PassThrough, Duplex } from 'stream';
2-
import { promisify } from 'util';
32
import path from 'path';
43
import { promises as fs } from 'fs';
54
import { once } from 'events';
6-
import rimraf from 'rimraf';
75
import CliRepl, { CliReplOptions } from './cli-repl';
86
import { startTestServer } from '../../../testing/integration-testing-hooks';
97
import { expect, useTmpdir, waitEval, fakeTTYProps } from '../test/repl-helpers';
@@ -75,7 +73,6 @@ describe('CliRepl', () => {
7573
context('during startup', () => {
7674
it('persists userId', async() => {
7775
const userIds: string[] = [];
78-
await promisify(rimraf)(tmpdir.path);
7976
for (let i = 0; i < 2; i++) {
8077
cliRepl = new CliRepl(cliReplOptions);
8178
cliRepl.bus.on('mongosh:new-user', userId => userIds.push(userId));

packages/cli-repl/test/repl-helpers.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ function useTmpdir(): { readonly path: string } {
2222
});
2323

2424
afterEach(async() => {
25-
promisify(rimraf)(tmpdir);
25+
try {
26+
await promisify(rimraf)(tmpdir);
27+
} catch (err) {
28+
// On Windows in CI, this can fail with EPERM for some reason.
29+
// If it does, just log the error instead of failing all tests.
30+
console.error('Could not remove fake home directory:', err);
31+
}
2632
});
2733

2834
return {

0 commit comments

Comments
 (0)