Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCANNPM-49 Fix compatibility with other scanners (CLI, Scanner Engine) #182

Merged
merged 2 commits into from
Dec 12, 2024
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 src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const SONAR_DIR_DEFAULT = '.sonar';

export const SONAR_CACHE_DIR = 'cache';

export const UNARCHIVE_SUFFIX = '_extracted';
export const UNARCHIVE_SUFFIX = '_unzip';

export const SONAR_SCANNER_ALIAS = 'SonarScanner Engine';
export const JRE_ALIAS = 'JRE';
Expand Down
1 change: 1 addition & 0 deletions src/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function getDefaultProperties(): ScannerProperties {
process.env.HOME ?? process.env.USERPROFILE ?? '',
SONAR_DIR_DEFAULT,
),
[ScannerProperty.SonarWorkingDirectory]: '.scannerwork',
[ScannerProperty.SonarScannerOs]: getSupportedOS(),
[ScannerProperty.SonarScannerArch]: getArch(),
};
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export enum ScannerProperty {
SonarExclusions = 'sonar.exclusions',
SonarHostUrl = 'sonar.host.url',
SonarUserHome = 'sonar.userHome',
SonarWorkingDirectory = 'sonar.working.directory',
SonarScannerApiBaseUrl = 'sonar.scanner.apiBaseUrl',
SonarScannerOs = 'sonar.scanner.os',
SonarScannerArch = 'sonar.scanner.arch',
Expand Down
4 changes: 1 addition & 3 deletions test/unit/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,7 @@ describe('file', () => {
expect(fsExtra.mkdirSync).not.toHaveBeenCalled();

expect(archivePath).toEqual(path.join('/', 'sonar', 'cache', 'md5_test', 'file.txt'));
expect(unarchivePath).toEqual(
path.join('/', 'sonar', 'cache', 'md5_test', 'file.txt_extracted'),
);
expect(unarchivePath).toEqual(path.join('/', 'sonar', 'cache', 'md5_test', 'file.txt_unzip'));
});
it('should create the parent cache directory if it does not exist', async () => {
jest.spyOn(fsExtra, 'existsSync').mockImplementationOnce(() => false);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/java.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('java', () => {
describe('when the JRE is not cached', () => {
const mockCacheDirectories = {
archivePath: '/mocked-archive-path',
unarchivePath: '/mocked-archive-path_extracted',
unarchivePath: '/mocked-archive-path_unzip',
};
beforeEach(() => {
jest.spyOn(file, 'getCacheFileLocation').mockResolvedValue(null);
Expand Down
1 change: 1 addition & 0 deletions test/unit/mocks/FakeProjectMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class FakeProjectMock {

getExpectedProperties() {
return {
'sonar.working.directory': '.scannerwork',
'sonar.exclusions': DEFAULT_SONAR_EXCLUSIONS,
'sonar.projectBaseDir': this.projectPath,
'sonar.scanner.bootstrapStartTime': this.startTimeMs.toString(),
Expand Down
2 changes: 2 additions & 0 deletions test/unit/properties.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ describe('getProperties', () => {
options: {
'sonar.projectKey': 'use-this-project-key',
'sonar.scanner.os': 'some-os',
'sonar.working.directory': '.override',
},
},
projectHandler.getStartTime(),
Expand All @@ -150,6 +151,7 @@ describe('getProperties', () => {
'sonar.projectVersion': '1.0-SNAPSHOT',
'sonar.sources': 'the-sources',
'sonar.scanner.os': 'some-os',
'sonar.working.directory': '.override',
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/unit/scanner-engine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const MOCKED_PROPERTIES: ScannerProperties = {

const MOCK_CACHE_DIRECTORIES = {
archivePath: 'mocked/path/to/sonar/cache/sha_test/scanner-engine-1.2.3.jar',
unarchivePath: 'mocked/path/to/sonar/cache/sha_test/scanner-engine-1.2.3.jar_extracted',
unarchivePath: 'mocked/path/to/sonar/cache/sha_test/scanner-engine-1.2.3.jar_unzip',
};
jest.mock('../../src/constants', () => ({
...jest.requireActual('../../src/constants'),
Expand Down
Loading