Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Stop the bake time limit test depending on machine speed

Nguyen Xuan An985fc0e41f1d
diff --git a/tests/agent-bake.test.js b/tests/agent-bake.test.js
index a13b42e1..556e40d8 100644
--- a/tests/agent-bake.test.js
+++ b/tests/agent-bake.test.js
@@ -234,7 +234,18 @@ test('explicit settings far above the preset budget run when they fit the hard l
test('an explicit bake that passes maxSeconds fails cleanly with a lower setting to try', () => {
const slow = { samples: 256, bounces: 3, texelsPerUnit: 7 };
- assert.throws(() => createAgentScene(largeRoom(slow)), error => /maxSeconds/.test(error.message) && /Try samples 128/.test(error.message));
+ // A fast machine finishes this bake inside the real limit, so each clock read is made to cost a second.
+ const realNow = performance.now;
+ let clockReads = 0;
+ performance.now = () => {
+ clockReads += 1;
+ return realNow.call(performance) + clockReads * 1000;
+ };
+ try {
+ assert.throws(() => createAgentScene(largeRoom(slow)), error => /maxSeconds/.test(error.message) && /Try samples 128/.test(error.message));
+ } finally {
+ performance.now = realNow;
+ }
});
test('the bake kernel carries 20 s on the page thread and 90 s inside a worker', () => {