Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/tests/cache-location.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* lines into the new file. The move is idempotent, keeps union-merged lines,
* and survives a merge with a clone that still writes the old names.
*/
import { withoutSigningForEach } from "./git-fixture";
import { afterEach, expect, test } from "bun:test";
import { Database } from "bun:sqlite";
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, symlinkSync, writeFileSync } from "fs";
Expand All @@ -23,6 +24,8 @@ import { vecAvailable } from "./vec-fixture";
import { makeTempBrain, runCli } from "./cli-harness";
import { brainWithRemote, cleanupFixtures, git, write } from "./sync-fixture";

withoutSigningForEach();

const DIM = 16;
const taxonomy = buildTaxonomy({ user: null });
const OLD_CONTEXTS = ".context-cache.jsonl";
Expand Down
23 changes: 22 additions & 1 deletion packages/core/tests/git-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* config is needed.
*/

import { expect } from "bun:test";
import { afterEach, beforeEach, expect } from "bun:test";

export function git(root: string, ...args: string[]): string {
const proc = Bun.spawnSync(
Expand Down Expand Up @@ -87,3 +87,24 @@ export function withoutSigning(env: Record<string, string>): Record<string, stri
[`GIT_CONFIG_KEY_${count + 1}`]: "tag.gpgSign", [`GIT_CONFIG_VALUE_${count + 1}`]: "false",
};
}

/**
* Opt one test file into unsigned fixture and product commits, including
* in-process Git children. Unlike a preload override, this runs only where
* requested; signing-policy tests keep their original environment (#3485).
*/
export function withoutSigningForEach(): void {
let before: Record<string, string> = {};
beforeEach(() => {
before = Object.fromEntries(Object.entries(process.env).filter(
(entry): entry is [string, string] => entry[0].startsWith("GIT_CONFIG_") && entry[1] !== undefined,
));
Object.assign(process.env, withoutSigning(before));
});
afterEach(() => {
for (const key of Object.keys(process.env)) {
if (key.startsWith("GIT_CONFIG_") && !(key in before)) delete process.env[key];
}
Object.assign(process.env, before);
});
}
3 changes: 3 additions & 0 deletions packages/core/tests/media-review-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* `brain sync` and review's `brain hygiene next` for the same tree.
*/

import { withoutSigningForEach } from "./git-fixture";
import { afterEach, describe, expect, test } from "bun:test";
import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
Expand All @@ -15,6 +16,8 @@ import type { RunEnvelope } from "../src/lib/sync/run";
import { runCli } from "./cli-harness";
import { brainWithRemote, cleanupFixtures, git, syncJson, write } from "./sync-fixture";

withoutSigningForEach();

afterEach(cleanupFixtures);

const LOG = "context/hygiene";
Expand Down
3 changes: 3 additions & 0 deletions packages/core/tests/sync-cache-commit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* A pull that cannot merge says whether git refused or stopped on conflicts.
*/

import { withoutSigningForEach } from "./git-fixture";
import { afterEach, describe, expect, test } from "bun:test";
import { Database } from "bun:sqlite";
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
Expand All @@ -18,6 +19,8 @@ import { chunkContextKey } from "../src/lib/indexer.js";
import { saveContextCache } from "../src/lib/indexer/caches.js";
import { makeTempBrain, runCli } from "./cli-harness";

withoutSigningForEach();

const CACHE = ".brain-cache/contexts.jsonl";
const dirs: string[] = [];

Expand Down
3 changes: 3 additions & 0 deletions packages/core/tests/sync-commit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* and leaves anything else staged where it was.
*/

