Skip to content

Commit

Permalink
Merge branch 'main' into garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x authored Nov 2, 2023
2 parents fe03729 + a644dd0 commit 5df3305
Show file tree
Hide file tree
Showing 25 changed files with 313 additions and 250 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.1
- uses: actions/checkout@v3
with:
persist-credentials: false
- run: |
git fetch origin ${{ github.event.pull_request.head.sha }}
git checkout ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v2-beta
- uses: actions/setup-node@v3
with:
node-version: "16.x"
- run: npm ci
- run: npm test
- run: |
mkdir deploy-build/
cp -r README.md src standalone out docs deploy-build/
- uses: actions/upload-artifact@v2
with:
name: pr-artifact
path: deploy-build/
- name: copy out-wpt to wpt tree
run: |
git clone --depth 2 https://github.com/web-platform-tests/wpt.git
rsync -av out-wpt/ wpt/webgpu
- name: test wpt lint
run: ./wpt lint
working-directory: ./wpt
80 changes: 0 additions & 80 deletions .github/workflows/workflow.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/wpt.yml

This file was deleted.

31 changes: 25 additions & 6 deletions src/common/framework/fixture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestCaseRecorder } from '../internal/logging/test_case_recorder.js';
import { JSONWithUndefined } from '../internal/params_utils.js';
import { assert, unreachable } from '../util/util.js';
import { assert, ExceptionCheckOptions, unreachable } from '../util/util.js';

export class SkipTestCase extends Error {}
export class UnexpectedPassError extends Error {}
Expand Down Expand Up @@ -237,16 +237,26 @@ export class Fixture<S extends SubcaseBatchState = SubcaseBatchState> {
}

