Skip to content

Commit 8aafc0a

Browse files
committed
Cleanup changes to CDS extractor
Applies suggestions from Copilot review of PR #203 for the `advanced-security/codeql-sap-js` repo.
1 parent 5dc8cf1 commit 8aafc0a

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

extractors/cds/tools/dist/cds-extractor.bundle.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extractors/cds/tools/dist/cds-extractor.bundle.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extractors/cds/tools/src/cds/compiler/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ function testCdsCommand(
311311
{
312312
encoding: 'utf8',
313313
stdio: 'pipe',
314-
timeout: 10000, // timeout after 10 seconds
314+
timeout: DEFAULT_COMMAND_TIMEOUT_MS, // timeout after 10 seconds
315315
cwd: sourceRoot,
316316
env: cleanEnv,
317317
},

extractors/cds/tools/test/src/diagnostics.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('diagnostics', () => {
9494
describe('addJavaScriptExtractorDiagnostic', () => {
9595
it('should add JavaScript extractor diagnostic successfully', () => {
9696
const filePath = '/path/to/source/root';
97-
const errorMessage = 'Message: JavaScript extracutor failed';
97+
const errorMessage = 'Message: JavaScript extractor failed';
9898
const codeqlExePath = '/path/to/codeql';
9999

100100
// Mock process.env to include necessary environment variable

extractors/cds/tools/validate-bundle.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const fs = require('fs');
44
const os = require('os');
55
const path = require('path');
66

7-
const DEFAULT_TIMEOUT_MS = 5000; // Default timeout for execution in milliseconds
7+
const CMD_TIMEOUT_MS = 5000; // Default timeout for execution in milliseconds
88
const MAX_BUNDLE_SIZE_MB = 0.5; // We expect the bundle to be quite small
99

1010
const bundlePath = path.join(__dirname, 'dist', 'cds-extractor.bundle.js');
@@ -45,22 +45,19 @@ try {
4545
fs.mkdirSync(testDir, { recursive: true });
4646
}
4747

48-
// Test with a timeout to avoid hanging
49-
// We expect this to fail or timeout since we're not providing proper arguments
50-
// but it should at least start execution
51-
const nodeCmd = `node "${bundlePath}" "${testDir}"`;
52-
48+
// Test with a timeout to avoid hanging. We expect this to fail or timeout since
49+
// we are not providing proper arguments but it should at least start execution.
5350
try {
54-
execSync(nodeCmd, {
51+
execSync(`node "${bundlePath}" "${testDir}"`, {
5552
stdio: 'pipe',
5653
cwd: testDir,
57-
timeout: DEFAULT_TIMEOUT_MS,
54+
timeout: CMD_TIMEOUT_MS,
5855
encoding: 'utf8',
5956
});
6057
console.log('✅ Bundle execution completed successfully');
6158
} catch (error) {
6259
// We expect this to fail or timeout in test environment
63-
if (error.code === 'TIMEOUT' || error.signal === 'SIGTERM') {
60+
if (error.killed) {
6461
console.log('✅ Bundle execution test passed (timed out as expected)');
6562
} else if (error.status !== 0) {
6663
// Check if it's a controlled exit (expected behavior)

0 commit comments

Comments
 (0)