test: remove module and timestamp assumptions from boundary fixtures (#1621)
This commit is contained in:
@@ -36,8 +36,8 @@ const writeBlockingCompiler = async (directory: string) => {
|
||||
const statePath = join(directory, "compile-state.json");
|
||||
const releasePath = join(directory, "release-compiler");
|
||||
const source = `#!/usr/bin/env node
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const fs = process.getBuiltinModule("node:fs");
|
||||
const path = process.getBuiltinModule("node:path");
|
||||
const statePath = ${JSON.stringify(statePath)};
|
||||
const releasePath = ${JSON.stringify(releasePath)};
|
||||
const state = fs.existsSync(statePath)
|
||||
@@ -69,14 +69,14 @@ const writeBlockingIdentityCompiler = async (directory: string) => {
|
||||
const executable = join(directory, "fake-identity-xcrun");
|
||||
const statePath = join(directory, "identity-helper-state.json");
|
||||
const helperSource = `#!/usr/bin/env node
|
||||
const fs = require("node:fs");
|
||||
const fs = process.getBuiltinModule("node:fs");
|
||||
fs.writeFileSync(${JSON.stringify(statePath)}, JSON.stringify({
|
||||
root: __dirname,
|
||||
root: process.getBuiltinModule("node:path").dirname(fs.realpathSync(process.argv[1])),
|
||||
}));
|
||||
setInterval(() => {}, 1000);
|
||||
`;
|
||||
const compilerSource = `#!/usr/bin/env node
|
||||
const fs = require("node:fs");
|
||||
const fs = process.getBuiltinModule("node:fs");
|
||||
const outputIndex = process.argv.indexOf("-o");
|
||||
const output = process.argv[outputIndex + 1];
|
||||
fs.writeFileSync(output, ${JSON.stringify(helperSource)});
|
||||
@@ -309,14 +309,14 @@ const writeTemporaryObjectCompiler = async (directory: string) => {
|
||||
const executable = join(directory, "fake-temporary-xcrun");
|
||||
const statePath = join(directory, "temporary-state.json");
|
||||
const source = `#!/usr/bin/env node
|
||||
const fs = require("node:fs");
|
||||
const os = require("node:os");
|
||||
const path = require("node:path");
|
||||
const { spawn } = require("node:child_process");
|
||||
const fs = process.getBuiltinModule("node:fs");
|
||||
const os = process.getBuiltinModule("node:os");
|
||||
const path = process.getBuiltinModule("node:path");
|
||||
const { spawn } = process.getBuiltinModule("node:child_process");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "TemporaryDirectory."));
|
||||
const object = path.join(temporary, "ProcessRunTokenReader-1.o");
|
||||
const job = spawn(process.execPath, ["-e",
|
||||
"setTimeout(() => { const fs = require('node:fs'); fs.mkdirSync(" + JSON.stringify(temporary) +
|
||||
"setTimeout(() => { const fs = process.getBuiltinModule('node:fs'); fs.mkdirSync(" + JSON.stringify(temporary) +
|
||||
", { recursive: true }); fs.writeFileSync(" + JSON.stringify(object) + ", 'object'); }, 300)"],
|
||||
{ detached: true, stdio: "ignore" });
|
||||
job.unref();
|
||||
|
||||
Reference in New Issue
Block a user