diff --git a/package.json b/package.json index b0901281ecb4..4f65dd8eb20e 100644 --- a/package.json +++ b/package.json @@ -1593,7 +1593,7 @@ "vscode:prepublish": "tsc -p ./ && webpack", "compile": "webpack && tsc -watch -p ./", "postinstall": "node ./node_modules/vscode/bin/install", - "test": "node ./node_modules/vscode/bin/test && node ./out/test/multiRootTest.js" + "test": "node ./out/test/standardTest.js && node ./out/test/multiRootTest.js" }, "dependencies": { "anser": "^1.1.0", diff --git a/src/test/standardTest.ts b/src/test/standardTest.ts new file mode 100644 index 000000000000..ee31d40bb142 --- /dev/null +++ b/src/test/standardTest.ts @@ -0,0 +1,8 @@ +import * as path from 'path'; + +process.env.CODE_TESTS_WORKSPACE = path.join(__dirname, '..', '..', 'src', 'test'); + +function start() { + require('../../node_modules/vscode/bin/test'); +} +start(); diff --git a/src/test/workspaceSymbols/standard.test.ts b/src/test/workspaceSymbols/standard.test.ts index f7e0270d4fd9..f32a9de3efa7 100644 --- a/src/test/workspaceSymbols/standard.test.ts +++ b/src/test/workspaceSymbols/standard.test.ts @@ -8,7 +8,7 @@ import { WorkspaceSymbolProvider } from '../../client/workspaceSymbols/provider' import { enableDisableWorkspaceSymbols } from './common'; import { PythonSettings } from '../../client/common/configSettings'; -const symbolFilesPath = path.join(__dirname, '..', '..', '..', 'src', 'test', 'symbolFiles'); +const workspaceUri = Uri.file(path.join(__dirname, '..', '..', '..', 'src', 'test')); suite('Workspace Symbols', () => { suiteSetup(() => initialize()); @@ -16,15 +16,18 @@ suite('Workspace Symbols', () => { setup(() => PythonSettings.dispose()); teardown(async () => { await closeActiveWindows(); - await enableDisableWorkspaceSymbols(Uri.file(path.join(symbolFilesPath, 'file.py')), false, ConfigurationTarget.Workspace); + await enableDisableWorkspaceSymbols(workspaceUri, false, ConfigurationTarget.Workspace); }); test(`symbols should be returned when enabeld and vice versa`, async () => { - const workspaceUri = Uri.file(path.join(symbolFilesPath, 'file.py')); const outputChannel = new MockOutputChannel('Output'); - await enableDisableWorkspaceSymbols(workspaceUri, false, ConfigurationTarget.Workspace); + // The workspace will be in the output test folder + // So lets modify the settings so it sees the source test folder + let settings = PythonSettings.getInstance(workspaceUri); + settings.workspaceSymbols.tagFilePath = path.join(workspaceUri.fsPath, '.vscode', 'tags') + let generator = new Generator(workspaceUri, outputChannel); let provider = new WorkspaceSymbolProvider([generator], outputChannel); let symbols = await provider.provideWorkspaceSymbols('', new CancellationTokenSource().token); @@ -33,17 +36,25 @@ suite('Workspace Symbols', () => { await enableDisableWorkspaceSymbols(workspaceUri, true, ConfigurationTarget.Workspace); + // The workspace will be in the output test folder + // So lets modify the settings so it sees the source test folder + settings = PythonSettings.getInstance(workspaceUri); + settings.workspaceSymbols.tagFilePath = path.join(workspaceUri.fsPath, '.vscode', 'tags') + generator = new Generator(workspaceUri, outputChannel); provider = new WorkspaceSymbolProvider([generator], outputChannel); symbols = await provider.provideWorkspaceSymbols('', new CancellationTokenSource().token); assert.notEqual(symbols.length, 0, 'Symbols should be returned when workspace symbols are turned on'); }); test(`symbols should be filtered correctly`, async () => { - const workspaceUri = Uri.file(path.join(symbolFilesPath, 'file.py')); const outputChannel = new MockOutputChannel('Output'); - await enableDisableWorkspaceSymbols(workspaceUri, true, ConfigurationTarget.Workspace); + // The workspace will be in the output test folder + // So lets modify the settings so it sees the source test folder + const settings = PythonSettings.getInstance(workspaceUri); + settings.workspaceSymbols.tagFilePath = path.join(workspaceUri.fsPath, '.vscode', 'tags') + const generators = [new Generator(workspaceUri, outputChannel)]; const provider = new WorkspaceSymbolProvider(generators, outputChannel); const symbols = await provider.provideWorkspaceSymbols('meth1Of', new CancellationTokenSource().token);