mirror of
https://github.com/morluto/rea.git
synced 2026-11-01 04:16:28 +00:00
* fix(javascript): exclude TypeScript this annotations from runtime parameters * test(javascript): assert exact typed argument bindings * test(apple): keep dyld slice regression portable * fix(process): report no remaining time after a provider deadline fires Node timers can fire while performance.now() is still a fraction of a millisecond short of the monotonic deadline. ProviderStartupDeadline then reported interruption "timeout" and an aborted signal while remainingMs() returned ceil(0.x) = 1, so polling loops guarded by remainingMs() > 0 (Hopper and Ghidra startup) could run past an elapsed deadline, and the real-timer test "aborts a bounded wait when its real monotonic deadline expires" failed intermittently in CI (expected 1 to be 0). Once the deadline's own timer has classified a timeout, report zero remaining time. A deterministic regression test fires the timer with the monotonic clock 0.4 ms short of the deadline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ci): restore descriptor and fixture validation * test(ci): retain verification coverage within lint limits * fix(test): share admitted Ghidra profile installation fixtures * fix(ci): isolate timing report fixtures from workflow state --------- Co-authored-by: hhang <169027046+xu91102@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
111 lines
4.4 KiB
JavaScript
111 lines
4.4 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { execFileSync } from "node:child_process";
|
|
import {
|
|
copyFile,
|
|
mkdir,
|
|
mkdtemp,
|
|
readdir,
|
|
rmdir,
|
|
rm,
|
|
stat,
|
|
symlink,
|
|
writeFile,
|
|
} from "node:fs/promises";
|
|
import { createRequire } from "node:module";
|
|
import { tmpdir } from "node:os";
|
|
import { dirname, join, resolve } from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
if (process.platform !== "win32")
|
|
throw new Error("Native inspection ownership requires real Windows NTFS");
|
|
const root = resolve(process.argv[2] ?? ".");
|
|
const artifact = resolve(
|
|
process.argv[3] ?? ".cache/windows-native-inspection-fixture",
|
|
);
|
|
const workspace = await mkdtemp(join(tmpdir(), "rea-inspection-conformance-"));
|
|
try {
|
|
// Isolate the fixture from the packaged production artifact and loader cache.
|
|
await mkdir(join(workspace, "dist", "windows"), { recursive: true });
|
|
await mkdir(join(workspace, "native", "windows", "build"), {
|
|
recursive: true,
|
|
});
|
|
await writeFile(join(workspace, "package.json"), '{"type":"module"}');
|
|
await copyFile(
|
|
join(root, "dist", "windows", "WindowsNativeLoader.js"),
|
|
join(workspace, "dist", "windows", "WindowsNativeLoader.js"),
|
|
);
|
|
await copyFile(
|
|
join(root, "dist", "generatedPackageMetadata.js"),
|
|
join(workspace, "dist", "generatedPackageMetadata.js"),
|
|
);
|
|
for (const name of ["manifest.json", "rea-windows-x64.node"])
|
|
await copyFile(
|
|
join(artifact, name),
|
|
join(workspace, "native", "windows", "build", name),
|
|
);
|
|
const require = createRequire(join(root, "package.json"));
|
|
await mkdir(join(workspace, "node_modules"));
|
|
await symlink(
|
|
dirname(require.resolve("zod/package.json")),
|
|
join(workspace, "node_modules", "zod"),
|
|
"junction",
|
|
);
|
|
const loader = pathToFileURL(
|
|
join(workspace, "dist", "windows", "WindowsNativeLoader.js"),
|
|
).href;
|
|
const source = `import assert from 'node:assert/strict';
|
|
import {existsSync,mkdirSync,readdirSync,renameSync,statSync} from 'node:fs';
|
|
import {join} from 'node:path';
|
|
import {systemWindowsNativeAuthority} from ${JSON.stringify(loader)};
|
|
const temp=process.env.TEMP;
|
|
const first=systemWindowsNativeAuthority();
|
|
assert.equal(first.available,false);
|
|
assert.equal(first.retryable,true);
|
|
assert.match(first.reason,/Delete owned object by handle failed.*Win32 5/s);
|
|
const [name,...extra]=readdirSync(temp);assert.ok(name);assert.equal(extra.length,0);
|
|
const path=join(temp,name);const identity=statSync(path,{bigint:true});
|
|
// Ownership follows the retained NTFS handle even when the directory moves.
|
|
// A replacement at its old pathname must remain caller-owned.
|
|
const moved=path+'-renamed';renameSync(path,moved);
|
|
assert.equal(statSync(moved,{bigint:true}).ino,identity.ino);
|
|
mkdirSync(path);const replacement=statSync(path,{bigint:true});
|
|
assert.notEqual(replacement.ino,identity.ino);
|
|
if(process.argv[2]!=='teardown'){
|
|
const second=systemWindowsNativeAuthority();assert.equal(second.available,true);
|
|
assert.equal(existsSync(moved),false);
|
|
assert.deepEqual(readdirSync(temp),[name]);
|
|
assert.equal(statSync(path,{bigint:true}).ino,replacement.ino);
|
|
assert.equal(systemWindowsNativeAuthority(),second);
|
|
}
|
|
console.log(JSON.stringify({mode:process.argv[2],firstFailed:true,retainedOwner:true,inode:identity.ino.toString(),replacementName:name,replacementInode:replacement.ino.toString()}));
|
|
`;
|
|
const fixture = join(workspace, "probe.mjs");
|
|
await writeFile(fixture, source);
|
|
for (const mode of ["retry", "teardown"]) {
|
|
const temp = join(workspace, mode);
|
|
await mkdir(temp);
|
|
const observed = JSON.parse(
|
|
execFileSync(process.execPath, [fixture, mode], {
|
|
encoding: "utf8",
|
|
timeout: 20_000,
|
|
windowsHide: true,
|
|
env: { ...process.env, TEMP: temp, TMP: temp },
|
|
}),
|
|
);
|
|
assert.equal(observed.retainedOwner, true);
|
|
assert.deepEqual(await readdir(temp), [observed.replacementName]);
|
|
const replacement = join(temp, observed.replacementName);
|
|
assert.equal(
|
|
(await stat(replacement, { bigint: true })).ino.toString(),
|
|
observed.replacementInode,
|
|
);
|
|
await rmdir(replacement);
|
|
assert.deepEqual(await readdir(temp), []);
|
|
}
|
|
process.stdout.write(
|
|
`${JSON.stringify({ ok: true, controlledDispositionFailure: true, retainedOwner: true, renamedOwnerCleanup: true, replacementPreserved: true, retryRecovers: true, successfulAdmissionCached: true, environmentTeardownCleansProbe: true, issue1701HostCauseReproduced: false })}\n`,
|
|
);
|
|
} finally {
|
|
await rm(workspace, { recursive: true, force: true });
|
|
}
|