-
Notifications
You must be signed in to change notification settings - Fork 28.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77839 from microsoft/tyriar/task_vp_fix
Add CustomExecution2 test and make start fire after onDidOpenTerminal
- Loading branch information
Showing
3 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
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,62 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 taskProvider = vscode.tasks.registerTaskProvider(taskType, { | ||
provideTasks: () => { | ||
const result: vscode.Task[] = []; | ||
const kind: CustomTestingTaskDefinition = { | ||
type: taskType, | ||
customProp1: 'testing task one' | ||
}; | ||
const writeEmitter = new vscode.EventEmitter<string>(); | ||
const execution = new vscode.CustomExecution2((): Thenable<vscode.TerminalVirtualProcess> => { | ||
return Promise.resolve(<vscode.TerminalVirtualProcess>{ | ||
onDidWrite: writeEmitter.event, | ||
start: () => { | ||
writeEmitter.fire('testing\r\n'); | ||
}, | ||
shutdown: () => { | ||
taskProvider.dispose(); | ||
done(); | ||
} | ||
}); | ||
}); | ||
const task = new vscode.Task2(kind, vscode.TaskScope.Workspace, taskName, taskType, execution); | ||
result.push(task); | ||
return result; | ||
}, | ||
resolveTask(_task: vscode.Task): vscode.Task | undefined { | ||
assert.fail('resolveTask should not trigger during the test'); | ||
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