Skip to content

Commit a10da7b

Browse files
committed
Pass gnatcov traces in a file
1 parent 36cfd8e commit a10da7b

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ section below it for the last release. -->
1111
invocations in the same workspace, causing sporadic errors. Alire invocations
1212
are now made sequentially using file-based synchronization across ALS
1313
processes.
14+
* Support customizing GNATcoverage tasks, e.g. to select a coverage level
1415
* Support importing MC/DC reports from GNATcoverage
1516

1617
## 26.0.202504171

integration/vscode/ada/src/gnattest.ts

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ import { addCoverageData, GnatcovFileCoverage } from './gnatcov';
1111
import { getScenarioArgs } from './gnatTaskProvider';
1212
import { escapeRegExp, exe, setTerminalEnvironment, slugify } from './helpers';
1313
import {
14-
DEFAULT_PROBLEM_MATCHERS,
1514
findTaskByName,
1615
getOrCreateTask,
1716
runTaskSequence,
18-
SimpleTaskDef,
1917
TASK_BUILD_TEST_DRIVER,
2018
TASK_GNATCOV_SETUP,
2119
TASK_TYPE_ADA,
@@ -732,29 +730,38 @@ async function handleRunRequestedTests(
732730
* Produce a GNATcov XML report
733731
*/
734732
const outputDir = await getGnatCovXMLReportDir();
735-
const adaTP = adaExtState.getAdaTaskProvider()!;
736-
const gnatcovReportTask = (await adaTP.resolveTask(
737-
new vscode.Task(
738-
{
739-
type: TASK_TYPE_ADA,
740-
command: 'gnatcov',
741-
args: [
742-
'coverage',
743-
'-P',
744-
await getGnatTestDriverProjectPath(),
745-
'--level=stmt',
746-
'--annotate=xml',
747-
`--output-dir=${outputDir}`,
748-
].concat(testsToRun.map(getTracePath)),
749-
},
750-
vscode.TaskScope.Workspace,
751-
`Create GNATcoverage XML report`,
752-
TASK_TYPE_ADA,
753-
undefined,
754-
DEFAULT_PROBLEM_MATCHERS,
755-
),
756-
))!;
757-
gnatcovReportTask.presentationOptions.reveal = vscode.TaskRevealKind.Never;
733+
/**
734+
* Use a trace list file with gnatcov for 2 reasons:
735+
*
736+
* 1. Avoid any potential limitation on the number of process
737+
* arguments in case we are dealing with a large number of traces.
738+
*
739+
* 2. Keep a constant command line instead of having a different
740+
* command line for every run. Different command lines would create
741+
* multiple copies of the task with the same name in the VS Code
742+
* UI.
743+
*/
744+
const traceListFile = path.join(
745+
await adaExtState.getVSCodeObjectSubdir(),
746+
'traces.list',
747+
);
748+
fs.writeFileSync(traceListFile, testsToRun.map(getTracePath).join('\n'));
749+
const gnatcovReportTask = await getOrCreateTask(
750+
`Create GNATcoverage XML report`,
751+
async () => ({
752+
type: TASK_TYPE_ADA,
753+
command: 'gnatcov',
754+
args: [
755+
'coverage',
756+
'-P',
757+
await getGnatTestDriverProjectPath(),
758+
'--level=stmt',
759+
'--annotate=xml',
760+
`--output-dir=${outputDir}`,
761+
`--trace=@${traceListFile}`,
762+
],
763+
}),
764+
);
758765
const result = await runTaskSequence([gnatcovReportTask], new WriteEmitter(run));
759766
if (result != 0) {
760767
const msg =

0 commit comments

Comments
 (0)