Find code by asking what it does. A CLI for coding agents that uses Jev to discover relevant files and source context.
TypeScript ai-sdkclaude-codeclicode-searchcodexcoding-agentscontext-retrievaldeveloper-toolsjevsemantic-searchtypescriptvercel-ai-gateway
Run the test suite on Windows
Andrei Kirkouski8f285af43e52
diff --git a/apps/cli/test/auth.test.ts b/apps/cli/test/auth.test.tsindex 37f35ea..64e2328 100644--- a/apps/cli/test/auth.test.ts+++ b/apps/cli/test/auth.test.ts@@ -1,7 +1,7 @@import { expect } from "bun:test";import { mkdir, readFile, stat, writeFile } from "node:fs/promises";import { join } from "node:path";-import { testInDocker, withCli } from "./cli";+import { posix, testInDocker, withCli } from "./cli";testInDocker("installed auth saves privately, bounds stdin, and never echoes keys", async () => {await withCli(async ({ home, run }) => {@@ -15,8 +15,10 @@ testInDocker("installed auth saves privately, bounds stdin, and never echoes keyprovider: "vercel",apiKey: "test-gateway-secret",});- expect((await stat(file)).mode & 0o777).toBe(0o600);- expect((await stat(join(home, "jevgrep"))).mode & 0o777).toBe(0o700);+ if (posix) {+ expect((await stat(file)).mode & 0o777).toBe(0o600);+ expect((await stat(join(home, "jevgrep"))).mode & 0o777).toBe(0o700);+ }const whitespace = await run(["auth", "--provider", "vercel", "--stdin"], "two secrets\n");expect(whitespace.code).toBe(1);expect(whitespace.stderr).toBe("");@@ -77,8 +79,10 @@ testInDocker(model: "gateway/jev-2",apiKey: key,});- expect((await stat(file)).mode & 0o777).toBe(0o600);- expect((await stat(join(home, "jevgrep"))).mode & 0o777).toBe(0o700);+ if (posix) {+ expect((await stat(file)).mode & 0o777).toBe(0o600);+ expect((await stat(join(home, "jevgrep"))).mode & 0o777).toBe(0o700);+ }expect(requests).toHaveLength(0);const doctor = await run(["doctor"]);diff --git a/apps/cli/test/cli.ts b/apps/cli/test/cli.tsindex 5959b03..43c9348 100644--- a/apps/cli/test/cli.ts+++ b/apps/cli/test/cli.ts@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";import { join } from "node:path";export const testInDocker = process.env.JEVGREP_TEST_IN_DOCKER === "1" ? test : test.skip;+export { posix, testIfDockerPosix as testInDockerPosix } from "../../../test/helpers/docker";export async function withCli(runTest: (context: {diff --git a/apps/cli/test/process.test.ts b/apps/cli/test/process.test.tsindex 187c0e9..4b1d6cd 100644--- a/apps/cli/test/process.test.ts+++ b/apps/cli/test/process.test.ts@@ -4,13 +4,13 @@ import { join } from "node:path";import { execFile } from "node:child_process";import { promisify } from "node:util";import { fileURLToPath } from "node:url";-import { testInDocker, withCli } from "./cli";+import { testInDockerPosix, withCli } from "./cli";const execute = promisify(execFile);const cli =process.env.JEVGREP_TEST_CLI ?? fileURLToPath(new URL("../dist/bin/index.js", import.meta.url));-testInDocker("a closed stdout pipe exits quietly", async () => {+testInDockerPosix("a closed stdout pipe exits quietly", async () => {await withCli(async ({ home }) => {const { stdout } = await execute("python3",@@ -38,7 +38,7 @@ finally:});});-testInDocker("interactive auth hides input and exits 130 on interruption", async () => {+testInDockerPosix("interactive auth hides input and exits 130 on interruption", async () => {await withCli(async ({ home }) => {for (const mode of ["save",diff --git a/packages/core/test-node/provider-protocol.mjs b/packages/core/test-node/provider-protocol.mjsindex 5bf0653..55370e0 100644--- a/packages/core/test-node/provider-protocol.mjs+++ b/packages/core/test-node/provider-protocol.mjs@@ -189,7 +189,6 @@ test("routing rejects unknown destinations before HTTP", async (t) => {test("Node preload routes SDK-shaped fetches and rejects any other host", async (t) => {const { execFile } = await import("node:child_process");const { promisify } = await import("node:util");- const { fileURLToPath } = await import("node:url");const run = promisify(execFile);const bodies = [];const http = await fixture(t, async (req, res) => {@@ -198,9 +197,8 @@ test("Node preload routes SDK-shaped fetches and rejects any other host", asyncbodies.push(Buffer.concat(chunks).toString());res.end("fixture-ok");});- const preload = fileURLToPath(- new URL("../../../test/fixtures/provider-route.mjs", import.meta.url),- );+ // --import takes a URL; a bare Windows path such as C:\... is rejected as scheme "c:".+ const preload = new URL("../../../test/fixtures/provider-route.mjs", import.meta.url).href;const options = { env: { JEVGREP_TEST_PROVIDER_ORIGIN: http.origin }, timeout: 5000 };const args = ["--import", preload, "--input-type=module", "-e"];const result = await run(diff --git a/packages/core/test/cache.test.ts b/packages/core/test/cache.test.tsindex 101316e..f6eeb6c 100644--- a/packages/core/test/cache.test.ts+++ b/packages/core/test/cache.test.ts@@ -1,4 +1,4 @@-import { testIfDocker as test } from "../../../test/helpers/docker";+import { posix, testIfDocker as test } from "../../../test/helpers/docker";import { afterEach, expect } from "bun:test";import {mkdtemp,@@ -53,8 +53,10 @@ test("exact requests reuse numeric answers without persisting source or credentiexpect(saved).not.toContain("SOURCE_SENTINEL");expect(saved).not.toContain("source.ts");expect(saved).not.toContain("API_KEY_SENTINEL");- expect((await stat(join(dir, "entries", names[0]!))).mode & 0o777).toBe(0o600);- expect((await stat(dir)).mode & 0o777).toBe(0o700);+ if (posix) {+ expect((await stat(join(dir, "entries", names[0]!))).mode & 0o777).toBe(0o600);+ expect((await stat(dir)).mode & 0o777).toBe(0o700);+ }expect(cache.stats()).toEqual({ hits: 1, misses: 1, issues: [] });});@@ -127,15 +129,17 @@ test("corrupt, incompatible and unreadable entries degrade to counted misses", aexpect(await cache.get(input)).toBeUndefined();}await cache.put(input, { question1: 0.2 });- await chmod(file, 0);- try {- expect(await cache.get(input)).toBeUndefined();- } finally {- await chmod(file, 0o600);+ if (posix) {+ await chmod(file, 0);+ try {+ expect(await cache.get(input)).toBeUndefined();+ } finally {+ await chmod(file, 0o600);+ }}expect(cache.stats().issues).toEqual([{ kind: "cache_corrupt", count: 3 },- { kind: "cache_unavailable", count: 1 },+ ...(posix ? [{ kind: "cache_unavailable", count: 1 }] : []),]);expect(await cache.get(input)).toEqual({ question1: 0.2 });});diff --git a/packages/core/test/filesystem.test.ts b/packages/core/test/filesystem.test.tsindex 0a66ebf..3f163f8 100644--- a/packages/core/test/filesystem.test.ts+++ b/packages/core/test/filesystem.test.ts@@ -1,4 +1,4 @@-import { testIfDocker as test } from "../../../test/helpers/docker";+import { posix, testIfDocker as test } from "../../../test/helpers/docker";import { afterEach, expect, spyOn } from "bun:test";import { mkdtemp, mkdir, writeFile, rm, symlink, chmod, open, utimes } from "node:fs/promises";import { tmpdir } from "node:os";@@ -86,7 +86,7 @@ test("pages advance past excluded entries, preserve unusual names, and release cskip1: "excluded",skip2: "excluded","a.ts": "a",- "line\nbreak.ts": "b",+ ...(posix ? { "line\nbreak.ts": "b" } : {}),"last.ts": "c",});const reader = await createFilesystem({ root, limits: { pageSize: 1, maxOpenDirectories: 1 } });@@ -99,7 +99,7 @@ test("pages advance past excluded entries, preserve unusual names, and release cnames.push(...page.entries.map((entry) => entry.path));cursor = page.nextCursor;} while (cursor);- expect(names.sort()).toEqual(["a.ts", "last.ts", "line\nbreak.ts"]);+ expect(names.sort()).toEqual(["a.ts", "last.ts", ...(posix ? ["line\nbreak.ts"] : [])]);expect((await reader.listPage()).issues).toEqual([]);} finally {await reader.close();@@ -221,25 +221,29 @@ test("exclude patterns only narrow eligibility, even with --no-ignore and repositest("root normalization does not follow descendant links or special files and permission errors stay issues", async () => {const root = await fixture({ visible: "ok", unreadable: "unreadable sentinel" });const outside = await fixture({ outside: "OUTSIDE_SENTINEL" });- await symlink(outside, join(root, "escape"));- await symlink(root, join(root, "cycle"));- await chmod(join(root, "unreadable"), 0);- const fifo = Bun.spawnSync(["mkfifo", join(root, "pipe")]);- expect(fifo.exitCode).toBe(0);+ // POSIX ignores the type; Windows junctions need no symlink privilege.+ await symlink(outside, join(root, "escape"), "junction");+ await symlink(root, join(root, "cycle"), "junction");+ if (posix) {+ await chmod(join(root, "unreadable"), 0);+ const fifo = Bun.spawnSync(["mkfifo", join(root, "pipe")]);+ expect(fifo.exitCode).toBe(0);+ }const reader = await createFilesystem({ root });try {for (const path of ["escape/outside","cycle/visible",- "pipe",+ ...(posix ? ["pipe"] : []),"../outside",join(outside, "outside"),])expect(await reader.readSnapshot(path)).toMatchObject({ status: "excluded" });- expect(await reader.readSnapshot("unreadable")).toMatchObject({- status: "issue",- issue: { kind: "unreadable" },- });+ if (posix)+ expect(await reader.readSnapshot("unreadable")).toMatchObject({+ status: "issue",+ issue: { kind: "unreadable" },+ });expect(await reader.readSnapshot("visible")).toMatchObject({ status: "ok" });} finally {await reader.close();diff --git a/packages/core/test/storage.test.ts b/packages/core/test/storage.test.tsnew file mode 100644index 0000000..8abf1d3--- /dev/null+++ b/packages/core/test/storage.test.ts@@ -0,0 +1,35 @@+import { expect, test } from "bun:test";+import { homedir } from "node:os";+import { join } from "node:path";+import { storageDirectory } from "../src/storage";++test("XDG locations win on every platform", () => {+ const env = { XDG_CONFIG_HOME: "/xdg/config", XDG_CACHE_HOME: "/xdg/cache", APPDATA: "/roaming" };+ for (const platform of ["linux", "darwin", "win32"] as const) {+ expect(storageDirectory("config", env, platform)).toBe(join("/xdg/config", "jevgrep"));+ expect(storageDirectory("cache", env, platform)).toBe(join("/xdg/cache", "jevgrep"));+ }+});++test("Windows uses APPDATA for config and LOCALAPPDATA for cache", () => {+ const env = { APPDATA: "/roaming", LOCALAPPDATA: "/local" };+ expect(storageDirectory("config", env, "win32")).toBe(join("/roaming", "jevgrep"));+ expect(storageDirectory("cache", env, "win32")).toBe(join("/local", "jevgrep"));+});++test("Windows falls back to the profile AppData folders when the variables are unset", () => {+ expect(storageDirectory("config", {}, "win32")).toBe(+ join(homedir(), "AppData", "Roaming", "jevgrep"),+ );+ expect(storageDirectory("cache", {}, "win32")).toBe(+ join(homedir(), "AppData", "Local", "jevgrep"),+ );+});++test("macOS and Linux keep the XDG defaults and ignore Windows variables", () => {+ const env = { APPDATA: "/roaming", LOCALAPPDATA: "/local" };+ for (const platform of ["linux", "darwin"] as const) {+ expect(storageDirectory("config", env, platform)).toBe(join(homedir(), ".config", "jevgrep"));+ expect(storageDirectory("cache", env, platform)).toBe(join(homedir(), ".cache", "jevgrep"));+ }+});diff --git a/test/discovery.test.ts b/test/discovery.test.tsindex 9702053..bc4777c 100644--- a/test/discovery.test.ts+++ b/test/discovery.test.ts@@ -4,7 +4,7 @@ import { expect } from "bun:test";import { mkdtemp, mkdir, writeFile, rm, chmod } from "node:fs/promises";import { join } from "node:path";import { tmpdir } from "node:os";-import { testIfDocker } from "./helpers/docker";+import { testIfDocker, testIfDockerPosix } from "./helpers/docker";import { retrieve } from "../packages/core/src/retrieve";import { createEvaluator, EvaluationFailure } from "../packages/core/src/evaluator";import { renderResult } from "../apps/cli/src/render";@@ -707,7 +707,7 @@ testIfDocker(120_000,);-testIfDocker(+testIfDockerPosix("unavailable directory previews are skipped rather than classified as empty metadata",async () => {const root = await mkdtemp(join(tmpdir(), "jg-preview-unavailable-"));diff --git a/test/helpers/docker.ts b/test/helpers/docker.tsindex 12862c5..e51b2a8 100644--- a/test/helpers/docker.ts+++ b/test/helpers/docker.ts@@ -1,2 +1,5 @@import { test } from "bun:test";export const testIfDocker = process.env.JEVGREP_TEST_IN_DOCKER === "1" ? test : test.skip;+/** Windows lacks POSIX modes, chmod 0 denial, FIFOs, pty and newline filenames; those fixtures are POSIX-only. */+export const posix = process.platform !== "win32";+export const testIfDockerPosix = posix ? testIfDocker : test.skip;