CTS: Hook into CTS heartbeat mechanism instead of wrapping TestCaseRecorder
Bug: chromium:1340602 Change-Id: I6272432c69c65fa45cbae9bedc02aec82ba68c8a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100561 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
81d62d7ca9
commit
b00c50edc6
|
@ -12,6 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { globalTestConfig } from '../third_party/webgpu-cts/src/common/framework/test_config.js';
|
||||
import { DefaultTestFileLoader } from '../third_party/webgpu-cts/src/common/internal/file_loader.js';
|
||||
import { prettyPrintLog } from '../third_party/webgpu-cts/src/common/internal/logging/log_message.js';
|
||||
import { Logger } from '../third_party/webgpu-cts/src/common/internal/logging/logger.js';
|
||||
|
@ -130,24 +131,7 @@ wrapPromiseWithHeartbeat(GPUQueue.prototype, 'onSubmittedWorkDone');
|
|||
wrapPromiseWithHeartbeat(GPUBuffer.prototype, 'mapAsync');
|
||||
wrapPromiseWithHeartbeat(GPUShaderModule.prototype, 'compilationInfo');
|
||||
|
||||
// Make a wrapper around TestCaseRecorder that sends a heartbeat before any
|
||||
// recording operations.
|
||||
function makeRecorderWithHeartbeat(rec) {
|
||||
return new Proxy(rec, {
|
||||
// Create a wrapper around all methods of the TestCaseRecorder.
|
||||
get(target, prop, receiver) {
|
||||
const orig = Reflect.get(target, prop, receiver);
|
||||
if (typeof orig !== 'function') {
|
||||
// Return the original property if it is not a function.
|
||||
return orig;
|
||||
}
|
||||
return (...args) => {
|
||||
sendHeartbeat();
|
||||
return orig.call(receiver, ...args)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
globalTestConfig.testHeartbeatCallback = sendHeartbeat;
|
||||
|
||||
async function runCtsTest(query, use_worker) {
|
||||
const workerEnabled = use_worker;
|
||||
|
@ -167,13 +151,12 @@ async function runCtsTest(query, use_worker) {
|
|||
const wpt_fn = async () => {
|
||||
sendMessageTestStarted();
|
||||
const [rec, res] = log.record(name);
|
||||
const recWithHeartbeat = makeRecorderWithHeartbeat(rec);
|
||||
|
||||
beginHeartbeatScope();
|
||||
if (worker) {
|
||||
await worker.run(recWithHeartbeat, name, expectations);
|
||||
await worker.run(rec, name, expectations);
|
||||
} else {
|
||||
await testcase.run(recWithHeartbeat, expectations);
|
||||
await testcase.run(rec, expectations);
|
||||
}
|
||||
endHeartbeatScope();
|
||||
|
||||
|
|
Loading…
Reference in New Issue