Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit f1f265c

Browse files
committed
Test that tasks are actually auto-detected
1 parent 901f5df commit f1f265c

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

fixtures/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/target
2+
Cargo.lock

fixtures/bare-lib-project/Cargo.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "bare-lib-project"
3+
version = "0.1.0"
4+
authors = ["Example <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]

fixtures/bare-lib-project/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[cfg(test)]
2+
mod tests {
3+
#[test]
4+
fn it_works() {
5+
assert_eq!(2 + 2, 4);
6+
}
7+
}

src/test/extension.test.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import * as assert from 'assert';
2+
import * as path from 'path';
3+
import * as vscode from 'vscode';
4+
// tslint:disable-next-line: no-duplicate-imports
5+
import { Uri } from 'vscode';
6+
7+
const fixtureDir = path.resolve(path.join(__dirname, '..', '..', 'fixtures'));
8+
9+
suite('Extension Tests', () => {
10+
test('cargo tasks are auto-detected', async () => {
11+
const projectPath = path.join(fixtureDir, 'bare-lib-project');
12+
const projectUri = Uri.file(projectPath);
13+
14+
await vscode.commands.executeCommand('vscode.openFolder', projectUri);
15+
await vscode.workspace.openTextDocument(
16+
Uri.file(path.join(projectPath, 'src', 'lib.rs')),
17+
);
18+
19+
const expected = [
20+
{ subcommand: 'build', group: vscode.TaskGroup.Build },
21+
{ subcommand: 'check', group: vscode.TaskGroup.Build },
22+
{ subcommand: 'test', group: vscode.TaskGroup.Test },
23+
{ subcommand: 'clean', group: vscode.TaskGroup.Clean },
24+
];
25+
26+
const tasks = await vscode.tasks.fetchTasks();
27+
28+
for (const { subcommand, group } of expected) {
29+
assert(
30+
tasks.some(
31+
task =>
32+
task.definition.type === 'cargo' &&
33+
task.definition.subcommand === subcommand &&
34+
task.group === group,
35+
),
36+
);
37+
}
38+
});
39+
});

0 commit comments

Comments
 (0)