Update web-platform-tests to revision 0abb411331f86f472103183c7ec1136ea21a7e1b

This commit is contained in:
WPT Sync Bot 2019-10-31 10:27:09 +00:00
parent d671010e46
commit 5a5512f805
139 changed files with 2559 additions and 1445 deletions

View file

@ -3,5 +3,5 @@
**/
// It may be OK to add more allowed characters here.
export const allowedTestNameCharacters = 'a-zA-Z0-9/_ ';
export const allowedTestNameCharacters = 'a-zA-Z0-9/_';
//# sourceMappingURL=allowed_characters.js.map

View file

@ -3,7 +3,7 @@
**/
export function attemptGarbageCollection() {
const w = window;
const w = self;
if (w.GCController) {
w.GCController.collect();

View file

@ -13,6 +13,8 @@ export class Fixture {
_defineProperty(this, "rec", void 0);
_defineProperty(this, "eventualExpectations", []);
_defineProperty(this, "numOutstandingAsyncExpectations", 0);
this.rec = rec;
@ -35,6 +37,8 @@ export class Fixture {
if (this.numOutstandingAsyncExpectations !== 0) {
throw new Error('there were outstanding asynchronous expectations (e.g. shouldReject) at the end of the test');
}
await Promise.all(this.eventualExpectations);
}
warn(msg) {
@ -45,18 +49,19 @@ export class Fixture {
this.rec.fail(msg);
}
ok(msg) {
const m = msg ? ': ' + msg : '';
this.log('OK' + m);
}
async asyncExpectation(fn) {
async immediateAsyncExpectation(fn) {
this.numOutstandingAsyncExpectations++;
const ret = await fn();
this.numOutstandingAsyncExpectations--;
return ret;
}
eventualAsyncExpectation(fn) {
const promise = fn();
this.eventualExpectations.push(promise);
return promise;
}
expectErrorValue(expectedName, ex, m) {
if (!(ex instanceof Error)) {
this.fail('THREW NON-ERROR');
@ -68,12 +73,12 @@ export class Fixture {
if (actualName !== expectedName) {
this.fail(`THREW ${actualName} INSTEAD OF ${expectedName}${m}`);
} else {
this.ok(`threw ${actualName}${m}`);
this.debug(`OK: threw ${actualName}${m}`);
}
}
async shouldReject(expectedName, p, msg) {
this.asyncExpectation(async () => {
shouldReject(expectedName, p, msg) {
this.eventualAsyncExpectation(async () => {
const m = msg ? ': ' + msg : '';
try {
@ -98,7 +103,8 @@ export class Fixture {
expect(cond, msg) {
if (cond) {
this.ok(msg);
const m = msg ? ': ' + msg : '';
this.debug('expect OK' + m);
} else {
this.rec.fail(msg);
}

View file

@ -38,9 +38,7 @@ export class TestLoader {
async loadTestsFromCmdLine(filters) {
// In actual URL queries (?q=...), + represents a space. But decodeURIComponent doesn't do this,
// so do it manually. (+ is used over %20 for readability.) (See also encodeSelectively.)
return this.loadTests(filters.map(f => decodeURIComponent(f.replace(/\+/g, '%20'))));
return this.loadTests(filters);
}
async loadTests(filters) {

View file

@ -5,6 +5,7 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { makeQueryString } from './url_query.js';
import { extractPublicParams } from './url_query.js';
import { getStackTrace, now } from './util/index.js';
import { version } from './version.js';
export class Logger {
@ -39,7 +40,7 @@ export class TestSpecRecorder {
record(test, params) {
const result = {
test,
params,
params: params ? extractPublicParams(params) : null,
status: 'running',
timems: -1
};

View file

@ -6,7 +6,7 @@ let _Symbol$iterator;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
export function pcombine(params) {
export function pcombine(...params) {
return new PCombine(params);
}

View file

@ -2,10 +2,11 @@
* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
**/
import { objectEquals } from '../util/index.js';
export * from './combine.js';
export * from './exclude.js';
export * from './filter.js';
export * from './options.js';
export * from './exclude.js';
export function paramsEquals(x, y) {
if (x === y) {
return true;
@ -16,17 +17,17 @@ export function paramsEquals(x, y) {
}
for (const xk of Object.keys(x)) {
if (!y.hasOwnProperty(xk)) {
if (x[xk] !== undefined && !y.hasOwnProperty(xk)) {
return false;
}
if (x[xk] !== y[xk]) {
if (!objectEquals(x[xk], y[xk])) {
return false;
}
}
for (const yk of Object.keys(y)) {
if (!x.hasOwnProperty(yk)) {
if (y[yk] !== undefined && !x.hasOwnProperty(yk)) {
return false;
}
}

View file

@ -6,6 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
import { allowedTestNameCharacters } from './allowed_characters.js';
import { paramsEquals } from './params/index.js';
import { checkPublicParamType, extractPublicParams } from './url_query.js';
const validNames = new RegExp('^[' + allowedTestNameCharacters + ']+$');
export class TestGroup {
constructor(fixture) {
@ -44,6 +45,12 @@ export class TestGroup {
test(name, fn) {
// Replace spaces with underscores for readability.
if (name.indexOf('_') !== -1) {
throw new Error('Invalid test name ${name}: contains underscore (use space)');
}
name = name.replace(/ /g, '_');
this.checkName(name);
const test = new Test(name, this.fixture, fn);
this.tests.push(test);
@ -76,11 +83,18 @@ class Test {
const seen = []; // This is n^2.
for (const spec of cases) {
if (seen.some(x => paramsEquals(x, spec))) {
const publicParams = extractPublicParams(spec); // Check type of public params: can only be (currently):
// number, string, boolean, undefined, number[]
for (const v of Object.values(publicParams)) {
checkPublicParamType(v);
}
if (seen.some(x => paramsEquals(x, publicParams))) {
throw new Error('Duplicate test case params');
}
seen.push(spec);
seen.push(publicParams);
}
this.cases = cases;
@ -88,27 +102,30 @@ class Test {
*iterate(rec) {
for (const params of this.cases || [null]) {
yield new RunCaseSpecific(rec, {
test: this.name,
params
}, this.fixture, this.fn);
yield new RunCaseSpecific(rec, this.name, params, this.fixture, this.fn);
}
}
}
class RunCaseSpecific {
constructor(recorder, id, fixture, fn) {
constructor(recorder, test, params, fixture, fn) {
_defineProperty(this, "id", void 0);
_defineProperty(this, "params", void 0);
_defineProperty(this, "recorder", void 0);
_defineProperty(this, "fixture", void 0);
_defineProperty(this, "fn", void 0);
this.id = {
test,
params: params ? extractPublicParams(params) : null
};
this.params = params;
this.recorder = recorder;
this.id = id;
this.fixture = fixture;
this.fn = fn;
}
@ -118,17 +135,32 @@ class RunCaseSpecific {
rec.start(debug);
try {
const inst = new this.fixture(rec, this.id.params || {});
const inst = new this.fixture(rec, this.params || {});
await inst.init();
await this.fn(inst);
try {
await this.fn(inst);
} catch (ex) {
// There was an exception from the test itself.
rec.threw(ex);
} // Runs as long as constructor and init succeeded, even if the test rejected.
await inst.finalize();
} catch (e) {
rec.threw(e);
} catch (ex) {
// There was an exception from constructor, init, or finalize.
// (An error from finalize may have been an eventualAsyncExpectation failure.)
rec.threw(ex);
}
rec.finish();
return res;
}
injectResult(result) {
const [, res] = this.recorder.record(this.id.test, this.id.params);
Object.assign(res, result);
}
}
//# sourceMappingURL=test_group.js.map

View file

@ -0,0 +1,90 @@
/**
* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
**/
// e.g. iteratePath('a/b/c/d', ':') yields ['a/', 'a/b/', 'a/b/c/', 'a/b/c/d:']
function* iteratePath(path, terminator) {
const parts = path.split('/');
if (parts.length > 1) {
let partial = parts[0] + '/';
yield partial;
for (let i = 1; i < parts.length - 1; ++i) {
partial += parts[i] + '/';
yield partial;
} // Path ends in '/' (so is a README).
if (parts[parts.length - 1] === '') {
return;
}
}
yield path + terminator;
}
export function treeFromFilterResults(log, listing) {
function insertOrNew(n, k) {
const children = n.children;
if (children.has(k)) {
return children.get(k);
}
const v = {
children: new Map()
};
children.set(k, v);
return v;
}
const tree = {
children: new Map()
};
for (const f of listing) {
const files = insertOrNew(tree, f.id.suite + ':');
if (f.id.path === '') {
// This is a suite README.
files.description = f.spec.description;
continue;
}
let tests = files;
for (const path of iteratePath(f.id.path, ':')) {
tests = insertOrNew(tests, f.id.suite + ':' + path);
}
if (f.spec.description) {
// This is a directory README or spec file.
tests.description = f.spec.description.trim();
}
if (!('g' in f.spec)) {
// This is a directory README.
continue;
}
const [tRec] = log.record(f.id);
const fId = f.id.suite + ':' + f.id.path;
for (const t of f.spec.g.iterate(tRec)) {
let cases = tests;
for (const path of iteratePath(t.id.test, '~')) {
cases = insertOrNew(cases, fId + ':' + path);
}
const p = t.id.params ? JSON.stringify(t.id.params) : '';
cases.children.set(fId + ':' + t.id.test + '=' + p, {
runCase: t
});
}
}
return tree;
}
//# sourceMappingURL=tree.js.map

View file

@ -4,8 +4,6 @@
export function encodeSelectively(s) {
let ret = encodeURIComponent(s);
ret = ret.replace(/%20/g, '+'); // Encode space with + (equivalent but more readable)
ret = ret.replace(/%22/g, '"');
ret = ret.replace(/%2C/g, ',');
ret = ret.replace(/%2F/g, '/');
@ -17,6 +15,34 @@ export function encodeSelectively(s) {
ret = ret.replace(/%7D/g, '}');
return ret;
}
export function extractPublicParams(params) {
const publicParams = {};
for (const k of Object.keys(params)) {
if (!k.startsWith('_')) {
publicParams[k] = params[k];
}
}
return publicParams;
}
export function checkPublicParamType(v) {
if (typeof v === 'number' || typeof v === 'string' || typeof v === 'boolean' || v === undefined) {
return;
}
if (v instanceof Array) {
for (const x of v) {
if (typeof x !== 'number') {
break;
}
}
return;
}
throw new Error('Invalid type for test case params ' + v);
}
export function makeQueryString(spec, testcase) {
let s = spec.suite + ':';
s += spec.path + ':';
@ -25,7 +51,7 @@ export function makeQueryString(spec, testcase) {
s += testcase.test + '=';
if (testcase.params) {
s += JSON.stringify(testcase.params);
s += JSON.stringify(extractPublicParams(testcase.params));
}
}

View file

@ -1,3 +1,3 @@
// AUTO-GENERATED - DO NOT EDIT. See tools/gen_version.
export const version = 'afbbce5a6a4e9093d01ed454fdc7f257f29d2977';
export const version = 'ba0a130a078256d45504069de88f0d91d4631578';