Change how we check for relevant ql packs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import * as path from 'path';
|
||||
import { QLPackDiscovery, QLPack } from './qlpack-discovery';
|
||||
import { Discovery } from './discovery';
|
||||
import { EventEmitter, Event, Uri, RelativePattern, WorkspaceFolder, env } from 'vscode';
|
||||
import { EventEmitter, Event, Uri, RelativePattern, WorkspaceFolder, env, workspace } from 'vscode';
|
||||
import { MultiFileSystemWatcher } from './vscode-utils/multi-file-system-watcher';
|
||||
import { CodeQLCliServer } from './cli';
|
||||
|
||||
@@ -180,7 +180,7 @@ export class QLTestDiscovery extends Discovery<QLTestDiscoveryResults> {
|
||||
*/
|
||||
private isRelevantQlPack(qlPack: QLPack): boolean {
|
||||
return qlPack.name.endsWith('-tests')
|
||||
&& qlPack.uri.fsPath.startsWith(this.workspaceFolder.uri.fsPath);
|
||||
&& workspace.getWorkspaceFolder(qlPack.uri)?.index === this.workspaceFolder.index;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'vscode-test';
|
||||
import 'mocha';
|
||||
import { Uri } from 'vscode';
|
||||
import * as path from 'path';
|
||||
import { Uri, workspace } from 'vscode';
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { QLTestDiscovery } from '../../qltest-discovery';
|
||||
@@ -10,28 +11,29 @@ describe('qltest-discovery', () => {
|
||||
it('should check if a qlpack is relevant', () => {
|
||||
const qlTestDiscover: any = new QLTestDiscovery(
|
||||
{ onDidChangeQLPacks: () => ({}) } as any,
|
||||
{ uri: Uri.parse('file:///a/b/c') } as any,
|
||||
{ index: 0 } as any,
|
||||
{} as any
|
||||
);
|
||||
|
||||
const uri = workspace.workspaceFolders![0].uri;
|
||||
expect(qlTestDiscover.isRelevantQlPack({
|
||||
name: '-hucairz',
|
||||
uri: Uri.parse('file:///a/b/c/d')
|
||||
uri
|
||||
})).to.be.false;
|
||||
|
||||
expect(qlTestDiscover.isRelevantQlPack({
|
||||
name: '-tests',
|
||||
uri: Uri.parse('file:///a/b/')
|
||||
uri: Uri.file('/a/b/')
|
||||
})).to.be.false;
|
||||
|
||||
expect(qlTestDiscover.isRelevantQlPack({
|
||||
name: '-tests',
|
||||
uri: Uri.parse('file:///a/b/c')
|
||||
uri
|
||||
})).to.be.true;
|
||||
|
||||
expect(qlTestDiscover.isRelevantQlPack({
|
||||
name: '-tests',
|
||||
uri: Uri.parse('file:///a/b/c/d')
|
||||
uri: Uri.file(path.join(uri.fsPath, 'other'))
|
||||
})).to.be.true;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user