refactor: harden tests

This commit is contained in:
zhom
2026-07-21 23:13:17 +04:00
parent f7daf68b52
commit 9624ec846d
81 changed files with 11771 additions and 983 deletions
+19 -26
View File
@@ -4,7 +4,10 @@ import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const MANIFEST_DIR = dirname(fileURLToPath(import.meta.url));
const PROFILE = process.env.PROFILE || "debug";
const PROFILE =
process.argv.includes("--release") || process.env.PROFILE === "release"
? "release"
: "debug";
function getTarget() {
if (process.env.TARGET) return process.env.TARGET;
@@ -48,32 +51,22 @@ function copyBinary(baseName) {
if (isWindows) destName += ".exe";
const dest = join(destDir, destName);
if (existsSync(source)) {
copyFileSync(source, dest);
console.log(`Copied ${binName} to ${dest}`);
} else {
console.log(`Warning: Binary not found at ${source}`);
console.log(`Building ${baseName} binary...`);
const buildArgs = ["build", "--bin", baseName];
if (PROFILE === "release") buildArgs.push("--release");
if (TARGET !== "unknown" && TARGET !== HOST_TARGET) {
buildArgs.push("--target", TARGET);
}
execFileSync("cargo", buildArgs, {
cwd: MANIFEST_DIR,
stdio: "inherit",
});
if (existsSync(source)) {
copyFileSync(source, dest);
console.log(`Built and copied ${binName} to ${dest}`);
} else {
console.error(`Error: Failed to build ${baseName} binary`);
process.exit(1);
}
const buildArgs = ["build", "--bin", baseName];
if (PROFILE === "release") buildArgs.push("--release");
if (TARGET !== "unknown" && TARGET !== HOST_TARGET) {
buildArgs.push("--target", TARGET);
}
execFileSync("cargo", buildArgs, {
cwd: MANIFEST_DIR,
stdio: "inherit",
});
if (!existsSync(source)) {
console.error(`Error: Failed to build ${baseName} binary`);
process.exit(1);
}
copyFileSync(source, dest);
console.log(`Built and copied ${binName} to ${dest}`);
}
copyBinary("donut-proxy");