Skip to content

Commit 0cb5897

Browse files
authored
test: remove tmp dir created for circular fixes in multithread mode test (#20146)
1 parent bb99566 commit 0cb5897

File tree

1 file changed

+42
-19
lines changed

1 file changed

+42
-19
lines changed

tests/bin/eslint.js

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,11 +1410,27 @@ describe("bin/eslint.js", () => {
14101410
return Promise.all([exitCodeAssertion, outputAssertion]);
14111411
});
14121412

1413-
it("should warn exactly once for a file with circular fixes", async () => {
1414-
const cwd = fs.mkdtempSync(
1415-
path.join(os.tmpdir(), "eslint-circular-fixes-"),
1416-
);
1417-
const configSrc = `
1413+
describe("with circular fixes", () => {
1414+
let cwd;
1415+
1416+
beforeEach(() => {
1417+
cwd = fs.mkdtempSync(
1418+
path.join(os.tmpdir(), "eslint-circular-fixes-"),
1419+
);
1420+
});
1421+
1422+
afterEach(() => {
1423+
if (cwd) {
1424+
fs.rmSync(cwd, {
1425+
recursive: true,
1426+
force: true,
1427+
});
1428+
cwd = void 0;
1429+
}
1430+
});
1431+
1432+
it("should warn exactly once for a file with circular fixes", async () => {
1433+
const configSrc = `
14181434
export default {
14191435
plugins: {
14201436
"circular-fixes": {
@@ -1470,22 +1486,29 @@ describe("bin/eslint.js", () => {
14701486
},
14711487
};
14721488
`;
1473-
fs.writeFileSync(path.join(cwd, "file.js"), "foo");
1474-
fs.writeFileSync(path.join(cwd, "eslint.config.mjs"), configSrc);
1475-
const child = runESLint(["--concurrency=2", "--fix", "file.js"], {
1476-
cwd,
1477-
});
1478-
const exitCodeAssertion = assertExitCode(child, 1);
1479-
const outputAssertion = getOutput(child).then(output => {
1480-
// The warning message should appear exactly once in stderr
1481-
assert.strictEqual(
1482-
[...output.stderr.matchAll("Circular fixes detected")]
1483-
.length,
1484-
1,
1489+
fs.writeFileSync(path.join(cwd, "file.js"), "foo");
1490+
fs.writeFileSync(
1491+
path.join(cwd, "eslint.config.mjs"),
1492+
configSrc,
14851493
);
1486-
});
1494+
const child = runESLint(
1495+
["--concurrency=2", "--fix", "file.js"],
1496+
{
1497+
cwd,
1498+
},
1499+
);
1500+
const exitCodeAssertion = assertExitCode(child, 1);
1501+
const outputAssertion = getOutput(child).then(output => {
1502+
// The warning message should appear exactly once in stderr
1503+
assert.strictEqual(
1504+
[...output.stderr.matchAll("Circular fixes detected")]
1505+
.length,
1506+
1,
1507+
);
1508+
});
14871509

1488-
return Promise.all([exitCodeAssertion, outputAssertion]);
1510+
return Promise.all([exitCodeAssertion, outputAssertion]);
1511+
});
14891512
});
14901513
});
14911514

0 commit comments

Comments
 (0)