Skip to content

Commit 0d7c50a

Browse files
joyeecheungpriyank-p
authored andcommitted
git-node: load supported WPT modules from file system
Load the supported tests from `test/wpt/status` foler for flexibility. Also removes a redundant file.
1 parent e473aca commit 0d7c50a

2 files changed

Lines changed: 19 additions & 35 deletions

File tree

components/git/wpt.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
'use strict';
22

3-
const yargs = require('yargs');
3+
const fs = require('fs');
4+
const path = require('path');
45
const Request = require('../../lib/request');
56
const CLI = require('../../lib/cli');
67
const auth = require('../../lib/auth');
78
const { WPTUpdater, HarnessUpdater } = require('../../lib/wpt');
89
const { runPromise } = require('../../lib/run');
910

10-
// TODO: read this from test/wpt/status/*.json
11-
const SUPPORTED_TESTS = ['url', 'console', 'encoding'];
1211
function builder(yargs) {
1312
return yargs
1413
.positional('name', {
15-
describe: 'Subset of the WPT to update, e.g. \'url\'',
16-
type: 'string',
17-
choices: ['all', 'harness'].concat(SUPPORTED_TESTS)
14+
describe: 'Subset of the WPT to update, e.g. \'harness\', \'url\'',
15+
type: 'string'
1816
})
1917
.options({
2018
nodedir: {
@@ -34,18 +32,28 @@ async function main(argv) {
3432
const request = new Request(credentials);
3533

3634
const updaters = [];
35+
36+
const statusFolder = path.join(nodedir, 'test', 'wpt', 'status');
37+
let supported = [];
38+
if (fs.existsSync(statusFolder)) {
39+
const jsons = fs.readdirSync(statusFolder);
40+
supported = jsons.map(item => item.replace('.json', ''));
41+
} else {
42+
cli.warn(`Please create the status JSON files in ${statusFolder}`);
43+
}
44+
3745
if (name === 'all') {
3846
updaters.push(new HarnessUpdater(cli, request, nodedir));
39-
for (const item of SUPPORTED_TESTS) {
47+
for (const item of supported) {
4048
updaters.push(new WPTUpdater(item, cli, request, nodedir));
4149
}
42-
} else if (SUPPORTED_TESTS.includes(name)) {
43-
updaters.push(new WPTUpdater(name, cli, request, nodedir));
4450
} else if (name === 'harness') {
4551
updaters.push(new HarnessUpdater(cli, request, nodedir));
4652
} else {
47-
yargs.showHelp();
48-
return;
53+
if (!supported.includes(name)) {
54+
cli.warn(`Please create ${name}.json in ${statusFolder}`);
55+
}
56+
updaters.push(new WPTUpdater(name, cli, request, nodedir));
4957
}
5058

5159
for (const updater of updaters) {

lib/wpt/harness.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)