mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
fix(testrunner): properly run tests when the first arg is a file (#3472)
This commit is contained in:
parent
69e1e713ef
commit
0c798f0572
@ -34,8 +34,7 @@ program
|
|||||||
.option('--timeout <timeout>', 'Specify test timeout threshold (in milliseconds), default: 10000', 10000)
|
.option('--timeout <timeout>', 'Specify test timeout threshold (in milliseconds), default: 10000', 10000)
|
||||||
.action(async (command) => {
|
.action(async (command) => {
|
||||||
// Collect files
|
// Collect files
|
||||||
const files = [];
|
const files = collectFiles(path.join(process.cwd(), command.args[0]), command.args.slice(1));
|
||||||
collectFiles(path.join(process.cwd(), command.args[0]), command.args.slice(1), files);
|
|
||||||
const rootSuite = new Mocha.Suite('', new Mocha.Context(), true);
|
const rootSuite = new Mocha.Suite('', new Mocha.Context(), true);
|
||||||
|
|
||||||
let total = 0;
|
let total = 0;
|
||||||
@ -61,6 +60,11 @@ program
|
|||||||
mocha.suite.title = path.basename(file);
|
mocha.suite.title = path.basename(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!total) {
|
||||||
|
console.error('No tests found.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Filter tests.
|
// Filter tests.
|
||||||
if (rootSuite.hasOnly())
|
if (rootSuite.hasOnly())
|
||||||
rootSuite.filterOnly();
|
rootSuite.filterOnly();
|
||||||
@ -88,12 +92,13 @@ program
|
|||||||
|
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
|
|
||||||
function collectFiles(dir, filters, files) {
|
function collectFiles(dir, filters) {
|
||||||
if (fs.statSync(dir).isFile())
|
if (fs.statSync(dir).isFile())
|
||||||
return [dir];
|
return [dir];
|
||||||
|
const files = [];
|
||||||
for (const name of fs.readdirSync(dir)) {
|
for (const name of fs.readdirSync(dir)) {
|
||||||
if (fs.lstatSync(path.join(dir, name)).isDirectory()) {
|
if (fs.lstatSync(path.join(dir, name)).isDirectory()) {
|
||||||
collectFiles(path.join(dir, name), filters, files);
|
files.push(...collectFiles(path.join(dir, name), filters));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!name.includes('spec'))
|
if (!name.includes('spec'))
|
||||||
@ -109,4 +114,5 @@ function collectFiles(dir, filters, files) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return files;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user