Skip to content

Commit 660766c

Browse files
committed
Improve error reporting in task testing
1 parent 69fb111 commit 660766c

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TESTER=$(ROOTDIR)/.obj/tester/tester-run$(EXE)
3535
MOCHA_ALS_UPDATE=
3636

3737
GPRBUILD_EXTRA=
38-
GPRBUILD_FLAGS=-m -j4 $(GPRBUILD_EXTRA)
38+
GPRBUILD_FLAGS=-m -j0 $(GPRBUILD_EXTRA)
3939
GPRBUILD=gprbuild $(GPRBUILD_FLAGS) -XSUPERPROJECT=
4040
GPRCLEAN_EXTRA=
4141
GPRCLEAN=gprclean -XSUPERPROJECT= $(GPRCLEAN_EXTRA)

integration/vscode/ada/test/suite/utils.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export async function getCommandLines(prov: SimpleTaskProvider) {
8888
return actualCommandLines;
8989
}
9090
export async function runTaskAndGetResult(task: vscode.Task): Promise<number | undefined> {
91-
return await new Promise((resolve, reject) => {
91+
return await new Promise<number | undefined>((resolve, reject) => {
9292
let started = false;
9393

9494
const startDisposable = vscode.tasks.onDidStartTask((e) => {
@@ -114,17 +114,27 @@ export async function runTaskAndGetResult(task: vscode.Task): Promise<number | u
114114
* error occured during startup. Reject the promise.
115115
*/
116116
if (!started) {
117-
reject(
118-
Error(
119-
`The task '${getConventionalTaskLabel(
120-
task
121-
)}' was not started, likely due to an error`
122-
)
123-
);
117+
const msg = `The task '${getConventionalTaskLabel(
118+
task
119+
)}' was not started, likely due to an error.\n`;
120+
reject(Error(msg));
124121
}
125122
}, 3000);
126123

127124
void vscode.tasks.executeTask(task);
125+
}).catch(async (reason) => {
126+
if (reason instanceof Error) {
127+
let msg = 'The current list of tasks is:\n';
128+
msg += await vscode.tasks.fetchTasks({ type: task.definition.type }).then(
129+
(list) => list.map(getConventionalTaskLabel).join('\n'),
130+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
131+
(reason) => `fetchTasks promise was rejected: ${reason}`
132+
);
133+
134+
reason.message += '\n' + msg;
135+
}
136+
137+
return Promise.reject(reason);
128138
});
129139
}
130140
export function getCmdLine(exec: vscode.ShellExecution) {
@@ -156,7 +166,14 @@ export async function testTask(
156166
if (execStatus != 0) {
157167
let msg = `Got status ${execStatus ?? "'undefined'"} for task '${taskName}'`;
158168
if (task.execution instanceof vscode.ShellExecution) {
159-
msg += ` with command line: ${getCmdLine(task.execution)}`;
169+
const cmdLine = [task.execution.command].concat(task.execution.args).map((arg) => {
170+
if (typeof arg == 'string') {
171+
return arg;
172+
} else {
173+
return arg.value;
174+
}
175+
});
176+
msg += ` with command line: ${cmdLine.join(' ')}`;
160177

161178
try {
162179
/**
@@ -166,19 +183,7 @@ export async function testTask(
166183
msg += `\nTrying to re-run the command explicitly in: ${cwd}`;
167184
const env = { ...process.env };
168185
setTerminalEnvironment(env);
169-
const cp = spawnSync(
170-
typeof task.execution.command == 'string'
171-
? task.execution.command
172-
: task.execution.command.value,
173-
task.execution.args.map((arg) => {
174-
if (typeof arg == 'string') {
175-
return arg;
176-
} else {
177-
return arg.value;
178-
}
179-
}),
180-
{ cwd: cwd, env: env }
181-
);
186+
const cp = spawnSync(cmdLine[0], cmdLine.slice(1), { cwd: cwd, env: env });
182187

183188
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
184189
msg += `\nProcess ended with exit code ${cp.status} and output:\n`;

0 commit comments

Comments
 (0)