Skip to content

Commit

Permalink
tests: Set up initial examples workspace when launching
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Compiler committed Jul 6, 2022
1 parent 3bc0159 commit 46ecf1f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as path from 'path';
import * as fs_promises from 'fs/promises';

import { runTests } from '@vscode/test-electron';

Expand All @@ -12,11 +13,16 @@ async function main() {
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');

const exampleRoot = path.resolve(extensionDevelopmentPath, './src/test/examples');
const exampleBasenames = await fs_promises.readdir(exampleRoot);
const examplePaths = exampleBasenames.map((dir) => path.resolve(exampleRoot, dir));

// Download VS Code, unzip it and run the integration test
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: ['--disable-extensions']
// open a multi-folder workspace with all test example dirs
launchArgs: ['--disable-extensions'].concat(examplePaths)
});
} catch (err) {
console.error('Failed to run tests');
Expand Down
16 changes: 8 additions & 8 deletions src/test/suite/toxTaskProvider.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { doesNotMatch, strict as assert } from 'assert';
import * as path from 'path';

// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
Expand All @@ -13,17 +14,16 @@ suite('ToxTaskProvider Test Suite', () => {
test('getting tox tasks', async() => {
const dir = utils.getExampleDir("allenvs");

const allEnvsWorkspaceFolder = {
uri: vscode.Uri.file(dir),
name: "AllEnvs",
index: 0,
};

vscode.workspace.updateWorkspaceFolders(0, null, allEnvsWorkspaceFolder);
// make sure we started with the expected workspace, as we can't change
// workspaces in tests:
// https://github.com/microsoft/vscode/issues/69335
assert.ok(vscode.workspace.workspaceFolders);
assert.equal(path.basename(vscode.workspace.workspaceFolders[0].uri.fsPath), "allenvs");

const toxTaskProvider = new tasks.ToxTaskProvider(dir);
const toxTasks = await toxTaskProvider.provideTasks();
assert.equal(toxTasks?.length, 3);
assert.equal(toxTasks?.length, 6);
// from allenvs workspace folder
assert.equal(toxTasks[0].name, "one");
assert.equal(toxTasks[1].name, "two");
assert.equal(toxTasks[2].name, "three");
Expand Down

0 comments on commit 46ecf1f

Please sign in to comment.