-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create CustomExecution2 test, make start fire after onDidOpenTerminal
Part of #70978
- Loading branch information
Showing
3 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
extensions/vscode-api-tests/src/singlefolder-tests/workspace.tasks.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import * as vscode from 'vscode'; | ||
|
||
suite.only('workspace-namespace', () => { | ||
|
||
suite('Tasks', () => { | ||
|
||
test('CustomExecution2 task should start and shutdown successfully', (done) => { | ||
interface CustomTestingTaskDefinition extends vscode.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'; | ||
const reg1 = vscode.window.onDidOpenTerminal(term => { | ||
reg1.dispose(); | ||
const reg2 = term.onDidWriteData(e => { | ||
reg2.dispose(); | ||
assert.equal(e, 'testing\r\n'); | ||
term.dispose(); | ||
}); | ||
}); | ||
const exitEmitter = new vscode.EventEmitter<number>(); | ||
const taskProvider = vscode.tasks.registerTaskProvider(taskType, { | ||
provideTasks: () => { | ||
let result: vscode.Task[] = []; | ||
let kind: CustomTestingTaskDefinition = { | ||
type: taskType, | ||
customProp1: 'testing task one' | ||
}; | ||
const writeEmitter = new vscode.EventEmitter<string>(); | ||
let execution = new vscode.CustomExecution2((): Thenable<vscode.TerminalVirtualProcess> => { | ||
return Promise.resolve(<vscode.TerminalVirtualProcess>{ | ||
onDidWrite: writeEmitter.event, | ||
start: () => { | ||
writeEmitter.fire('testing\r\n'); | ||
}, | ||
onDidExit: exitEmitter.event, | ||
shutdown: () => { | ||
taskProvider.dispose(); | ||
done(); | ||
} | ||
}); | ||
}); | ||
let task = new vscode.Task2(kind, vscode.TaskScope.Workspace, taskName, taskType, execution); | ||
result.push(task); | ||
return result; | ||
}, | ||
resolveTask(_task: vscode.Task): vscode.Task | undefined { | ||
return undefined; | ||
} | ||
}); | ||
vscode.commands.executeCommand('workbench.action.tasks.runTask', `${taskType}: ${taskName}`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters