Merge pull request #87999 from microsoft/tyriar/85257

Flush all buffered data events on terminal close
This commit is contained in:
Daniel Imms
2020-01-06 10:50:05 -08:00
committed by GitHub
5 changed files with 136 additions and 108 deletions

View File

@@ -69,7 +69,64 @@ suite('workspace-namespace', () => {
},
resolveTask(_task: Task): Task | undefined {
try {
assert.fail('resolveTask should not trigger during the test');
assert.fail('resolveTask should not trigger during the test');
} catch (e) {
done(e);
}
return undefined;
}
}));
commands.executeCommand('workbench.action.tasks.runTask', `${taskType}: ${taskName}`);
});
test('sync CustomExecution task should flush all data on close', (done) => {
interface CustomTestingTaskDefinition extends TaskDefinition {
/**
* One of the task properties. This can be used to customize the task in the tasks.json
*/
customProp1: string;
}
const taskType: string = 'customTesting';
const taskName = 'First custom task';
disposables.push(window.onDidOpenTerminal(term => {
disposables.push(window.onDidWriteTerminalData(e => {
try {
assert.equal(e.data, 'exiting');
} catch (e) {
done(e);
}
disposables.push(window.onDidCloseTerminal(() => done()));
term.dispose();
}));
}));
disposables.push(tasks.registerTaskProvider(taskType, {
provideTasks: () => {
const result: Task[] = [];
const kind: CustomTestingTaskDefinition = {
type: taskType,
customProp1: 'testing task one'
};
const writeEmitter = new EventEmitter<string>();
const closeEmitter = new EventEmitter<void>();
const execution = new CustomExecution((): Thenable<Pseudoterminal> => {
const pty: Pseudoterminal = {
onDidWrite: writeEmitter.event,
onDidClose: closeEmitter.event,
open: () => {
writeEmitter.fire('exiting');
closeEmitter.fire();
},
close: () => {}
};
return Promise.resolve(pty);
});
const task = new Task2(kind, TaskScope.Workspace, taskName, taskType, execution);
result.push(task);
return result;
},
resolveTask(_task: Task): Task | undefined {
try {
assert.fail('resolveTask should not trigger during the test');
} catch (e) {
done(e);
}