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
9 changes: 5 additions & 4 deletions scripts/diffex-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ if ($noEnv) {
Write-Host "Running without API keys..."
}

$tsxBin = Join-Path $repoRoot "node_modules/.bin/tsx.cmd"
if (-not (Test-Path -LiteralPath $tsxBin)) {
throw "tsx not found at $tsxBin. Run npm install from the repository root first."
$tsxLoader = Join-Path $repoRoot "node_modules/tsx/dist/loader.mjs"
if (-not (Test-Path -LiteralPath $tsxLoader)) {
throw "tsx not found at $tsxLoader. Run npm install from the repository root first."
}

$cliPath = Join-Path $repoRoot "packages/coding-agent/src/cli.ts"
& $tsxBin $cliPath @forwardArgs
$env:TSX_TSCONFIG_PATH = Join-Path $repoRoot "tsconfig.json"
& node --import $tsxLoader $cliPath @forwardArgs
$exitCode = $LASTEXITCODE
if ($exitCode -ne 0) {
exit $exitCode
Expand Down
3 changes: 2 additions & 1 deletion scripts/diffex-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ if [[ "$NO_ENV" == "true" ]]; then
echo "Running without API keys..."
fi

exec "$REPO_ROOT/node_modules/.bin/tsx" --tsconfig "$REPO_ROOT/tsconfig.json" "$REPO_ROOT/packages/coding-agent/src/cli.ts" ${ARGS[@]+"${ARGS[@]}"}
export TSX_TSCONFIG_PATH="$REPO_ROOT/tsconfig.json"
exec node --import "$REPO_ROOT/node_modules/tsx/dist/loader.mjs" "$REPO_ROOT/packages/coding-agent/src/cli.ts" ${ARGS[@]+"${ARGS[@]}"}
24 changes: 24 additions & 0 deletions scripts/diffex-test.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import test from "node:test";

const launcher = fileURLToPath(new URL("./diffex-test.sh", import.meta.url));

test("source launcher runs from another directory and forwards arguments", (t) => {
const root = mkdtempSync(join(tmpdir(), "diffex-launcher-test-"));
t.after(() => rmSync(root, { recursive: true, force: true }));
const result = spawnSync(launcher, ["--no-env", "--help"], {
cwd: root,
env: { ...process.env, DIFFEX_CODING_AGENT_DIR: join(root, "agent"), DIFFEX_OFFLINE: "1" },
encoding: "utf8",
timeout: 30_000,
});
assert.ifError(result.error);
assert.equal(result.status, 0, result.stderr);
assert.match(result.stdout, /^Running without API keys\.\.\.\nDiffex - AI coding assistant/m);
assert.match(result.stdout, /Usage:\n diffex \[options\]/);
});
Loading