Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #213573 #213574

Merged
merged 1 commit into from
May 27, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -303,5 +325,5 @@ export const PlatformTestRunner =
process.platform === 'win32'
? WindowsTestRunner
: process.platform === 'darwin'
? DarwinTestRunner
: PosixTestRunner;
? DarwinTestRunner
: PosixTestRunner;
Loading