Skip to content

Commit 50867d6

Browse files
FIX: @W-19972333@: Stop creating log files in our test directory
1 parent bc1e986 commit 50867d6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/lib/actions/ConfigAction.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'node:path';
22
import * as fs from 'node:fs';
3+
import * as os from 'node:os';
34
import * as fsp from 'node:fs/promises';
45
import ansis from 'ansis';
56
import {CodeAnalyzerConfig} from "@salesforce/code-analyzer-core";
@@ -252,19 +253,19 @@ describe('ConfigAction tests', () => {
252253
{prop: 'log_folder'}
253254
])(`When derivable property $prop input is non-null and non-default, it is rendered as-is`, async ({prop}) => {
254255
// ==== SETUP ====
255-
// Make the config root and log folder both be the folder above this one.
256-
const parentOfCurrentDirectory = path.resolve(__dirname, '..');
257-
stubConfigFactory.dummyConfigRoot = parentOfCurrentDirectory;
258-
stubConfigFactory.dummyLogFolder = parentOfCurrentDirectory;
256+
// Make the config root and log folder both a non-default temp folder
257+
const nonDefaultFolder: string = fs.mkdtempSync(path.join(os.tmpdir(), 'my-temp-'));
258+
stubConfigFactory.dummyConfigRoot = nonDefaultFolder;
259+
stubConfigFactory.dummyLogFolder = nonDefaultFolder;
259260

260261
// ==== TESTED BEHAVIOR ====
261262
// Just select all rules for this test, since we don't care about the rules here.
262263
const output = await runActionAndGetDisplayedConfig(dependencies, ['all']);
263264

264265
// ==== ASSERTIONS ====
265266
const goldFileContents = (await readGoldFile(path.join(PATH_TO_COMPARISON_DIR, 'derivables-as-non-defaults', `${prop}.yml.goldfile`)))
266-
.replace('__DUMMY_CONFIG_ROOT__', parentOfCurrentDirectory)
267-
.replace('__DUMMY_LOG_FOLDER__', parentOfCurrentDirectory)
267+
.replace('__DUMMY_CONFIG_ROOT__', nonDefaultFolder)
268+
.replace('__DUMMY_LOG_FOLDER__', nonDefaultFolder)
268269
.replace('__DUMMY_DEFAULT_CONFIG_ROOT__', 'null')
269270
.replace('__DUMMY_DEFAULT_LOG_FOLDER__', 'null')
270271
expect(output).toContain(goldFileContents);

0 commit comments

Comments
 (0)