Add test filter argument to wasm js test runner
Change-Id: I8e0c5d7b9049fb3c3248749db8dc8c616db293f0 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
This commit is contained in:
parent
ee23941c29
commit
a73f41d657
@ -1,6 +1,19 @@
|
|||||||
// Copyright (C) 2022 The Qt Company Ltd.
|
// Copyright (C) 2022 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||||
|
|
||||||
|
function parseQuery()
|
||||||
|
{
|
||||||
|
const trimmed = window.location.search.substring(1);
|
||||||
|
return new Map(
|
||||||
|
trimmed.length === 0 ?
|
||||||
|
[] :
|
||||||
|
trimmed.split('&').map(paramNameAndValue =>
|
||||||
|
{
|
||||||
|
const [name, value] = paramNameAndValue.split('=');
|
||||||
|
return [decodeURIComponent(name), value ? decodeURIComponent(value) : ''];
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
export class assert
|
export class assert
|
||||||
{
|
{
|
||||||
static isFalse(value)
|
static isFalse(value)
|
||||||
@ -128,12 +141,15 @@ export class TestRunner
|
|||||||
|
|
||||||
async runAll()
|
async runAll()
|
||||||
{
|
{
|
||||||
|
const query = parseQuery();
|
||||||
|
const testFilter = query.has('testfilter') ? new RegExp(query.get('testfilter')) : undefined;
|
||||||
|
|
||||||
const SPECIAL_FUNCTIONS =
|
const SPECIAL_FUNCTIONS =
|
||||||
['beforeEach', 'afterEach', 'beforeAll', 'afterAll', 'constructor'];
|
['beforeEach', 'afterEach', 'beforeAll', 'afterAll', 'constructor'];
|
||||||
const prototype = Object.getPrototypeOf(this.#testClassInstance);
|
const prototype = Object.getPrototypeOf(this.#testClassInstance);
|
||||||
const testFunctions =
|
const testFunctions =
|
||||||
Object.getOwnPropertyNames(prototype).filter(
|
Object.getOwnPropertyNames(prototype).filter(
|
||||||
entry => SPECIAL_FUNCTIONS.indexOf(entry) === -1);
|
entry => SPECIAL_FUNCTIONS.indexOf(entry) === -1 && (!testFilter || entry.match(testFilter)));
|
||||||
|
|
||||||
if (prototype.beforeAll)
|
if (prototype.beforeAll)
|
||||||
await prototype.beforeAll.apply(this.#testClassInstance);
|
await prototype.beforeAll.apply(this.#testClassInstance);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user