summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/common/tools/validate.ts
blob: 47aa9782a88b42f590b59805ce4897e64bdeba6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as process from 'process';

import { crawl } from './crawl.js';

function usage(rc: number): never {
  console.error(`Usage: tools/validate [options] [SUITE_DIRS...]

For each suite in SUITE_DIRS, validate some properties about the file:
- It has a .description and .g
- That each test:
  - Has a test function (or is marked unimplemented)
  - Has no duplicate cases
  - Configures batching correctly, if used
- That each case query is not too long

Example:
  tools/validate src/unittests src/webgpu

Options:
  --help                     Print this message and exit.
  --print-metadata-warnings  Print non-fatal warnings about listing_meta.json files.
`);
  process.exit(rc);
}

const args = process.argv.slice(2);
if (args.length < 1) {
  usage(0);
}
if (args.indexOf('--help') !== -1) {
  usage(0);
}

let printMetadataWarnings = false;
const suiteDirs = [];
for (const arg of args) {
  if (arg === '--print-metadata-warnings') {
    printMetadataWarnings = true;
  } else {
    suiteDirs.push(arg);
  }
}

if (suiteDirs.length === 0) {
  usage(0);
}

for (const suiteDir of suiteDirs) {
  void crawl(suiteDir, {
    validate: true,
    printMetadataWarnings,
  });
}