fix(tests): use array form for space-containing paths in CLI invocations

On machines where os.tmpdir() returns a path with a space (e.g.
/Volumes/Mini Me/tmp), runGsdTools() string args were whitespace-split by
the helper tokeniser, truncating paths at the first space.  Switch all
calls that embed a dynamic path into the argument list to the array form
of runGsdTools() so execFileSync receives each path as a single argv slot.

Fixes #3509

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-14 12:43:48 -04:00
parent 625ccf5217
commit c21bbf116e
6 changed files with 162 additions and 20 deletions

View File

@@ -28,7 +28,7 @@ describe('scan-sessions command', () => {
test('returns empty array for empty sessions directory', () => {
const sessionsDir = path.join(tmpDir, 'projects');
fs.mkdirSync(sessionsDir, { recursive: true });
const result = runGsdTools(`scan-sessions --path ${sessionsDir} --raw`, tmpDir);
const result = runGsdTools(['scan-sessions', '--path', sessionsDir, '--raw'], tmpDir);
assert.ok(result.success, `Failed: ${result.error}`);
const out = JSON.parse(result.output);
assert.ok(Array.isArray(out), 'should return an array');
@@ -47,7 +47,7 @@ describe('scan-sessions command', () => {
].join('\n');
fs.writeFileSync(path.join(projectDir, 'session-001.jsonl'), sessionData);
const result = runGsdTools(`scan-sessions --path ${sessionsDir} --raw`, tmpDir);
const result = runGsdTools(['scan-sessions', '--path', sessionsDir, '--raw'], tmpDir);
assert.ok(result.success, `Failed: ${result.error}`);
const out = JSON.parse(result.output);
assert.ok(Array.isArray(out), 'should return array');
@@ -65,7 +65,7 @@ describe('scan-sessions command', () => {
fs.writeFileSync(path.join(projectDir, `session-${i}.jsonl`), data + '\n');
}
const result = runGsdTools(`scan-sessions --path ${sessionsDir} --raw`, tmpDir);
const result = runGsdTools(['scan-sessions', '--path', sessionsDir, '--raw'], tmpDir);
assert.ok(result.success, `Failed: ${result.error}`);
const out = JSON.parse(result.output);
assert.strictEqual(out[0].sessionCount, 3);
@@ -102,7 +102,7 @@ describe('extract-messages command', () => {
messages.map(m => JSON.stringify(m)).join('\n')
);
const result = runGsdTools(`extract-messages my-project --path ${sessionsDir} --raw`, tmpDir);
const result = runGsdTools(['extract-messages', 'my-project', '--path', sessionsDir, '--raw'], tmpDir);
assert.ok(result.success, `Failed: ${result.error}`);
const out = JSON.parse(result.output);
assert.strictEqual(out.messages_extracted, 2, 'should extract 2 genuine user messages');
@@ -128,7 +128,7 @@ describe('extract-messages command', () => {
messages.map(m => JSON.stringify(m)).join('\n')
);
const result = runGsdTools(`extract-messages filter-test --path ${sessionsDir} --raw`, tmpDir);
const result = runGsdTools(['extract-messages', 'filter-test', '--path', sessionsDir, '--raw'], tmpDir);
assert.ok(result.success, `Failed: ${result.error}`);
const out = JSON.parse(result.output);
assert.strictEqual(out.messages_extracted, 2, 'should only extract 2 genuine external messages');