Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

test(compiler): regenerating the AOT artifacts leaves a file whose bytes did not change alone

esengine89e6b827ea00
diff --git a/compiler/tests/generated.test.ts b/compiler/tests/generated.test.ts
index 6e8c03175..41723f02c 100644
--- a/compiler/tests/generated.test.ts
+++ b/compiler/tests/generated.test.ts
@@ -38,8 +38,13 @@ const result = lowerProgram([
function artifact(path: string, want: string): void {
if (WRITE) {
- mkdirSync(dirname(path), { recursive: true });
- writeFileSync(path, want);
+ // Only when it differs: a rewrite of the same bytes moves the mtime every
+ // freshness check reads, and the engine built a minute ago reads as stale.
+ const same = existsSync(path) && readFileSync(path, 'utf8').replace(/\r\n/g, '\n') === want;
+ if (!same) {
+ mkdirSync(dirname(path), { recursive: true });
+ writeFileSync(path, want);
+ }
return;
}
const rel = path.slice(ROOT.length + 1);