blob: 32d83dfb6d7845f2c6be69d4b999046ae2a789f3 [file] [log] [blame]
{"version":3,"sources":["../../../src/common/runtime/wpt.ts"],"names":["DefaultTestFileLoader","prettyPrintLog","Logger","parseQuery","parseExpectationsForTestQuery","relativeQueryString","assert","optionEnabled","TestWorker","setup","explicit_done","workerEnabled","worker","undefined","failOnWarnings","shouldWebGPUCTSFailOnWarnings","loader","qs","URLSearchParams","window","location","search","getAll","length","filterQuery","testcases","loadCases","expectations","loadWebGPUExpectations","URL","href","log","testcase","name","query","toString","shortName","wpt_fn","rec","res","record","run","status","logs","map","assert_unreached","join","promise_test","done"],"mappings":";AAAA;AACA,G,CADA;AAEA,SAASA,qBAAT,QAAsC,4BAAtC,CACA,SAASC,cAAT,QAA+B,oCAA/B;AACA,SAASC,MAAT,QAAuB,+BAAvB;AACA,SAASC,UAAT,QAA2B,iCAA3B;AACA,SAASC,6BAAT,EAAwCC,mBAAxC,QAAmE,4BAAnE;AACA,SAASC,MAAT,QAAuB,iBAAvB;;AAEA,SAASC,aAAT,QAA8B,qBAA9B;AACA,SAASC,UAAT,QAA2B,yBAA3B;;AAEA;;;;;;;;;;;;;AAaAC,KAAK,CAAC;AACJ;AACA;AACAC,EAAAA,aAAa,EAAE,IAHX,EAAD,CAAL;;;AAMA,CAAC,YAAY;AACX,QAAMC,aAAa,GAAGJ,aAAa,CAAC,QAAD,CAAnC;AACA,QAAMK,MAAM,GAAGD,aAAa,GAAG,IAAIH,UAAJ,CAAe,KAAf,CAAH,GAA2BK,SAAvD;;AAEA,QAAMC,cAAc;AAClB,SAAOC,6BAAP,KAAyC,WAAzC,KAAyD,MAAMA,6BAA/D,CADF;;AAGA,QAAMC,MAAM,GAAG,IAAIhB,qBAAJ,EAAf;AACA,QAAMiB,EAAE,GAAG,IAAIC,eAAJ,CAAoBC,MAAM,CAACC,QAAP,CAAgBC,MAApC,EAA4CC,MAA5C,CAAmD,GAAnD,CAAX;AACAhB,EAAAA,MAAM,CAACW,EAAE,CAACM,MA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I,CAACG,IAAL,CAAU,IAAV,CAAP,GAAyB,IAA1B,CAAhB;AACD;AACF,KAbD;;AAeAC,IAAAA,YAAY,CAACV,MAAD,EAASD,SAAT,CAAZ;AACD;;AAEDY,EAAAA,IAAI;AACL,CAhDD","sourcesContent":["// Implements the wpt-embedded test runner (see also: wpt/cts.https.html).\n\nimport { DefaultTestFileLoader } from '../internal/file_loader.js';\nimport { prettyPrintLog } from '../internal/logging/log_message.js';\nimport { Logger } from '../internal/logging/logger.js';\nimport { parseQuery } from '../internal/query/parseQuery.js';\nimport { parseExpectationsForTestQuery, relativeQueryString } from '../internal/query/query.js';\nimport { assert } from '../util/util.js';\n\nimport { optionEnabled } from './helper/options.js';\nimport { TestWorker } from './helper/test_worker.js';\n\n// testharness.js API (https://web-platform-tests.org/writing-tests/testharness-api.html)\ndeclare interface WptTestObject {\n step(f: () => void): void;\n done(): void;\n}\ndeclare function setup(properties: { explicit_done?: boolean }): void;\ndeclare function promise_test(f: (t: WptTestObject) => Promise<void>, name: string): void;\ndeclare function done(): void;\ndeclare function assert_unreached(description: string): void;\n\ndeclare const loadWebGPUExpectations: Promise<unknown> | undefined;\ndeclare const shouldWebGPUCTSFailOnWarnings: Promise<boolean> | undefined;\n\nsetup({\n // It's convenient for us to asynchronously add tests to the page. Prevent done() from being\n // called implicitly when the page is finished loading.\n explicit_done: true,\n});\n\n(async () => {\n const workerEnabled = optionEnabled('worker');\n const worker = workerEnabled ? new TestWorker(false) : undefined;\n\n const failOnWarnings =\n typeof shouldWebGPUCTSFailOnWarnings !== 'undefined' && (await shouldWebGPUCTSFailOnWarnings);\n\n const loader = new DefaultTestFileLoader();\n const qs = new URLSearchParams(window.location.search).getAll('q');\n assert(qs.length === 1, 'currently, there must be exactly one ?q=');\n const filterQuery = parseQuery(qs[0]);\n const testcases = await loader.loadCases(filterQuery);\n\n const expectations =\n typeof loadWebGPUExpectations !== 'undefined'\n ? parseExpectationsForTestQuery(\n await loadWebGPUExpectations,\n filterQuery,\n new URL(window.location.href)\n )\n : [];\n\n const log = new Logger();\n\n for (const testcase of testcases) {\n const name = testcase.query.toString();\n // For brevity, display the case name \"relative\" to the ?q= path.\n const shortName = relativeQueryString(filterQuery, testcase.query) || '(case)';\n\n const wpt_fn = async () => {\n const [rec, res] = log.record(name);\n if (worker) {\n await worker.run(rec, name, expectations);\n } else {\n await testcase.run(rec, expectations);\n }\n\n // Unfortunately, it seems not possible to surface any logs for warn/skip.\n if (res.status === 'fail' || (res.status === 'warn' && failOnWarnings)) {\n const logs = (res.logs ?? []).map(prettyPrintLog);\n assert_unreached('\\n' + logs.join('\\n') + '\\n');\n }\n };\n\n promise_test(wpt_fn, shortName);\n }\n\n done();\n})();\n"],"file":"wpt.js"}