Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/test/standardTest.ts
Original file line number Diff line number Diff line change
@@ -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();
23 changes: 17 additions & 6 deletions src/test/workspaceSymbols/standard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@ 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());
suiteTeardown(() => closeActiveWindows());
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);
Expand All @@ -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);
Expand Down