Skip to content

Commit

Permalink
Move the query manipulation to parseQuery (#3320)
Browse files Browse the repository at this point in the history
* Move the query manipulation to parseQuery
  • Loading branch information
greggman authored Jan 25, 2024
1 parent 138b023 commit 462fd8e
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 147 deletions.
43 changes: 40 additions & 3 deletions src/common/internal/query/parseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,49 @@ import {
import { kBigSeparator, kWildcard, kPathSeparator, kParamSeparator } from './separators.js';
import { validQueryPart } from './validQueryPart.js';

export function parseQuery(s: string): TestQuery {
/**
* converts foo/bar/src/webgpu/this/that/file.spec.ts to webgpu:this,that,file,*
*/
function convertPathToQuery(path: string) {
// removes .spec.ts and splits by directory separators.
const parts = path.substring(0, path.length - 8).split(/\/|\\/g);
// Gets parts only after the last `src`. Example: returns ['webgpu', 'foo', 'bar', 'test']
// for ['Users', 'me', 'src', 'cts', 'src', 'webgpu', 'foo', 'bar', 'test']
const partsAfterSrc = parts.slice(parts.lastIndexOf('src') + 1);
const suite = partsAfterSrc.shift();
return `${suite}:${partsAfterSrc.join(',')},*`;
}

/**
* If a query looks like a path (ends in .spec.ts and has directory separators)
* then convert try to convert it to a query.
*/
function convertPathLikeToQuery(queryOrPath: string) {
return queryOrPath.endsWith('.spec.ts') &&
(queryOrPath.includes('/') || queryOrPath.includes('\\'))
? convertPathToQuery(queryOrPath)
: queryOrPath;
}

/**
* Convert long suite names (the part before the first colon) to the
* shortest last word
* foo.bar.moo:test,subtest,foo -> moo:test,subtest,foo
*/
function shortenSuiteName(query: string) {
const parts = query.split(':');
// converts foo.bar.moo to moo
const suite = parts.shift()?.replace(/.*\.(\w+)$/, '$1');
return [suite, ...parts].join(':');
}

export function parseQuery(queryLike: string): TestQuery {
try {
return parseQueryImpl(s);
const query = shortenSuiteName(convertPathLikeToQuery(queryLike));
return parseQueryImpl(query);
} catch (ex) {
if (ex instanceof Error) {
ex.message += '\n on: ' + s;
ex.message += `\n on: ${queryLike}`;
}
throw ex;
}
Expand Down
41 changes: 1 addition & 40 deletions src/common/runtime/helper/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,42 +103,6 @@ function getOptionsInfoFromSearchString<Type extends CTSOptions>(
return optionValues as unknown as Type;
}

/**
* converts foo/bar/src/webgpu/this/that/file.spec.ts to webgpu:this,that,file,*
*/
function convertPathToQuery(path: string) {
// removes .spec.ts and splits by directory separators.
const parts = path.substring(0, path.length - 8).split(/\/|\\/g);
// Gets parts only after the last `src`. Example: returns ['webgpu', 'foo', 'bar', 'test']
// for ['Users', 'me', 'src', 'cts', 'src', 'webgpu', 'foo', 'bar', 'test']
const partsAfterSrc = parts.slice(parts.lastIndexOf('src') + 1);
const suite = partsAfterSrc.shift();
return `${suite}:${partsAfterSrc.join(',')},*`;
}

/**
* If a query looks like a path (ends in .spec.ts and has directory separators)
* then convert try to convert it to a query.
*/
function convertPathLikeToQuery(queryOrPath: string) {
return queryOrPath.endsWith('.spec.ts') &&
(queryOrPath.includes('/') || queryOrPath.includes('\\'))
? convertPathToQuery(queryOrPath)
: queryOrPath;
}

/**
* Convert long suite names (the part before the first colon) to the
* shortest last word
* foo.bar.moo:test/subtest/foo -> moo:test/subtest/foo
*/
function shortenSuiteName(query: string) {
const parts = query.split(':');
// converts foo.bar.moo to moo
const suite = parts.shift()?.replace(/.*\.(\w+)$/, '$1');
return [suite, ...parts].join(':');
}

/**
* Given a test query string in the form of `suite:foo,bar,moo&opt1=val1&opt2=val2
* returns the query and the options.
Expand All @@ -151,10 +115,7 @@ export function parseSearchParamLikeWithOptions<Type extends CTSOptions>(
options: Type;
} {
const searchString = query.includes('q=') || query.startsWith('?') ? query : `q=${query}`;
const queries = new URLSearchParams(searchString)
.getAll('q')
.map(convertPathLikeToQuery)
.map(shortenSuiteName);
const queries = new URLSearchParams(searchString).getAll('q');
const options = getOptionsInfoFromSearchString(optionsInfos, searchString);
return { queries, options };
}
Expand Down
208 changes: 104 additions & 104 deletions src/resources/cache/hashes.json
Original file line number Diff line number Diff line change
@@ -1,106 +1,106 @@
{
"webgpu/shader/execution/binary/af_addition.bin": "e2a6fa97",
"webgpu/shader/execution/binary/af_logical.bin": "f87033d7",
"webgpu/shader/execution/binary/af_division.bin": "b6608a1d",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "26880f55",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "2cabd6fc",
"webgpu/shader/execution/binary/af_multiplication.bin": "44267c8c",
"webgpu/shader/execution/binary/af_remainder.bin": "99e33c8c",
"webgpu/shader/execution/binary/af_subtraction.bin": "3bb5b279",
"webgpu/shader/execution/binary/f16_addition.bin": "8d3096b6",
"webgpu/shader/execution/binary/f16_logical.bin": "9777729",
"webgpu/shader/execution/binary/f16_division.bin": "9d58b04e",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "a0c77404",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "6bfe3a1f",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "354748aa",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "58dfb66c",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "f999f684",
"webgpu/shader/execution/binary/f16_multiplication.bin": "b3fae008",
"webgpu/shader/execution/binary/f16_remainder.bin": "2af28c4a",
"webgpu/shader/execution/binary/f16_subtraction.bin": "daf481ef",
"webgpu/shader/execution/binary/f32_addition.bin": "1275af67",
"webgpu/shader/execution/binary/f32_logical.bin": "b4a0d63e",
"webgpu/shader/execution/binary/f32_division.bin": "1d78692",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "90da9e9a",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "3a6e178a",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "3c91a515",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "bf5b1139",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "2b15a7",
"webgpu/shader/execution/binary/f32_multiplication.bin": "96662d61",
"webgpu/shader/execution/binary/f32_remainder.bin": "61feee9",
"webgpu/shader/execution/binary/f32_subtraction.bin": "39ba674",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "ece05bfe",
"webgpu/shader/execution/binary/i32_comparison.bin": "6f1a5f8a",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "fe793f15",
"webgpu/shader/execution/binary/u32_comparison.bin": "6f4cc9ce",
"webgpu/shader/execution/abs.bin": "a24702b4",
"webgpu/shader/execution/acos.bin": "6be8a261",
"webgpu/shader/execution/acosh.bin": "f0ee78c7",
"webgpu/shader/execution/asin.bin": "253f4af0",
"webgpu/shader/execution/asinh.bin": "3314584b",
"webgpu/shader/execution/atan.bin": "da8d08d7",
"webgpu/shader/execution/atan2.bin": "b954d4e1",
"webgpu/shader/execution/atanh.bin": "1b3f2d03",
"webgpu/shader/execution/bitcast.bin": "4e7c77c3",
"webgpu/shader/execution/ceil.bin": "ea0eceec",
"webgpu/shader/execution/clamp.bin": "c9cbd016",
"webgpu/shader/execution/cos.bin": "5a33f219",
"webgpu/shader/execution/cosh.bin": "eba59441",
"webgpu/shader/execution/cross.bin": "e1ca8519",
"webgpu/shader/execution/degrees.bin": "d4f9f7cc",
"webgpu/shader/execution/determinant.bin": "a1e37972",
"webgpu/shader/execution/distance.bin": "e012cbbc",
"webgpu/shader/execution/dot.bin": "4e4422fc",
"webgpu/shader/execution/exp.bin": "69d128c9",
"webgpu/shader/execution/exp2.bin": "8ff6b47c",
"webgpu/shader/execution/faceForward.bin": "9db6ba7c",
"webgpu/shader/execution/floor.bin": "390d4095",
"webgpu/shader/execution/fma.bin": "2f0cc932",
"webgpu/shader/execution/fract.bin": "d5adea9",
"webgpu/shader/execution/frexp.bin": "426d8896",
"webgpu/shader/execution/inverseSqrt.bin": "bb5fa342",
"webgpu/shader/execution/ldexp.bin": "efae4849",
"webgpu/shader/execution/length.bin": "fd465bc5",
"webgpu/shader/execution/log.bin": "fccd2720",
"webgpu/shader/execution/log2.bin": "79218514",
"webgpu/shader/execution/max.bin": "83d5bf02",
"webgpu/shader/execution/min.bin": "e3879019",
"webgpu/shader/execution/mix.bin": "9d656458",
"webgpu/shader/execution/modf.bin": "699020c0",
"webgpu/shader/execution/normalize.bin": "10b742c3",
"webgpu/shader/execution/pack2x16float.bin": "7bc9650c",
"webgpu/shader/execution/pow.bin": "75838277",
"webgpu/shader/execution/quantizeToF16.bin": "6e984214",
"webgpu/shader/execution/radians.bin": "9a0d018b",
"webgpu/shader/execution/reflect.bin": "4466e293",
"webgpu/shader/execution/refract.bin": "a2567635",
"webgpu/shader/execution/round.bin": "5b51d80a",
"webgpu/shader/execution/saturate.bin": "e4df7a6d",
"webgpu/shader/execution/sign.bin": "d487be2d",
"webgpu/shader/execution/sin.bin": "f163d263",
"webgpu/shader/execution/sinh.bin": "f1101f5a",
"webgpu/shader/execution/smoothstep.bin": "b1f55378",
"webgpu/shader/execution/sqrt.bin": "8bd7012b",
"webgpu/shader/execution/step.bin": "110a275",
"webgpu/shader/execution/tan.bin": "5459be1f",
"webgpu/shader/execution/tanh.bin": "80a6df0e",
"webgpu/shader/execution/transpose.bin": "f7044a92",
"webgpu/shader/execution/trunc.bin": "ed12ec64",
"webgpu/shader/execution/unpack2x16float.bin": "d23babe0",
"webgpu/shader/execution/unpack2x16snorm.bin": "4642a93c",
"webgpu/shader/execution/unpack2x16unorm.bin": "f6a97c9e",
"webgpu/shader/execution/unpack4x8snorm.bin": "6e14623",
"webgpu/shader/execution/unpack4x8unorm.bin": "4e898f1a",
"webgpu/shader/execution/unary/af_arithmetic.bin": "ee10c839",
"webgpu/shader/execution/unary/af_assignment.bin": "630efc9b",
"webgpu/shader/execution/unary/bool_conversion.bin": "e164da1a",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "33e18928",
"webgpu/shader/execution/unary/f16_conversion.bin": "8fb6afc8",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "50cfea21",
"webgpu/shader/execution/unary/f32_conversion.bin": "ea0858e9",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "c18f10fb",
"webgpu/shader/execution/unary/i32_complement.bin": "5c92c508",
"webgpu/shader/execution/unary/i32_conversion.bin": "8170e9ba",
"webgpu/shader/execution/unary/u32_complement.bin": "b463fd72",
"webgpu/shader/execution/unary/u32_conversion.bin": "d1fa1bf3"
"webgpu/shader/execution/binary/af_addition.bin": "2c5e7574",
"webgpu/shader/execution/binary/af_logical.bin": "2885252a",
"webgpu/shader/execution/binary/af_division.bin": "de2c92cc",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "3c01149a",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "bd4616a3",
"webgpu/shader/execution/binary/af_multiplication.bin": "30337a92",
"webgpu/shader/execution/binary/af_remainder.bin": "b974c5d4",
"webgpu/shader/execution/binary/af_subtraction.bin": "e532bbbe",
"webgpu/shader/execution/binary/f16_addition.bin": "36beac4c",
"webgpu/shader/execution/binary/f16_logical.bin": "48b5847",
"webgpu/shader/execution/binary/f16_division.bin": "5377812e",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "2f778220",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "8f7db49c",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "ccc6898f",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "66ab0554",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "c570c9d1",
"webgpu/shader/execution/binary/f16_multiplication.bin": "eb1180d7",
"webgpu/shader/execution/binary/f16_remainder.bin": "85b6f6f2",
"webgpu/shader/execution/binary/f16_subtraction.bin": "17cb0c61",
"webgpu/shader/execution/binary/f32_addition.bin": "7ed11615",
"webgpu/shader/execution/binary/f32_logical.bin": "49eb7a68",
"webgpu/shader/execution/binary/f32_division.bin": "73dbed8a",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "72980509",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "58aa220c",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "f8b0e4a8",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "7878810e",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "58d640f4",
"webgpu/shader/execution/binary/f32_multiplication.bin": "16e09d10",
"webgpu/shader/execution/binary/f32_remainder.bin": "a6c6a8fa",
"webgpu/shader/execution/binary/f32_subtraction.bin": "6fa482ff",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "9428fcd7",
"webgpu/shader/execution/binary/i32_comparison.bin": "11d07528",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "243cb8a1",
"webgpu/shader/execution/binary/u32_comparison.bin": "272ae0fa",
"webgpu/shader/execution/abs.bin": "aa2f77b4",
"webgpu/shader/execution/acos.bin": "223ed115",
"webgpu/shader/execution/acosh.bin": "e2b339c8",
"webgpu/shader/execution/asin.bin": "b09c87",
"webgpu/shader/execution/asinh.bin": "a269a791",
"webgpu/shader/execution/atan.bin": "72435ef",
"webgpu/shader/execution/atan2.bin": "c766ee54",
"webgpu/shader/execution/atanh.bin": "ca85d013",
"webgpu/shader/execution/bitcast.bin": "f1dfaef7",
"webgpu/shader/execution/ceil.bin": "956505f5",
"webgpu/shader/execution/clamp.bin": "f411b304",
"webgpu/shader/execution/cos.bin": "40a28b62",
"webgpu/shader/execution/cosh.bin": "ad54c793",
"webgpu/shader/execution/cross.bin": "520c3390",
"webgpu/shader/execution/degrees.bin": "c847ea4f",
"webgpu/shader/execution/determinant.bin": "c601a65d",
"webgpu/shader/execution/distance.bin": "466b0741",
"webgpu/shader/execution/dot.bin": "8150a481",
"webgpu/shader/execution/exp.bin": "47940592",
"webgpu/shader/execution/exp2.bin": "ee99106",
"webgpu/shader/execution/faceForward.bin": "71fd946c",
"webgpu/shader/execution/floor.bin": "dc1e0116",
"webgpu/shader/execution/fma.bin": "f8a5fcd0",
"webgpu/shader/execution/fract.bin": "d64b4648",
"webgpu/shader/execution/frexp.bin": "fcbd25a7",
"webgpu/shader/execution/inverseSqrt.bin": "b9516be3",
"webgpu/shader/execution/ldexp.bin": "cea8acfb",
"webgpu/shader/execution/length.bin": "f2c1b5d4",
"webgpu/shader/execution/log.bin": "50f2df6",
"webgpu/shader/execution/log2.bin": "3fed9ca1",
"webgpu/shader/execution/max.bin": "c687421f",
"webgpu/shader/execution/min.bin": "93d6f7dd",
"webgpu/shader/execution/mix.bin": "90fc51a1",
"webgpu/shader/execution/modf.bin": "ffa60832",
"webgpu/shader/execution/normalize.bin": "edab0498",
"webgpu/shader/execution/pack2x16float.bin": "157b9079",
"webgpu/shader/execution/pow.bin": "7013e734",
"webgpu/shader/execution/quantizeToF16.bin": "d1b7619f",
"webgpu/shader/execution/radians.bin": "35d5c4a4",
"webgpu/shader/execution/reflect.bin": "8c78147",
"webgpu/shader/execution/refract.bin": "f6797744",
"webgpu/shader/execution/round.bin": "87053dcd",
"webgpu/shader/execution/saturate.bin": "a6478965",
"webgpu/shader/execution/sign.bin": "6764de33",
"webgpu/shader/execution/sin.bin": "2a231111",
"webgpu/shader/execution/sinh.bin": "f1aa29f4",
"webgpu/shader/execution/smoothstep.bin": "446216ba",
"webgpu/shader/execution/sqrt.bin": "8686bbeb",
"webgpu/shader/execution/step.bin": "c7f41980",
"webgpu/shader/execution/tan.bin": "3839e7f0",
"webgpu/shader/execution/tanh.bin": "e98e67a7",
"webgpu/shader/execution/transpose.bin": "4e422cd2",
"webgpu/shader/execution/trunc.bin": "abc8cd37",
"webgpu/shader/execution/unpack2x16float.bin": "9d44b030",
"webgpu/shader/execution/unpack2x16snorm.bin": "2c62ccb1",
"webgpu/shader/execution/unpack2x16unorm.bin": "953c2189",
"webgpu/shader/execution/unpack4x8snorm.bin": "d7afd331",
"webgpu/shader/execution/unpack4x8unorm.bin": "1de18638",
"webgpu/shader/execution/unary/af_arithmetic.bin": "d81659dd",
"webgpu/shader/execution/unary/af_assignment.bin": "3c291894",
"webgpu/shader/execution/unary/bool_conversion.bin": "a772b7a8",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "42a82294",
"webgpu/shader/execution/unary/f16_conversion.bin": "187f2a7d",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "1e8f5ba5",
"webgpu/shader/execution/unary/f32_conversion.bin": "44626171",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "af2d5073",
"webgpu/shader/execution/unary/i32_complement.bin": "d2454830",
"webgpu/shader/execution/unary/i32_conversion.bin": "fff42cc4",
"webgpu/shader/execution/unary/u32_complement.bin": "f999c865",
"webgpu/shader/execution/unary/u32_conversion.bin": "a2f40c7e"
}

0 comments on commit 462fd8e

Please sign in to comment.