mirror-webgpu-cts/Gruntfile.js
Kai Ninomiya 9cbb800a96
Make test cases hierarchical, and refactor/cleanup a lot in the process (#181)
* update tests, approximately

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* unittests:loading:* now passes

* passes 63 unittests, but not all are running...

* typechecks!!

* 58 unittests passing

* reenable getStackTrace tests

* wip

* finally all tests and checks pass!

* fixups

* wip

* replace all spaces with underscores in test names

* wip

* wip

* wip

* Dissolve TestLoader (now just use DefaultTestFileLoader)

* tighten ParamSpec type

* rename ParamSpec -> CaseParams

* make kParamSeparator ";", now standalone runner is working!

* add separate icon for leaf run buttons

* file renames

* remove user-select:all (not really needed anymore, triple click works fine now)

* cleanup some tests, add tests for test queries

* split interface for defining and running TestGroups

* more cleanup, fix URL encoding stuff, and standalone HTML

* fix readmes for parents of query

* clean up unused ReadmeFile interface

* dissolve id.ts

* test_suite_listing.ts

* split params_utils into param_utils + stringify_params

* rename encodeURLSelectively again

* add query.isMulti{File,Test,Case}

* fix gen_wpt_cts_html (at least for the simple mode; advanced mode probably still broken

* better run-one icon

* standalone: always make the url bar show the complete url

* revert tasks.json

* fix number out of bounds

* don't drop worker results, report input string on all query parse errors

* update docs/terms.md

* revisions

* more revisions

* make comparePublicParamsPaths order-agnostic (now allows queries against params out of order, but tree will not reorder itself accordingly)

* revise compareQueries, part 1

* revise compareQueries, part 2: compareOneLevel

* remove incorrect comment

* undo fast-glob dependency

* address Austin's comments

* address comments

* pass debug flag into test worker

* typo fixes
2020-05-18 15:33:41 -07:00

205 lines
5.6 KiB
JavaScript

module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
constants: ['src/constants.ts', 'src/common/constants.ts'],
out: ['out/', 'out-wpt'],
},
run: {
'generate-version': {
cmd: 'node',
args: ['tools/gen_version'],
},
'generate-listings': {
cmd: 'node',
args: ['tools/gen_listings', 'webgpu', 'unittests'],
},
'generate-wpt-cts-html': {
cmd: 'node',
args: ['tools/gen_wpt_cts_html', 'out-wpt/cts.html', 'src/common/templates/cts.html'],
},
test: {
cmd: 'node',
args: ['tools/run', 'unittests:*'],
},
'build-out': {
cmd: 'node',
args: [
'node_modules/@babel/cli/bin/babel',
'--source-maps=true',
'--extensions=.ts',
'--out-dir=out/',
'src/',
],
},
lint: {
cmd: 'node',
args: ['node_modules/eslint/bin/eslint', 'src/**/*.ts'],
},
fix: {
cmd: 'node',
args: ['node_modules/eslint/bin/eslint', 'src/**/*.ts', '--fix'],
},
},
watch: {
src: {
files: ['src/**/*'],
tasks: ['run:build-out', 'run:lint'],
options: {
spawn: false,
}
}
},
copy: {
'webgpu-constants': {
files: [
{
expand: true,
cwd: 'node_modules/@webgpu/types/src',
src: 'constants.ts',
dest: 'src/common/',
},
],
},
'out-wpt': {
files: [
{ expand: true, cwd: '.', src: 'LICENSE.txt', dest: 'out-wpt/' },
{ expand: true, cwd: 'out', src: 'common/constants.js', dest: 'out-wpt/' },
{ expand: true, cwd: 'out', src: 'common/framework/**/*.js', dest: 'out-wpt/' },
{ expand: true, cwd: 'out', src: 'common/runtime/wpt.js', dest: 'out-wpt/' },
{ expand: true, cwd: 'out', src: 'common/runtime/helper/**/*.js', dest: 'out-wpt/' },
{ expand: true, cwd: 'out', src: 'webgpu/**/*.js', dest: 'out-wpt/' },
{ expand: true, cwd: 'src', src: 'webgpu/**/*.html', dest: 'out-wpt/' },
],
},
},
'http-server': {
'.': {
root: '.',
port: 8080,
host: '127.0.0.1',
cache: -1,
},
'background': {
root: '.',
port: 8080,
host: '127.0.0.1',
cache: -1,
runInBackground: true,
logFn: function (req, res, error) {
// Only log errors to not spam the console.
if (error) {
console.error(error);
}
},
},
},
ts: {
check: {
tsconfig: {
tsconfig: 'tsconfig.json',
passThrough: true,
},
},
},
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-http-server');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.event.on('watch', function (action, filepath) {
const buildArgs = grunt.config(['run', 'build-out', 'args']);
buildArgs[buildArgs.length - 1] = filepath;
grunt.config(['run', 'build-out', 'args'], buildArgs);
const lintArgs = grunt.config(['run', 'lint', 'args']);
lintArgs[lintArgs.length - 1] = filepath;
grunt.config(['run', 'lint', 'args'], lintArgs);
});
const helpMessageTasks = [];
function registerTaskAndAddToHelp(name, desc, deps) {
grunt.registerTask(name, deps);
addExistingTaskToHelp(name, desc);
}
function addExistingTaskToHelp(name, desc) {
helpMessageTasks.push({ name, desc });
}
grunt.registerTask('set-quiet-mode', () => {
grunt.log.write('Running other tasks');
require('quiet-grunt');
});
grunt.registerTask('prebuild', 'Pre-build tasks (clean and re-copy)', [
'clean',
'copy:webgpu-constants',
]);
grunt.registerTask('compile', 'Compile and generate (no checks, no WPT)', [
'run:build-out',
'run:generate-version',
'run:generate-listings',
]);
grunt.registerTask('generate-wpt', 'Generate out-wpt/', [
'copy:out-wpt',
'run:generate-wpt-cts-html',
]);
grunt.registerTask('compile-done-message', () => {
process.stderr.write('\nBuild completed! Running checks/tests');
});
registerTaskAndAddToHelp('pre', 'Run all presubmit checks: build+typecheck+test+lint', [
'set-quiet-mode',
'wpt',
'run:lint',
]);
registerTaskAndAddToHelp('test', 'Quick development build: build+typecheck+test', [
'set-quiet-mode',
'prebuild',
'compile',
'compile-done-message',
'ts:check',
'run:test',
]);
registerTaskAndAddToHelp('wpt', 'Build for WPT: build+typecheck+test+wpt', [
'set-quiet-mode',
'prebuild',
'compile',
'generate-wpt',
'compile-done-message',
'ts:check',
'run:test',
]);
registerTaskAndAddToHelp('check', 'Typecheck and lint', [
'set-quiet-mode',
'copy:webgpu-constants',
'ts:check',
'run:lint',
]);
registerTaskAndAddToHelp('dev', 'Start the dev server, and watch for changes', [
'http-server:background',
'watch',
]);
registerTaskAndAddToHelp('serve', 'Serve out/ on 127.0.0.1:8080', ['http-server:.']);
registerTaskAndAddToHelp('fix', 'Fix lint and formatting', ['run:fix']);
grunt.registerTask('default', '', () => {
console.error('\nAvailable tasks (see grunt --help for info):');
for (const { name, desc } of helpMessageTasks) {
console.error(`$ grunt ${name}`);
console.error(` ${desc}`);
}
});
};