pi-ext
bugabingas pi extensions
owned by bugabinga
fix: support Termux test execution
4b7df8ec3264b6346e043c24984a69200e1200d1
Oliver Jan Krylow <oliver@bugabinga.net> ·
SSH signature · not checked
Browse filesCompare with HEAD
Changed files (6)
extensions/git-safe/__tests__/harness.test.ts
Modified 31 33 return path.
resolve(
import.
meta.dirname,
"../../rtk/index.ts");
36 +function bashShebang()
: string {
37 + if (
process.
platform === "win32")
return "#!/usr/bin/env bash";
38 + const candidates
= [
40 + ...(
process.
env.PATH
?? "")
41 + .
split(path.delimiter)
43 + .
map((directory)
=> path.
join(directory,
"bash")),
46 + for (
const candidate
of candidates) {
47 + if (
!candidate
|| path.
basename(candidate)
!== "bash")
continue;
49 + accessSync(candidate, constants.X_OK);
50 + return `#!${candidate}`;
53 + throw new Error(
"bash executable not found");
34 56 function installFakeGit(root
: string)
: { bin
: string; executable
: string } {
35 57 const bin
= path.
join(
root,
"fake-bin");
83 - "#!/usr/bin/env bash",
84 106 "if [[ \"$*\" == '--list-cmds=builtins' ]]; then printf 'status\\n'; exit 0; fi",
85 107 "if [[ \"$*\" == *'config --get alias.'* ]]; then exit 1; fi",
86 108 "printf 'FAKE_GIT\\n'",
103 - "#!/usr/bin/env bash",
104 126 "if [[ \"$1\" == '--version' ]]; then printf 'rtk 0.42.4\\n'; exit 0; fi",
105 127 "if [[ \"$1\" == 'rewrite' && \"$2\" == 'git commit --no-verify' ]]; then printf 'rtk git commit --no-verify\\n'; exit 0; fi",
106 128 "if [[ \"$1\" == 'rewrite' && \"$2\" == 'git status' ]]; then printf 'rtk git status\\n'; exit 0; fi",
226 248 await expectRejected(command);
230 252 it(
"rejects temporary aliases that create no-verify inside Git",
async ()
=> {
231 253 await startWithFakeGit();
323 345 expect(result.output, command).
toContain(
"FAKE_GIT");
328 350 it(
"blocks literal command-git bypasses before execution",
async ()
=> {
329 351 await startWithFakeGit();
extensions/git-safe/__tests__/spawn.test.ts
Modified17 17 const result
= await spawnWithTimeout(
19 19 [
"-e",
"process.stdout.write(process.env.GIT_TERMINAL_PROMPT ?? '')"],
23 23 expect(result).
toMatchObject({ stdout:
"0", code:
0, killed:
false });
extensions/nu-bang/__tests__/real-world-full.test.ts
Modified325 325 test(
"shows nu's native delimiter diagnostics",
async ()
=> {
326 326 const result
= await run(
"[1 2 3");
327 327 expect(result.exitCode).
toBe(
1);
328 - expect(result.output).
toContain(
"Unexpected end of code");
328 + expect(result.output).
toContain(
"Unclosed delimiter");
331 331 test(
"reports a missing working directory clearly",
async ()
=> {
extensions/the-system/__tests__/the-system.test.ts
Modified382 382 args: [
"file.md"],
386 + editorCandidates(
"file.md", { TERMUX_VERSION:
"0.118" },
"android").
at(
0),
388 + command:
"termux-open",
extensions/the-system/open-editor.ts
Modified 35 35 .
map((item)
=> ({
...item, args: [
...item.args, file], wait:
true }));
36 - return [
...configured,
...platformCandidates(file, platform)];
36 + return [
...configured,
...platformCandidates(file, env, platform)];
39 39 export function parseEditorCommand(
48 48 function platformCandidates(
50 + env
: NodeJS.
ProcessEnv,
50 51 platform
: NodeJS.
Platform,
51 52 )
: EditorCandidate[] {
52 - if (
process.
env.TERMUX_VERSION)
53 + if (platform
=== "android" && env.TERMUX_VERSION)
53 54 return [{ command:
"termux-open", args: [file], wait:
false }];
54 55 if (platform
=== "darwin")
55 56 return [{ command:
"open", args: [
"-t", file], wait:
false }];
extensions/tune/__tests__/remaining.test.ts
Modified 1 1 import * as fs
from "node:fs";
2 +import { tmpdir }
from "node:os";
2 3 import * as path
from "node:path";
3 -import { afterEach, beforeAll, describe, expect, it }
from "vitest";
4 +import { afterAll, afterEach, beforeAll, describe, expect, it }
from "vitest";
5 6 buildTuneCompactionSummary,
10 11 import { reconstructJsonlState }
from "../jsonl.ts";
11 12 import { resolveTuneShortcuts }
from "../shortcuts.ts";
13 -const TESTDIR
= "/tmp/pi-ext-20260530-164209-project";
14 -const LOCK_TESTDIR
= "/tmp/pi-ext-tune-lock";
14 +const TESTDIR
= fs.
mkdtempSync(path.
join(
tmpdir(),
"pi-ext-tune-"));
15 +const LOCK_TESTDIR
= path.
join(TESTDIR,
"lock");
17 18 '{"type":"config","name":"Optimize sqrt/sin loop","metricName":"total_ms","metricUnit":"ms","bestDirection":"lower"}',
32 33 fs.
rmSync(LOCK_TESTDIR, { recursive:
true, force:
true });
37 + fs.
rmSync(TESTDIR, { recursive:
true, force:
true });
37 42 describe(
"compaction resume", ()
=> {