mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
committed by
GitHub
parent
014beb7eb8
commit
ccb4db151d
@@ -24,7 +24,7 @@ const ATTACH_CONFIG_NAME = 'Attach to VS Code';
|
||||
const DEBUG_TYPE = 'pwa-chrome';
|
||||
|
||||
export abstract class VSCodeTestRunner {
|
||||
constructor(protected readonly repoLocation: vscode.WorkspaceFolder) {}
|
||||
constructor(protected readonly repoLocation: vscode.WorkspaceFolder) { }
|
||||
|
||||
public async run(baseArgs: ReadonlyArray<string>, filter?: ReadonlyArray<vscode.TestItem>) {
|
||||
const args = this.prepareArguments(baseArgs, filter);
|
||||
@@ -163,18 +163,40 @@ export abstract class VSCodeTestRunner {
|
||||
path.relative(data.workspaceFolder.uri.fsPath, data.uri.fsPath).replace(/\\/g, '/')
|
||||
);
|
||||
|
||||
const itemDatas = filter.map(f => itemData.get(f));
|
||||
/** If true, we have to be careful with greps, as a grep for one test file affects the run of the other test file. */
|
||||
const hasBothTestCaseOrTestSuiteAndTestFileFilters =
|
||||
itemDatas.some(d => (d instanceof TestCase) || (d instanceof TestSuite)) &&
|
||||
itemDatas.some(d => d instanceof TestFile);
|
||||
|
||||
function addTestCaseOrSuite(data: TestCase | TestSuite, test: vscode.TestItem): void {
|
||||
grepRe.push(escapeRe(data.fullName) + (data instanceof TestCase ? '$' : ' '));
|
||||
for (let p = test.parent; p; p = p.parent) {
|
||||
const parentData = itemData.get(p);
|
||||
if (parentData instanceof TestFile) {
|
||||
addTestFileRunPath(parentData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const test of filter) {
|
||||
const data = itemData.get(test);
|
||||
if (data instanceof TestCase || data instanceof TestSuite) {
|
||||
grepRe.push(escapeRe(data.fullName) + (data instanceof TestCase ? '$' : ' '));
|
||||
for (let p = test.parent; p; p = p.parent) {
|
||||
const parentData = itemData.get(p);
|
||||
if (parentData instanceof TestFile) {
|
||||
addTestFileRunPath(parentData);
|
||||
addTestCaseOrSuite(data, test);
|
||||
} else if (data instanceof TestFile) {
|
||||
if (!hasBothTestCaseOrTestSuiteAndTestFileFilters) {
|
||||
addTestFileRunPath(data);
|
||||
} else {
|
||||
// We add all the items individually so they get their own grep expressions.
|
||||
for (const [_id, nestedTest] of test.children) {
|
||||
const childData = itemData.get(nestedTest);
|
||||
if (childData instanceof TestCase || childData instanceof TestSuite) {
|
||||
addTestCaseOrSuite(childData, nestedTest);
|
||||
} else {
|
||||
console.error('Unexpected test item in test file', nestedTest.id, nestedTest.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (data instanceof TestFile) {
|
||||
addTestFileRunPath(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,5 +325,5 @@ export const PlatformTestRunner =
|
||||
process.platform === 'win32'
|
||||
? WindowsTestRunner
|
||||
: process.platform === 'darwin'
|
||||
? DarwinTestRunner
|
||||
: PosixTestRunner;
|
||||
? DarwinTestRunner
|
||||
: PosixTestRunner;
|
||||
|
||||
Reference in New Issue
Block a user