Skip to content

Commit

Permalink
running a single tests
Browse files Browse the repository at this point in the history
  • Loading branch information
justjavac committed Apr 25, 2019
1 parent aaf0669 commit 1f6cead
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Inspired by [node-compat-table](https://github.com/williamkapke/node-compat-tabl
The `wpt` shell command provides a frontend to a variety of tools for working with and running [web-platform-tests](https://github.com/web-platform-tests/wpt). Some of the most useful commands are:

- [x] `./wpt run` - For running tests in Deno
- [x] `./wpt test <file>` - For running a single tests in Deno
- [x] `./wpt build` - For building the website
- [ ] `./wpt sync` - For syncing tests in `spec` from web-platform-tests repo
- [ ] `./wpt serve` - For starting the wpt http server (BUG & Need Help)
10 changes: 7 additions & 3 deletions lib/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,16 @@ export async function runTestsSerial(tests: TestDefinition[]): Promise<void> {
* Runs specified test cases.
* Parallel execution can be enabled via the boolean option; default: serial.
*/
export async function runTests(): Promise<void> {
export async function runTests(saveJson = false): Promise<void> {
console.log(`running ${tests.length} tests`);
await runTestsSerial(tests);
printResults();
reportJson();
reportTesters();

if (saveJson) {
reportJson();
reportTesters();
}

if (result._failed) {
// Use setTimeout to avoid the error being ignored due to unhandled
// promise rejections being swallowed.
Expand Down
13 changes: 12 additions & 1 deletion wpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@ switch (Deno.args[1]) {
}
}

runTests();
runTests(true);
break;
case "test":
if (!Deno.args[2]) {
console.log('Please input a file name. Usage: wpt test <filename>');
Deno.exit(1);
}

const content = Deno.readFileSync(Deno.args[2]);
const code: string = decoder.decode(content);
eval(code);
runTests(false);
break;
case "build":
build();
Expand Down

0 comments on commit 1f6cead

Please sign in to comment.