Skip to content

Commit

Permalink
SCANNPM-39 exit parent process w correct exit code (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-paulger-sonarsource authored Jul 19, 2024
1 parent 9b2187a commit 744dc70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function scan(scanOptions: ScanOptions, cliArgs?: CliArgs) {
await runScan(scanOptions, cliArgs);
} catch (error) {
log(LogLevel.ERROR, `An error occurred: ${error}`);
throw error;
}
}

Expand Down
18 changes: 11 additions & 7 deletions test/unit/scan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ describe('scan', () => {
jest.spyOn(scannerCli, 'runScannerCli');
jest.spyOn(process, 'locateExecutableFromPath').mockResolvedValue(null);

await scan({ serverUrl: 'http://localhost:9000', localScannerCli: true });
await expect(
scan({ serverUrl: 'http://localhost:9000', localScannerCli: true }),
).rejects.toThrow(Error);

expect(scannerCli.downloadScannerCli).not.toHaveBeenCalled();
expect(scannerCli.runScannerCli).not.toHaveBeenCalled();
Expand Down Expand Up @@ -176,12 +178,14 @@ describe('scan', () => {
jest.spyOn(scannerEngine, 'runScannerEngine');
jest.spyOn(process, 'locateExecutableFromPath').mockResolvedValue(null);

await scan({
serverUrl: 'http://localhost:9000',
options: {
[ScannerProperty.SonarScannerSkipJreProvisioning]: 'true',
},
});
await expect(
scan({
serverUrl: 'http://localhost:9000',
options: {
[ScannerProperty.SonarScannerSkipJreProvisioning]: 'true',
},
}),
).rejects.toThrow(Error);

expect(scannerEngine.runScannerEngine).not.toHaveBeenCalled();
expect(scannerCli.runScannerCli).not.toHaveBeenCalled();
Expand Down

0 comments on commit 744dc70

Please sign in to comment.