Skip to content

Commit 76c0255

Browse files
committed
Merge branch 'topic/gnatcov' into 'master'
Slugify trace file names See merge request eng/ide/ada_language_server!1948
2 parents 5db2d65 + f00d110 commit 76c0255

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

integration/vscode/ada/src/gnattest.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CancellationToken } from 'vscode-languageclient';
99
import { adaExtState } from './extension';
1010
import { addCoverageData, GnatcovFileCoverage } from './gnatcov';
1111
import { getScenarioArgs } from './gnatTaskProvider';
12-
import { escapeRegExp, exe, getObjectDir, setTerminalEnvironment } from './helpers';
12+
import { escapeRegExp, exe, getObjectDir, setTerminalEnvironment, slugify } from './helpers';
1313
import {
1414
DEFAULT_PROBLEM_MATCHER,
1515
findTaskByName,
@@ -609,7 +609,7 @@ async function handleRunRequestedTests(
609609
const tracesDir = path.dirname(execPath);
610610

611611
function getTracePath(test: TestItem): string {
612-
return path.join(tracesDir, test.id + '.srctrace');
612+
return path.join(tracesDir, slugify(test.id) + '.srctrace');
613613
}
614614

615615
/**

integration/vscode/ada/src/helpers.ts

+9
Original file line numberDiff line numberDiff line change
@@ -627,3 +627,12 @@ export function staggerProgress(
627627
return lastProgress;
628628
}
629629
}
630+
631+
/**
632+
*
633+
* @param arg - a string
634+
* @returns a modified string suitable for use as a filename
635+
*/
636+
export function slugify(arg: string): string {
637+
return arg.replace(/[<>:"/\\|?*]/g, '_');
638+
}

integration/vscode/ada/test/general/helpers.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
findAdaMain,
55
getSymbols,
66
parallelize,
7+
slugify,
78
staggerProgress,
89
which,
910
} from '../../src/helpers';
@@ -343,4 +344,9 @@ suite('staggerProgress', function () {
343344
assert.ok(called, 'Progress reporting function was unexpectedly not called');
344345
assert.equal(lastProgress, 50);
345346
});
347+
348+
test('slugify', function () {
349+
assert.equal(slugify('file<>:"/\\|?*name'), 'file_________name');
350+
assert.equal(slugify('file<>:"/\\|?*name'), 'file' + '_'.repeat(9) + 'name');
351+
});
346352
});

0 commit comments

Comments
 (0)