mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 00:59:03 +01:00
Make task execution event tests more specific
This commit is contained in:
@@ -138,35 +138,45 @@ import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomEx
|
||||
commands.executeCommand('workbench.action.tasks.runTask', `${taskType}: ${taskName}`);
|
||||
});
|
||||
|
||||
test('Execution from event is equal to original', () => {
|
||||
test('Execution from onDidEndTaskProcess is equal to original', () => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const task = new Task({ type: 'testTask' }, TaskScope.Workspace, 'echo', 'testTask', new ShellExecution('echo', ['hello test']));
|
||||
const taskExecution = await tasks.executeTask(task);
|
||||
let equalCount = 2;
|
||||
function checkEqualCount() {
|
||||
equalCount--;
|
||||
if (equalCount === 0) {
|
||||
resolve();
|
||||
} else if (equalCount < 0) {
|
||||
reject('Unexpected extra task events.');
|
||||
}
|
||||
}
|
||||
|
||||
tasks.onDidStartTaskProcess(e => {
|
||||
if (e.execution === taskExecution) {
|
||||
checkEqualCount();
|
||||
} else {
|
||||
disposables.push(tasks.onDidStartTaskProcess(e => {
|
||||
if (e.execution !== taskExecution) {
|
||||
reject('Unexpected task execution value in start process.');
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
tasks.onDidEndTaskProcess(e => {
|
||||
disposables.push(tasks.onDidEndTaskProcess(e => {
|
||||
if (e.execution === taskExecution) {
|
||||
checkEqualCount();
|
||||
resolve();
|
||||
} else {
|
||||
reject('Unexpected task execution value in end process.');
|
||||
}
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
test('Execution from onDidStartTaskProcess is equal to original', () => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const task = new Task({ type: 'testTask' }, TaskScope.Workspace, 'echo', 'testTask', new ShellExecution('echo', ['hello test']));
|
||||
const taskExecution = await tasks.executeTask(task);
|
||||
|
||||
disposables.push(tasks.onDidStartTaskProcess(e => {
|
||||
if (e.execution === taskExecution) {
|
||||
resolve();
|
||||
} else {
|
||||
reject('Unexpected task execution value in start process.');
|
||||
}
|
||||
}));
|
||||
|
||||
disposables.push(tasks.onDidEndTaskProcess(e => {
|
||||
if (e.execution !== taskExecution) {
|
||||
reject('Unexpected task execution value in end process.');
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user