-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-parallel-debug.ts
More file actions
64 lines (51 loc) · 1.98 KB
/
test-parallel-debug.ts
File metadata and controls
64 lines (51 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bun
import { $ } from "bun";
async function testParallel() {
console.log("🔍 Testing parallel execution debug...\n");
// Build the exact command that parallel script would use
const command = "claude";
const args = ["--dangerously-skip-permissions", "hello world in python"];
console.log("Command:", command);
console.log("Args:", args);
console.log("Full command:", `${command} ${args.join(" ")}`);
// Test with environment variable
process.env.ANTHROPIC_MODEL = "claude-3-5-sonnet-20241022";
try {
console.log("\n📝 Test 1: Direct shell execution");
const result1 = await $`${command} ${args}`.text();
console.log("✅ Success:", result1.substring(0, 100));
} catch (e: any) {
console.error("❌ Failed:", e);
console.error("Exit code:", e.exitCode);
console.error("Stderr:", e.stderr?.toString());
console.error("Stdout:", e.stdout?.toString());
}
try {
console.log("\n📝 Test 2: Shell with joined string");
const fullCmd = `${command} ${args.join(" ")}`;
const result2 = await $`sh -c ${fullCmd}`.text();
console.log("✅ Success:", result2.substring(0, 100));
} catch (e: any) {
console.error("❌ Failed:", e);
}
// Test tmux session
try {
console.log("\n📝 Test 3: Tmux session");
const sessionName = "test-claude";
// Kill any existing session
await $`tmux kill-session -t ${sessionName}`.quiet().nothrow();
// Create new session
const fullCmd = `${command} ${args.join(" ")}`;
await $`tmux new-session -d -s ${sessionName} "${fullCmd}"`.quiet();
console.log("Session created, waiting...");
await Bun.sleep(3000);
// Get output
const output = await $`tmux capture-pane -t ${sessionName} -p`.text();
console.log("Output:", output);
// Kill session
await $`tmux kill-session -t ${sessionName}`.quiet();
} catch (e: any) {
console.error("❌ Tmux failed:", e.message);
}
}
testParallel().catch(console.error);