Skip to content

Commit

Permalink
Fix build on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Aug 3, 2019
1 parent 0206834 commit cb7e03d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
28 changes: 18 additions & 10 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,40 @@ module.exports = function(grunt) {

run: {
'generate-listings': {
cmd: 'tools/gen',
args: ['cts', 'unittests'],
cmd: 'node',
args: ['tools/gen', 'cts', 'unittests'],
},
'generate-version': {
cmd: 'tools/gen_version',
cmd: 'node',
args: ['tools/gen_version'],
},
test: {
cmd: 'tools/run',
args: ['unittests:'],
cmd: 'node',
args: ['tools/run', 'unittests:'],
},
'build-out': {
cmd: 'node_modules/.bin/babel',
args: ['--source-maps', 'true', '--extensions', '.ts', '--out-dir', 'out/', 'src/'],
cmd: 'node',
args: ['node_modules/@babel/cli/bin/babel', '--source-maps', 'true', '--extensions', '.ts', '--out-dir', 'out/', 'src/'],
},
'build-shaderc': {
cmd: 'node_modules/.bin/babel',
cmd: 'node',
args: [
'node_modules/@babel/cli/bin/babel',
'--plugins',
'babel-plugin-transform-commonjs-es2015-modules',
'node_modules/@webgpu/shaderc/dist/index.js',
'-o',
'out/shaderc.js',
],
},
'gts-check': { cmd: 'node_modules/.bin/gts', args: ['check'] },
'gts-fix': { cmd: 'node_modules/.bin/gts', args: ['fix'] },
'gts-check': {
cmd: 'node',
args: ['node_modules/gts/build/src/cli', 'check'],
},
'gts-fix': {
cmd: 'node',
args: ['node_modules/gts/build/src/cli', 'fix'],
},
},

copy: {
Expand Down
17 changes: 9 additions & 8 deletions src/framework/util/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ export function getStackTrace(e: Error): string {

const stack = [];
let found = false;
const suitesRegex = /[\/\\]suites[\/\\]/;
for (let i = 0; i < parts.length; ++i) {
const part = parts[i].trim();
const isSuites = part.indexOf('/suites/') !== -1;
const isSuites = suitesRegex.test(part);
if (found && !isSuites) {
break;
}
Expand All @@ -28,21 +29,21 @@ export function getStackTrace(e: Error): string {
// *** Examples ***
//
// Node fail()
// x Error:
// x at CaseRecorder.fail (/Users/kainino/src/cts-experiment/src/framework/logger.ts:99:30)
// > Error:
// > at CaseRecorder.fail (/Users/kainino/src/cts-experiment/src/framework/logger.ts:99:30)
// > at RunCaseSpecific.exports.g.test.t [as fn] (/Users/kainino/src/cts-experiment/src/suites/unittests/logger.spec.ts:80:7)
// x at RunCaseSpecific.run (/Users/kainino/src/cts-experiment/src/framework/test_group.ts:121:18)
// x at processTicksAndRejections (internal/process/task_queues.js:86:5)
//
// Node throw
// x Error: hello
// > Error: hello
// > at RunCaseSpecific.g.test.t [as fn] (/Users/kainino/src/cts-experiment/src/suites/unittests/test_group.spec.ts:51:11)
// x at RunCaseSpecific.run (/Users/kainino/src/cts-experiment/src/framework/test_group.ts:121:18)
// x at processTicksAndRejections (internal/process/task_queues.js:86:5)
//
// Firefox fail()
// x fail@http://localhost:8080/out/framework/logger.js:104:30
// x expect@http://localhost:8080/out/framework/default_fixture.js:59:16
// > fail@http://localhost:8080/out/framework/logger.js:104:30
// > expect@http://localhost:8080/out/framework/default_fixture.js:59:16
// > @http://localhost:8080/out/suites/unittests/util.spec.js:35:5
// x run@http://localhost:8080/out/framework/test_group.js:119:18
//
Expand All @@ -51,8 +52,8 @@ export function getStackTrace(e: Error): string {
// x run@http://localhost:8080/out/framework/test_group.js:119:18
//
// Safari fail()
// x fail@http://localhost:8080/out/framework/logger.js:104:39
// x expect@http://localhost:8080/out/framework/default_fixture.js:59:20
// > fail@http://localhost:8080/out/framework/logger.js:104:39
// > expect@http://localhost:8080/out/framework/default_fixture.js:59:20
// > http://localhost:8080/out/suites/unittests/util.spec.js:35:11
// x http://localhost:8080/out/framework/test_group.js:119:20
// x asyncFunctionResume@[native code]
Expand Down
2 changes: 1 addition & 1 deletion src/suites/unittests/test_group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ g.test('stack', async t0 => {

const res = await t0.run(g);

const search = /unittests\/test_group\.spec\.[tj]s|suites\/unittests\/unit_test\.[tj]s/;
const search = /unittests[\/\\]test_group\.spec\.[tj]s|suites[\/\\]unittests[\/\\]unit_test\.[tj]s/;
for (const { logs } of res.cases) {
if (logs === undefined) {
throw new Error('expected logs');
Expand Down
4 changes: 2 additions & 2 deletions src/tools/crawl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import { TestSuiteListingEntry } from '../framework/listing.js';
const specSuffix = '.spec.ts';

export async function crawl(suite: string): Promise<TestSuiteListingEntry[]> {
const specDir = path.normalize(`src/suites/${suite}`);
const specDir = 'src/suites/' + suite;
if (!fs.existsSync(specDir)) {
console.error(`Could not find ${specDir}`);
process.exit(1);
}

const specFiles = await fg(specDir + '/**/{README.txt,*' + specSuffix + '}', { onlyFiles: true });
const specFiles = await fg(specDir + '/**/*' + specSuffix, { onlyFiles: true });

const groups: TestSuiteListingEntry[] = [];
for (const file of specFiles) {
Expand Down

0 comments on commit cb7e03d

Please sign in to comment.