diff --git a/packages/code-analyzer-core/src/config.ts b/packages/code-analyzer-core/src/config.ts index 057d8cd7..a73834f2 100644 --- a/packages/code-analyzer-core/src/config.ts +++ b/packages/code-analyzer-core/src/config.ts @@ -151,7 +151,7 @@ export class CodeAnalyzerConfig { custom_engine_plugin_modules: configExtractor.extractArray(FIELDS.CUSTOM_ENGINE_PLUGIN_MODULES, engApi.ValueValidator.validateString, DEFAULT_CONFIG.custom_engine_plugin_modules)!, - root_working_folder: !rawConfig.root_working_folder ? os.tmpdir() : validateAbsoluteFolder(rawConfig.root_working_folder, FIELDS.ROOT_WORKING_FOLDER), + root_working_folder: configExtractor.extractFolder(FIELDS.ROOT_WORKING_FOLDER, DEFAULT_CONFIG.root_working_folder)!, preserve_all_working_folders: configExtractor.extractBoolean(FIELDS.PRESERVE_ALL_WORKING_FOLDERS, DEFAULT_CONFIG.preserve_all_working_folders)!, rules: extractRulesValue(configExtractor), engines: extractEnginesValue(configExtractor) diff --git a/packages/code-analyzer-core/test/config.test.ts b/packages/code-analyzer-core/test/config.test.ts index 5e1f0faa..e39496eb 100644 --- a/packages/code-analyzer-core/test/config.test.ts +++ b/packages/code-analyzer-core/test/config.test.ts @@ -308,9 +308,18 @@ describe("Tests for creating and accessing configuration values", () => { getMessageFromCatalog(SHARED_MESSAGE_CATALOG, 'ConfigValueMustBeOfType','preserve_all_working_folders', 'boolean', 'string')); }) - it("When supplied root_working_folder is a valid absolute path, then we use it", () => { + it.each([ + { + case: 'absolute', + testPath: path.join(TEST_DATA_DIR, 'sampleWorkspace') + }, + { + case: 'relative', + testPath: path.join('test', 'test-data', 'sampleWorkspace') + } + ])("When supplied root_working_folder is a valid $case path, then we use it", ({testPath}) => { const workingFoldersRootValue: string = path.join(TEST_DATA_DIR, 'sampleWorkspace'); - const conf: CodeAnalyzerConfig = CodeAnalyzerConfig.fromObject({root_working_folder: workingFoldersRootValue}); + const conf: CodeAnalyzerConfig = CodeAnalyzerConfig.fromObject({root_working_folder: testPath}); expect(conf.getRootWorkingFolder()).toEqual(workingFoldersRootValue); }); @@ -324,11 +333,6 @@ describe("Tests for creating and accessing configuration values", () => { getMessageFromCatalog(SHARED_MESSAGE_CATALOG, 'ConfigFolderValueMustNotBeFile', 'root_working_folder', path.resolve('package.json'))); }); - it("When supplied root_working_folder is a relative folder, then we error", () => { - expect(() => CodeAnalyzerConfig.fromObject({root_working_folder: 'test/test-data'})).toThrow( - getMessage('ConfigPathValueMustBeAbsolute', 'root_working_folder', 'test/test-data', path.resolve('test', 'test-data'))); - }); - it("When supplied config_root path is a valid absolute path, then we use it", () => { const configRootValue: string = path.join(TEST_DATA_DIR, 'sampleWorkspace'); const conf: CodeAnalyzerConfig = CodeAnalyzerConfig.fromObject({config_root: configRootValue});