From 3861f01f9770dc6f6118cbaedd3113638428428a Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Wed, 3 Jul 2019 16:49:16 -0700 Subject: [PATCH] make .record() take a TestSpecID --- src/framework/logger.ts | 8 +++++--- src/runtime/cmdline.ts | 4 +--- src/runtime/standalone.ts | 2 +- src/runtime/wpt.ts | 2 +- src/suites/unittests/loading.spec.ts | 8 ++++---- src/suites/unittests/logger.spec.ts | 12 ++++++------ src/suites/unittests/test_group_test.ts | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/framework/logger.ts b/src/framework/logger.ts index 76a403015596..b4e8a9634079 100644 --- a/src/framework/logger.ts +++ b/src/framework/logger.ts @@ -1,10 +1,12 @@ import { ParamsSpec } from './params/index.js'; import { getStackTrace, now } from './util.js'; import { version } from './version.js'; +import { TestSpecID } from './id.js'; +import { makeQueryString } from './url_query.js'; type Status = 'running' | 'pass' | 'warn' | 'fail'; interface TestLiveResult { - path: string; + spec: string; cases: TestCaseLiveResult[]; } @@ -21,9 +23,9 @@ export class Logger { constructor() {} - record(path: string): [GroupRecorder, TestLiveResult] { + record(spec: TestSpecID): [GroupRecorder, TestLiveResult] { const cases: TestCaseLiveResult[] = []; - const result: TestLiveResult = { path, cases }; + const result: TestLiveResult = { spec: makeQueryString(spec), cases }; this.results.push(result); return [new GroupRecorder(result), result]; } diff --git a/src/runtime/cmdline.ts b/src/runtime/cmdline.ts index 835c21df4146..0724dacebd10 100644 --- a/src/runtime/cmdline.ts +++ b/src/runtime/cmdline.ts @@ -58,7 +58,7 @@ for (const a of process.argv.slice(2)) { continue; } - const [rec] = log.record(qr.id.path); + const [rec] = log.record(qr.id); for (const t of qr.spec.g.iterate(rec)) { running.push( (async () => { @@ -89,7 +89,6 @@ for (const a of process.argv.slice(2)) { console.log(''); console.log('** Warnings **'); for (const [id, r] of warned) { - // TODO: actually print query here console.log(makeQueryString(id), r); } } @@ -97,7 +96,6 @@ for (const a of process.argv.slice(2)) { console.log(''); console.log('** Failures **'); for (const [id, r] of failed) { - // TODO: actually print query here console.log(makeQueryString(id), r); } } diff --git a/src/runtime/standalone.ts b/src/runtime/standalone.ts index fe241381c0c4..cd757fd21d74 100644 --- a/src/runtime/standalone.ts +++ b/src/runtime/standalone.ts @@ -120,7 +120,7 @@ function mkCase(testcasesVis: HTMLElement, query: string, t: RunCase) { continue; } - const [tRec] = log.record(qr.id.path); + const [tRec] = log.record(qr.id); for (const t of qr.spec.g.iterate(tRec)) { const query = makeQueryString(qr.id, t.id); const runCase = mkCase(testcasesVis, query, t); diff --git a/src/runtime/wpt.ts b/src/runtime/wpt.ts index 6097153dcee2..5c9fb9652d84 100644 --- a/src/runtime/wpt.ts +++ b/src/runtime/wpt.ts @@ -25,7 +25,7 @@ declare function async_test(f: (this: WptTestObject) => Promise, name: str continue; } - const [rec] = log.record(qr.id.path); + const [rec] = log.record(qr.id); // TODO: don't run all tests all at once for (const t of qr.spec.g.iterate(rec)) { const run = t.run(); diff --git a/src/suites/unittests/loading.spec.ts b/src/suites/unittests/loading.spec.ts index 31ac5b79c6b1..35169a173f72 100644 --- a/src/suites/unittests/loading.spec.ts +++ b/src/suites/unittests/loading.spec.ts @@ -97,7 +97,7 @@ class LoadingTest extends DefaultFixture { } async singleGroup(query: string): Promise { - const [rec] = new Logger().record(''); + const [rec] = new Logger().record({ suite: '', path: '' }); const a = await this.load([query]); if (a.length !== 1) { throw new Error('more than one group'); @@ -142,7 +142,7 @@ g.test('whole group', async t => { if (foo.spec.g === undefined) { throw new Error('foo group'); } - const [rec] = new Logger().record(''); + const [rec] = new Logger().record({ suite: '', path: '' }); t.expect(Array.from(foo.spec.g.iterate(rec)).length === 3); } }); @@ -188,7 +188,7 @@ g.test('end2end', async t => { t.expect(l[0].spec.g.iterate instanceof Function); const log = new Logger(); - const [rec, res] = log.record(l[0].id.path); + const [rec, res] = log.record(l[0].id); const rcs = Array.from(l[0].spec.g.iterate(rec)); if (rcs.length !== 2) { throw new Error('iterate length'); @@ -201,7 +201,7 @@ g.test('end2end', async t => { t.expect(paramsEquals(rcs[1].id.params, {})); t.expect(log.results[0] === res); - t.expect(res.path === 'foof'); + t.expect(res.spec === 'suite2:foof:'); t.expect(res.cases.length === 0); { diff --git a/src/suites/unittests/logger.spec.ts b/src/suites/unittests/logger.spec.ts index a62595a49a2f..850b3f2bcbfa 100644 --- a/src/suites/unittests/logger.spec.ts +++ b/src/suites/unittests/logger.spec.ts @@ -12,12 +12,12 @@ export const g = new TestGroup(DefaultFixture); g.test('construct', t => { const mylog = new Logger(); - const [testrec, testres] = mylog.record('foo/bar'); + const [testrec, testres] = mylog.record({ suite: 'a', path: 'foo/bar' }); const [, res1] = testrec.record('baz', null); const params2 = {}; const [, res2] = testrec.record('qux', params2); - t.expect(testres.path === 'foo/bar'); + t.expect(testres.spec === 'a:foo/bar:'); t.expect(testres.cases.length === 2); t.expect(testres.cases[0] === res1); t.expect(testres.cases[1] === res2); @@ -35,7 +35,7 @@ g.test('construct', t => { g.test('empty', t => { const mylog = new Logger(); - const [testrec] = mylog.record(''); + const [testrec] = mylog.record({ suite: '', path: '' }); const [rec, res] = testrec.record('baz', null); rec.start(); @@ -47,7 +47,7 @@ g.test('empty', t => { g.test('pass', t => { const mylog = new Logger(); - const [testrec] = mylog.record(''); + const [testrec] = mylog.record({ suite: '', path: '' }); const [rec, res] = testrec.record('baz', null); rec.start(); @@ -60,7 +60,7 @@ g.test('pass', t => { g.test('warn', t => { const mylog = new Logger(); - const [testrec] = mylog.record(''); + const [testrec] = mylog.record({ suite: '', path: '' }); const [rec, res] = testrec.record('baz', null); rec.start(); @@ -73,7 +73,7 @@ g.test('warn', t => { g.test('fail', t => { const mylog = new Logger(); - const [testrec] = mylog.record(''); + const [testrec] = mylog.record({ suite: '', path: '' }); const [rec, res] = testrec.record('baz', null); rec.start(); diff --git a/src/suites/unittests/test_group_test.ts b/src/suites/unittests/test_group_test.ts index ace050d7530c..cefa9d397693 100644 --- a/src/suites/unittests/test_group_test.ts +++ b/src/suites/unittests/test_group_test.ts @@ -4,13 +4,13 @@ import { TestCaseID } from '../../framework/id.js'; export class TestGroupTest extends DefaultFixture { async run(g: TestGroup): Promise { - const [rec] = new Logger().record(''); + const [rec] = new Logger().record({ suite: '', path: '' }); await Promise.all(Array.from(g.iterate(rec)).map(test => test.run())); } enumerate(g: TestGroup): TestCaseID[] { const cases = []; - const [rec] = new Logger().record(''); + const [rec] = new Logger().record({ suite: '', path: '' }); for (const test of g.iterate(rec)) { cases.push(test.id); }