import { withoutSigningForEach } from "./git-fixture";
import { afterEach, describe, expect, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
Expand All @@ -21,6 +22,8 @@ import {
type GroupedFile,
} from "../src/lib/sync/commit.js";

withoutSigningForEach();

const TODAY = "2026-09-28";
const dirs: string[] = [];

Expand Down
3 changes: 3 additions & 0 deletions packages/core/tests/sync-pull-rebase.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/** Rebase-first pulls against real clones; conflicts must return to merge semantics. */
import { withoutSigningForEach } from "./git-fixture";
import { afterEach, describe, expect, test } from "bun:test";
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { brainConfigSchema } from "../src/lib/config";
import { runCli } from "./cli-harness";
import { brainWithRemote, cleanupFixtures, commitAndPush, git, gitMayFail, otherClone, write, type Brain } from "./sync-fixture";

withoutSigningForEach();

afterEach(cleanupFixtures);
const CACHE = ".brain-cache/contexts.jsonl";
const head = (root: string) => git(root, "rev-parse", "HEAD");
Expand Down
3 changes: 3 additions & 0 deletions packages/core/tests/sync-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* rules left.
*/

import { withoutSigningForEach } from "./git-fixture";
import { afterAll, afterEach, beforeAll, describe, expect, test } from "bun:test";
import { chmodSync, mkdirSync, readFileSync, renameSync, symlinkSync, writeFileSync } from "node:fs";
import { join } from "node:path";
Expand Down Expand Up @@ -38,6 +39,8 @@ import {
write,
} from "./sync-fixture";

withoutSigningForEach();

afterEach(cleanupFixtures);

const { sameNote, codeConflict, pushRace } = SCENARIO_SETUPS;
Expand Down
3 changes: 3 additions & 0 deletions packages/core/tests/sync-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* `init` reported arrives unchanged, a run the rules finish never launches
* the CLI, and human mode keeps the report and the agent's text.
*/
import { withoutSigningForEach } from "./git-fixture";
import { afterEach, describe, expect, test } from "bun:test";
import { chmodSync, existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
Expand All @@ -12,6 +13,8 @@ import { join } from "node:path";
import { runCli } from "./cli-harness";
import { brainWithRemote, cleanupFixtures, SCENARIO_SETUPS } from "./sync-fixture";

withoutSigningForEach();

const scratch: string[] = [];
afterEach(() => {
cleanupFixtures();
Expand Down
3 changes: 3 additions & 0 deletions packages/core/tests/sync-scenarios.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* `scripts/measure-sync-run.ts` times the same states.
*/

import { withoutSigningForEach } from "./git-fixture";
import { afterEach, describe, expect, test } from "bun:test";
import {
brainWithRemote,
Expand All @@ -21,6 +22,8 @@ import {
type Brain,
} from "./sync-fixture";

withoutSigningForEach();

afterEach(cleanupFixtures);

interface Row {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/tests/sync-stats-history.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
* `brain doctor --fix`) git conflicts on it, and nothing but an agent could
* resolve it. The fixture brain has no `.gitattributes`, which is that brain.
*/
import { withoutSigningForEach } from "./git-fixture";
import { afterEach, describe, expect, test } from "bun:test";
import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";

import { brainWithRemote, cleanupFixtures, commitAndPush, git, otherClone, syncJson, write, type Brain } from "./sync-fixture";

withoutSigningForEach();

const HISTORY = ".stats-history.jsonl";
const day = (date: string, at: string, documents: number) => JSON.stringify({ date, at, documents });

Expand Down
3 changes: 3 additions & 0 deletions packages/core/tests/sync-verbs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* off; the judged paths run in-process with a fake Jev, never the network.
*/

import { withoutSigningForEach } from "./git-fixture";
import { afterEach, describe, expect, test } from "bun:test";
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
Expand All @@ -24,6 +25,8 @@ import {
write,
} from "./sync-fixture";

withoutSigningForEach();

afterEach(cleanupFixtures);

const IGNORE_SUBJECT = "Ignore generated artifacts and secrets";
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-server/tests/jobs-board-selection-http.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { withoutSigningForEach } from "../../core/tests/git-fixture";
import { expect, test } from "bun:test";
import { existsSync, mkdirSync, readFileSync, symlinkSync, writeFileSync } from "node:fs";
import { join, resolve } from "node:path";
import { BRAIN_BIN, keylessEnv, runCli } from "../../core/tests/cli-harness";
import { RETIRED_SOURCES } from "../../module-jobs/src/types";
import { httpContractApp } from "./helpers/http-contract-app";

withoutSigningForEach();

function git(root: string, args: string[]) {
const result = Bun.spawnSync(["git", "-C", root, ...args]);
expect(result.exitCode, new TextDecoder().decode(result.stderr)).toBe(0);
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-server/tests/module-settings-http.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { withoutSigningForEach } from "../../core/tests/git-fixture";
import { expect, test } from "bun:test";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
Expand All @@ -11,6 +12,8 @@ import { BRAIN_BIN } from "../../core/tests/cli-harness";
import { createPrincipal } from "../src/db/principals";
import { httpContractApp } from "./helpers/http-contract-app";

withoutSigningForEach();

const SECRET = "module-settings-fixture-secret-0123456789";
function git(root: string, args: string[]): string {
const p = Bun.spawnSync(["git", "-C", root, ...args]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ test("bounded maintenance kills and reaps an actual output-flooding worker", asy
test("hosted packing publishes real Git packs while preserving refs and history", async () => {
const f = fixture();
const git = (...args: string[]) => {
const p = Bun.spawnSync(["git", "-C", f.brain, ...args], { stdout: "pipe", stderr: "pipe", env: { ...process.env, GIT_CONFIG_GLOBAL: "/dev/null", GIT_CONFIG_NOSYSTEM: "1" } });
const p = Bun.spawnSync(["git", "-c", "commit.gpgsign=false", "-C", f.brain, ...args], { stdout: "pipe", stderr: "pipe", env: { ...process.env, GIT_CONFIG_GLOBAL: "/dev/null", GIT_CONFIG_NOSYSTEM: "1" } });
expect(p.exitCode, p.stderr.toString()).toBe(0); return p.stdout.toString();
};
try {
Expand Down
Loading