提交 ebc95649 编写于 作者: A Alex Ross

Add task API test for execution equality

Related to https://github.com/microsoft/vscode/issues/96643
上级 0a5e2599
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert'; import * as assert from 'assert';
import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomExecution, Pseudoterminal, TaskScope, commands, Task2, env, UIKind } from 'vscode'; import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomExecution, Pseudoterminal, TaskScope, commands, Task2, env, UIKind, ShellExecution } from 'vscode';
// Disable tasks tests: // Disable tasks tests:
// - Web https://github.com/microsoft/vscode/issues/90528 // - Web https://github.com/microsoft/vscode/issues/90528
...@@ -118,7 +118,7 @@ import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomEx ...@@ -118,7 +118,7 @@ import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomEx
writeEmitter.fire('exiting'); writeEmitter.fire('exiting');
closeEmitter.fire(); closeEmitter.fire();
}, },
close: () => {} close: () => { }
}; };
return Promise.resolve(pty); return Promise.resolve(pty);
}); });
...@@ -137,5 +137,37 @@ import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomEx ...@@ -137,5 +137,37 @@ import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomEx
})); }));
commands.executeCommand('workbench.action.tasks.runTask', `${taskType}: ${taskName}`); commands.executeCommand('workbench.action.tasks.runTask', `${taskType}: ${taskName}`);
}); });
test('Execution from event 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 {
reject('Unexpected task execution value in start process.');
}
});
tasks.onDidEndTaskProcess(e => {
if (e.execution === taskExecution) {
checkEqualCount();
} else {
reject('Unexpected task execution value in end process.');
}
});
});
});
}); });
}); });
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册