Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/code-analyzer-core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 11 additions & 7 deletions packages/code-analyzer-core/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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});
Expand Down
Loading