Merge origin/main for artifact admission and evidence fixes
This commit is contained in:
@@ -1,110 +0,0 @@
|
||||
import {
|
||||
copyFile,
|
||||
mkdir,
|
||||
readFile,
|
||||
symlink,
|
||||
writeFile,
|
||||
} from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { execFileOutput } from "../../../src/process/ExecFileOutput.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
const run = (root: string, command: string, arguments_: readonly string[]) =>
|
||||
execFileOutput(command, arguments_, {
|
||||
cwd: root,
|
||||
stopSignal: "SIGTERM",
|
||||
timeout: 20_000,
|
||||
});
|
||||
|
||||
const commit = (root: string, message: string) =>
|
||||
run(root, "git", [
|
||||
"-c",
|
||||
"user.name=REA fixture",
|
||||
"-c",
|
||||
"user.email=fixture@example.invalid",
|
||||
"-c",
|
||||
"commit.gpgSign=false",
|
||||
"commit",
|
||||
"--quiet",
|
||||
"-m",
|
||||
message,
|
||||
]);
|
||||
|
||||
const fixture = async () => {
|
||||
const root = await createTestTempDirectory("rea-development-tests-");
|
||||
await mkdir(join(root, "scripts", "lib"), { recursive: true });
|
||||
await mkdir(join(root, "src"));
|
||||
for (const path of [
|
||||
"scripts/run-development-tests.mjs",
|
||||
"scripts/lib/development-tests.mjs",
|
||||
])
|
||||
await copyFile(join(process.cwd(), path), join(root, path));
|
||||
await symlink(
|
||||
join(process.cwd(), "node_modules"),
|
||||
join(root, "node_modules"),
|
||||
process.platform === "win32" ? "junction" : undefined,
|
||||
);
|
||||
await writeFile(join(root, "package.json"), '{"type":"module"}\n');
|
||||
await writeFile(join(root, ".gitignore"), "node_modules\nselected.txt\n");
|
||||
await writeFile(
|
||||
join(root, "vitest.config.mjs"),
|
||||
'export default { test: { projects: [{ test: { name: "domain", include: ["src/**/*.test.ts"] } }] } };\n',
|
||||
);
|
||||
await writeFile(join(root, "src", "value.ts"), "export const value = 1;\n");
|
||||
await writeFile(
|
||||
join(root, "src", "value.test.ts"),
|
||||
'import { expect, it } from "vitest"; import { writeFileSync } from "node:fs"; import { value } from "./value.js"; it("checks the selected source", () => { expect(value).toBe(1); writeFileSync("selected.txt", String(value)); });\n',
|
||||
);
|
||||
await run(root, "git", ["init", "--quiet"]);
|
||||
await run(root, "git", ["add", "."]);
|
||||
await commit(root, "fixture");
|
||||
return root;
|
||||
};
|
||||
|
||||
const testCommand = (root: string, ...arguments_: string[]) =>
|
||||
run(root, process.execPath, [
|
||||
"scripts/run-development-tests.mjs",
|
||||
...arguments_,
|
||||
]);
|
||||
|
||||
it("executes an explicitly selected source test on a clean tree without build artifacts", async () => {
|
||||
const root = await fixture();
|
||||
const { stdout: status } = await run(root, "git", ["status", "--porcelain"]);
|
||||
expect(status).toBe("");
|
||||
await testCommand(root, "local", "src/value.test.ts");
|
||||
expect(await readFile(join(root, "selected.txt"), "utf8")).toBe("1");
|
||||
});
|
||||
|
||||
it("uses committed dependency changes since the requested Git base to select source tests", async () => {
|
||||
const root = await fixture();
|
||||
const { stdout: base } = await run(root, "git", ["rev-parse", "HEAD"]);
|
||||
await writeFile(join(root, "src", "value.ts"), "export const value = 2;\n");
|
||||
await run(root, "git", ["add", "src/value.ts"]);
|
||||
await commit(root, "change dependency");
|
||||
await expect(
|
||||
testCommand(root, "changed", "--base", base.trim()),
|
||||
).rejects.toMatchObject({
|
||||
code: 1,
|
||||
stdout: expect.stringContaining("src/value.test.ts"),
|
||||
stderr: expect.stringContaining("expected 2 to be 1"),
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects a compiled boundary in the source-only command and a missing exact test", async () => {
|
||||
const root = await fixture();
|
||||
await expect(
|
||||
testCommand(root, "local", "tests/acceptance/runtime.test.ts"),
|
||||
).rejects.toMatchObject({
|
||||
code: 1,
|
||||
stderr: expect.stringContaining("Use test:focused"),
|
||||
});
|
||||
await expect(
|
||||
testCommand(root, "local", "src/missing.test.ts"),
|
||||
).rejects.toMatchObject({
|
||||
code: 1,
|
||||
stderr: expect.stringContaining("ENOENT"),
|
||||
});
|
||||
});
|
||||
@@ -52,7 +52,7 @@ const target = {
|
||||
const host: GhidraInstallationHost = {
|
||||
platform: "linux",
|
||||
architecture: "x64",
|
||||
readText: () => "application.version=12.1.3\n",
|
||||
readText: () => "application.version=12.1.3\napplication.java.min=21\n",
|
||||
executable: () => true,
|
||||
probeJava: () => ({
|
||||
version: "21.0.12",
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { join } from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
import { spawn as spawnPty } from "@lydell/node-pty";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
@@ -185,6 +186,69 @@ describe("curl installer scenarios", { timeout: 20_000 }, () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("installer TTY fallback", { timeout: 20_000 }, () => {
|
||||
it("skips automatic setup when stderr is redirected", async () => {
|
||||
const fixture = await createFixture();
|
||||
const script = join(process.cwd(), "install.sh");
|
||||
const wrapper = `
|
||||
const { spawnSync } = require("node:child_process");
|
||||
const { openSync, closeSync } = require("node:fs");
|
||||
const stderr = openSync(process.argv[2], "w");
|
||||
const child = spawnSync("/bin/bash", [process.argv[1], ...process.argv.slice(3)], {
|
||||
stdio: ["inherit", "inherit", stderr],
|
||||
env: process.env,
|
||||
});
|
||||
closeSync(stderr);
|
||||
process.exit(child.status ?? 1);
|
||||
`;
|
||||
let output = "";
|
||||
const terminal = spawnPty(
|
||||
process.execPath,
|
||||
["-e", wrapper, script, fixture.installerStderrLog, "--version", "0.3.0"],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: {
|
||||
...process.env,
|
||||
HOME: fixture.home,
|
||||
TMPDIR: fixture.temporary,
|
||||
PATH: `${fixture.bin}:/usr/bin:/bin`,
|
||||
FAKE_NPM_LOG: fixture.npmLog,
|
||||
FAKE_REA_LOG: fixture.reaLog,
|
||||
FAKE_REA_SOURCE: join(fixture.bin, "rea-source"),
|
||||
FAKE_NPM_PREFIX: join(fixture.home, ".npm-global"),
|
||||
TERM: "xterm-256color",
|
||||
},
|
||||
name: "xterm-256color",
|
||||
cols: 120,
|
||||
rows: 40,
|
||||
},
|
||||
);
|
||||
let timedOut = false;
|
||||
const exitCode = await new Promise<number>((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
timedOut = true;
|
||||
terminal.kill();
|
||||
}, 10_000);
|
||||
terminal.onData((data) => {
|
||||
output += data;
|
||||
});
|
||||
terminal.onExit(({ exitCode: code }) => {
|
||||
clearTimeout(timeout);
|
||||
if (timedOut)
|
||||
reject(new Error(`Installer PTY timed out after output: ${output}`));
|
||||
else resolve(code);
|
||||
});
|
||||
});
|
||||
|
||||
expect(exitCode).toBe(0);
|
||||
expect(output).toContain(
|
||||
`Run ${join(fixture.home, ".local/bin/rea")} setup to configure Hopper and agents.`,
|
||||
);
|
||||
expect(await readFile(fixture.reaLog, "utf8")).toBe("--version\n");
|
||||
expect(await readFile(fixture.installerStderrLog, "utf8")).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("truncated installer download", { timeout: 20_000 }, () => {
|
||||
it("runs nothing from a download truncated after the npm install line", async () => {
|
||||
const fixture = await createFixture();
|
||||
@@ -433,6 +497,7 @@ interface InstallerFixture {
|
||||
readonly temporary: string;
|
||||
readonly npmLog: string;
|
||||
readonly reaLog: string;
|
||||
readonly installerStderrLog: string;
|
||||
}
|
||||
|
||||
const getProcessOutput = (
|
||||
@@ -456,6 +521,7 @@ const createFixture = async (): Promise<InstallerFixture> => {
|
||||
const temporary = join(root, "tmp");
|
||||
const npmLog = join(root, "npm.log");
|
||||
const reaLog = join(root, "rea.log");
|
||||
const installerStderrLog = join(root, "installer.stderr.log");
|
||||
await Promise.all([mkdir(home), mkdir(bin), mkdir(temporary)]);
|
||||
await Promise.all([
|
||||
executable(
|
||||
@@ -507,7 +573,7 @@ exit 0
|
||||
symlink(`/usr/bin/${command}`, join(bin, command)),
|
||||
),
|
||||
]);
|
||||
return { home, bin, temporary, npmLog, reaLog };
|
||||
return { home, bin, temporary, npmLog, reaLog, installerStderrLog };
|
||||
};
|
||||
|
||||
const executable = async (path: string, source: string): Promise<void> => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { analyzeJavaScriptApplication } from "../../support/javascriptApplicatio
|
||||
import { parseApplicationGraphEvidence } from "../../../src/application/javascript/JavaScriptApplicationEvidenceGraph.js";
|
||||
import { findApplicationFeatureSeeds } from "../../../src/domain/javascript/javascriptFeatureSeed.js";
|
||||
import { compareSourceToBundle } from "../../../src/domain/javascript/sourceToBundleComparison.js";
|
||||
import { resolveSourceMapSource } from "../../../src/javascript/sourceMaps/DecodedSourceMap.js";
|
||||
import { resolveJavaScriptSourceMapUrl } from "../../../src/domain/javascript/javascriptSourceMapPaths.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { importReferenceSource } from "../../support/referenceSourceResourceScope.js";
|
||||
|
||||
@@ -180,7 +180,7 @@ it.each([
|
||||
decoy: decoyPath = "src/a.js",
|
||||
}) => {
|
||||
if (sourceRoot !== undefined) {
|
||||
const resolved = resolveSourceMapSource(
|
||||
const resolved = resolveJavaScriptSourceMapUrl(
|
||||
source,
|
||||
sourceRoot,
|
||||
`https://example.test/${mapPath}`,
|
||||
|
||||
Reference in New Issue
Block a user