/** Expect that the provided promise rejects, with the provided exception name. */
shouldReject(expectedName: string, p: Promise<unknown>, msg?: string): void {
shouldReject(
expectedName: string,
p: Promise<unknown>,
{ allowMissingStack = false, message }: ExceptionCheckOptions = {}
): void {
this.eventualAsyncExpectation(async niceStack => {
const m = msg ? ': ' + msg : '';
const m = message ? ': ' + message : '';
try {
await p;
niceStack.message = 'DID NOT REJECT' + m;
this.rec.expectationFailed(niceStack);
} catch (ex) {
niceStack.message = 'rejected as expected' + m;
this.expectErrorValue(expectedName, ex, niceStack);
if (!allowMissingStack) {
if (!(ex instanceof Error && typeof ex.stack === 'string')) {
const exMessage = ex instanceof Error ? ex.message : '?';
niceStack.message = `rejected as expected, but missing stack (${exMessage})${m}`;
this.rec.expectationFailed(niceStack);
}
}
}
});
}
Expand All @@ -257,8 +267,12 @@ export class Fixture<S extends SubcaseBatchState = SubcaseBatchState> {
*
* MAINTENANCE_TODO: Change to `string | false` so the exception name is always checked.
*/
shouldThrow(expectedError: string | boolean, fn: () => void, msg?: string): void {
const m = msg ? ': ' + msg : '';
shouldThrow(
expectedError: string | boolean,
fn: () => void,
{ allowMissingStack = false, message }: ExceptionCheckOptions = {}
) {
const m = message ? ': ' + message : '';
try {
fn();
if (expectedError === false) {
Expand All @@ -271,6 +285,11 @@ export class Fixture<S extends SubcaseBatchState = SubcaseBatchState> {
this.rec.expectationFailed(new Error('threw unexpectedly' + m));
} else {
this.expectErrorValue(expectedError, ex, new Error(m));
if (!allowMissingStack) {
if (!(ex instanceof Error && typeof ex.stack === 'string')) {
this.rec.expectationFailed(new Error('threw as expected, but missing stack' + m));
}
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/common/runtime/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,20 @@ function makeTreeNodeHeaderHTML(
.attr('alt', runtext)
.attr('title', runtext)
.on('click', async () => {
if (runDepth > 0) {
showInfo('tests are already running');
return;
}
showInfo('');
console.log(`Starting run for ${n.query}`);
// turn off all run buttons
$('#resultsVis').addClass('disable-run');
const startTime = performance.now();
await runSubtree();
const dt = performance.now() - startTime;
const dtMinutes = dt / 1000 / 60;
// turn on all run buttons
$('#resultsVis').removeClass('disable-run');
console.log(`Finished run: ${dt.toFixed(1)} ms = ${dtMinutes.toFixed(1)} min`);
})
.appendTo(header);
Expand Down
2 changes: 2 additions & 0 deletions src/common/tools/crawl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export async function crawl(suiteDir: string, validate: boolean): Promise<TestSu
assert(mod.description !== undefined, 'Test spec file missing description: ' + filename);
assert(mod.g !== undefined, 'Test spec file missing TestGroup definition: ' + filename);

mod.g.validate();

for (const { testPath } of mod.g.collectNonEmptyTests()) {
const testQuery = new TestQueryMultiCase(suite, pathSegments, testPath, {}).toString();
if (validateTimingsEntries) {
Expand Down
57 changes: 41 additions & 16 deletions src/common/tools/dev_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ import { makeListing } from './crawl.js';
// Make sure that makeListing doesn't cache imported spec files. See crawl().
process.env.STANDALONE_DEV_SERVER = '1';

function usage(rc: number): void {
console.error(`\
Usage:
tools/dev_server
tools/dev_server 0.0.0.0
npm start
npm start 0.0.0.0
By default, serves on localhost only. If the argument 0.0.0.0 is passed, serves on all interfaces.
`);
process.exit(rc);
}

const srcDir = path.resolve(__dirname, '../../');

// Import the project's babel.config.js. We'll use the same config for the runtime compiler.
Expand Down Expand Up @@ -110,7 +123,7 @@ app.use('/out-wpt', express.static(path.resolve(srcDir, '../out-wpt')));
app.use('/docs/tsdoc', express.static(path.resolve(srcDir, '../docs/tsdoc')));

// Serve a suite's listing.js file by crawling the filesystem for all tests.
app.get('/out/:suite/listing.js', async (req, res, next) => {
app.get('/out/:suite([a-zA-Z0-9_-]+)/listing.js', async (req, res, next) => {
const suite = req.params['suite'];

if (listingCache.has(suite)) {
Expand Down Expand Up @@ -162,28 +175,40 @@ app.get('/out/**/*.js', async (req, res, next) => {
}
});

const host = '0.0.0.0';
const port = 8080;
// Find an available port, starting at 8080.
portfinder.getPort({ host, port }, (err, port) => {
if (err) {
throw err;
// Serve everything else (not .js) as static, and directories as directory listings.
app.use('/out', serveIndex(path.resolve(srcDir, '../src')));
app.use('/out', express.static(path.resolve(srcDir, '../src')));

void (async () => {
let host = '127.0.0.1';
if (process.argv.length >= 3) {
if (process.argv.length !== 3) usage(1);
if (process.argv[2] === '0.0.0.0') {
host = '0.0.0.0';
} else {
usage(1);
}
}

console.log(`Finding an available port on ${host}...`);
const kPortFinderStart = 8080;
const port = await portfinder.getPortPromise({ host, port: kPortFinderStart });

watcher.on('ready', () => {
// Listen on the available port.
app.listen(port, host, () => {
console.log('Standalone test runner running at:');
for (const iface of Object.values(os.networkInterfaces())) {
for (const details of iface || []) {
if (details.family === 'IPv4') {
console.log(` http://${details.address}:${port}/standalone/`);
if (host === '0.0.0.0') {
for (const iface of Object.values(os.networkInterfaces())) {
for (const details of iface || []) {
if (details.family === 'IPv4') {
console.log(` http://${details.address}:${port}/standalone/`);
}
}
}
} else {
console.log(` http://${host}:${port}/standalone/`);
}
});
});
});

// Serve everything else (not .js) as static, and directories as directory listings.
app.use('/out', serveIndex(path.resolve(srcDir, '../src')));
app.use('/out', express.static(path.resolve(srcDir, '../src')));
})();
20 changes: 17 additions & 3 deletions src/common/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,29 @@ export function assertOK<T>(value: Error | T): T {
return value;
}

/** Options for assertReject, shouldReject, and friends. */
export type ExceptionCheckOptions = { allowMissingStack?: boolean; message?: string };

/**
* Resolves if the provided promise rejects; rejects if it does not.
*/
export async function assertReject(p: Promise<unknown>, msg?: string): Promise<void> {
export async function assertReject(
expectedName: string,
p: Promise<unknown>,
{ allowMissingStack = false, message }: ExceptionCheckOptions = {}
): Promise<void> {
try {
await p;
unreachable(msg);
unreachable(message);
} catch (ex) {
// Assertion OK
// Asserted as expected
if (!allowMissingStack) {
const m = message ? ` (${message})` : '';
assert(
ex instanceof Error && typeof ex.stack === 'string',
'threw as expected, but missing stack' + m
);
}
}
}

Expand Down
8 changes: 0 additions & 8 deletions src/unittests/floating_point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6437,14 +6437,6 @@ g.test('determinantInterval')
],
expected: 0,
},
{
input: [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
],
expected: 0,
},
{
input: [
[4, 1, -1],
Expand Down
5 changes: 4 additions & 1 deletion src/unittests/loaders_and_trees.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,10 @@ async function testIterateCollapsed(
subqueriesToExpand: expectations,
});
if (expectedResult === 'throws') {
t.shouldReject('Error', treePromise, 'loadTree should have thrown Error');
t.shouldReject('Error', treePromise, {
// Some errors here use StacklessError to print nicer command line outputs.
allowMissingStack: true,
});
return;
}
const tree = await treePromise;
Expand Down
Loading

0 comments on commit 5df3305

Please sign in to comment.