feat(testrunner): take the first argument as the test root dir (#3423)

This commit is contained in:
Joel Einbinder 2020-08-12 20:01:13 -07:00 committed by GitHub
parent f2088e068a
commit d3677357b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 12 deletions

View File

@ -38,7 +38,7 @@ jobs:
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
# Wrap `npm run` in a subshell to redirect STDERR to file. # Wrap `npm run` in a subshell to redirect STDERR to file.
# Enable core dumps in the subshell. # Enable core dumps in the subshell.
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000 && npm run coverage" - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner test/ --jobs=1 --forbid-only --timeout=30000 && npm run coverage"
env: env:
BROWSER: ${{ matrix.browser }} BROWSER: ${{ matrix.browser }}
DEBUG: "pw:*,-pw:wrapped*,-pw:test*" DEBUG: "pw:*,-pw:wrapped*,-pw:test*"
@ -69,7 +69,7 @@ jobs:
- uses: microsoft/playwright-github-action@v1 - uses: microsoft/playwright-github-action@v1
- run: npm ci - run: npm ci
- run: npm run build - run: npm run build
- run: node test/runner --jobs=1 --forbid-only --timeout=30000 - run: node test/runner test/ --jobs=1 --forbid-only --timeout=30000
env: env:
BROWSER: ${{ matrix.browser }} BROWSER: ${{ matrix.browser }}
DEBUG: "pw:*,-pw:wrapped*,-pw:test*" DEBUG: "pw:*,-pw:wrapped*,-pw:test*"
@ -103,7 +103,7 @@ jobs:
- uses: microsoft/playwright-github-action@v1 - uses: microsoft/playwright-github-action@v1
- run: npm ci - run: npm ci
- run: npm run build - run: npm run build
- run: node test/runner --jobs=1 --forbid-only --timeout=30000 - run: node test/runner test/ --jobs=1 --forbid-only --timeout=30000
shell: bash shell: bash
env: env:
BROWSER: ${{ matrix.browser }} BROWSER: ${{ matrix.browser }}
@ -160,7 +160,7 @@ jobs:
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
# Wrap `npm run` in a subshell to redirect STDERR to file. # Wrap `npm run` in a subshell to redirect STDERR to file.
# Enable core dumps in the subshell. # Enable core dumps in the subshell.
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000" - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner test/ --jobs=1 --forbid-only --timeout=30000"
if: ${{ always() }} if: ${{ always() }}
env: env:
BROWSER: ${{ matrix.browser }} BROWSER: ${{ matrix.browser }}
@ -194,7 +194,7 @@ jobs:
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
# Wrap `npm run` in a subshell to redirect STDERR to file. # Wrap `npm run` in a subshell to redirect STDERR to file.
# Enable core dumps in the subshell. # Enable core dumps in the subshell.
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000" - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner test/ --jobs=1 --forbid-only --timeout=30000"
env: env:
BROWSER: ${{ matrix.browser }} BROWSER: ${{ matrix.browser }}
DEBUG: "pw:*,-pw:wrapped*,-pw:test*" DEBUG: "pw:*,-pw:wrapped*,-pw:test*"

View File

@ -9,9 +9,9 @@
"node": ">=10.15.0" "node": ">=10.15.0"
}, },
"scripts": { "scripts": {
"ctest": "cross-env BROWSER=chromium node test/runner", "ctest": "cross-env BROWSER=chromium node test/runner test/",
"ftest": "cross-env BROWSER=firefox node test/runner", "ftest": "cross-env BROWSER=firefox node test/runner test/",
"wtest": "cross-env BROWSER=webkit node test/runner", "wtest": "cross-env BROWSER=webkit node test/runner test/",
"test": "npm run ctest && npm run ftest && npm run wtest", "test": "npm run ctest && npm run ftest && npm run wtest",
"eslint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src", "eslint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src",
"tsc": "tsc -p .", "tsc": "tsc -p .",

View File

@ -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(), 'test'), command.args, files);
const rootSuite = new Mocha.Suite('', new Mocha.Context(), true); const rootSuite = new Mocha.Suite('', new Mocha.Context(), true);
console.log(`Parsing ${files.length} test files`); console.log(`Parsing ${files.length} test files`);
@ -84,10 +83,13 @@ program
program.parse(process.argv); program.parse(process.argv);
function collectFiles(dir, filters, files) { function collectFiles(dir, filters) {
if (fs.statSync(dir).isFile())
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'))
@ -103,4 +105,5 @@ function collectFiles(dir, filters, files) {
} }
} }
} }
return files;
} }