Skip to content

Commit c6d62a2

Browse files
authored
test: use bun for mcp server mock (#95)
* test: launch mock server with shebang * chore(flake): remove node_modules install bun install all deps automatically * test: remove bun install * fix(test): use -S flag in shebang for Linux compatibility The shebang `#!/usr/bin/env bun run` works on macOS but fails on Linux because the `env` command doesn't split space-separated arguments by default. Using `#!/usr/bin/env -S bun run` makes env parse the string as multiple arguments, enabling cross-platform compatibility. Fixes CI failures where the mock server couldn't start due to: /usr/bin/env: 'bun run': No such file or directory
1 parent f5aca1e commit c6d62a2

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

flake.nix

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,6 @@
120120
uv sync --all-extras
121121
fi
122122
123-
# Install Node.js dependencies for MCP mock server (used in tests)
124-
if [ -f vendor/stackone-ai-node/package.json ]; then
125-
if [ ! -f vendor/stackone-ai-node/node_modules/.pnpm/lock.yaml ] || \
126-
[ vendor/stackone-ai-node/pnpm-lock.yaml -nt vendor/stackone-ai-node/node_modules/.pnpm/lock.yaml ]; then
127-
echo "📦 Installing MCP mock server dependencies..."
128-
(cd vendor/stackone-ai-node && pnpm install --frozen-lockfile)
129-
fi
130-
fi
131-
132123
# Install git hooks
133124
${config.pre-commit.installationScript}
134125
'';

tests/conftest.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import annotations
44

55
import os
6-
import shutil
76
import socket
87
import subprocess
98
import time
@@ -61,30 +60,16 @@ def test_mcp_integration(mcp_mock_server):
6160
if not vendor_dir.exists():
6261
pytest.skip("stackone-ai-node submodule not found. Run 'git submodule update --init'")
6362

64-
# Check for bun runtime
65-
bun_path = shutil.which("bun")
66-
if not bun_path:
67-
pytest.skip("bun not found. Install via Nix flake.")
68-
63+
# find port
6964
port = _find_free_port()
7065
base_url = f"http://localhost:{port}"
7166

72-
# Install dependencies if needed
73-
node_modules = vendor_dir / "node_modules"
74-
if not node_modules.exists():
75-
subprocess.run(
76-
[bun_path, "install"],
77-
cwd=vendor_dir,
78-
check=True,
79-
capture_output=True,
80-
)
81-
8267
# Start the server from project root
8368
env = os.environ.copy()
8469
env["PORT"] = str(port)
8570

8671
process = subprocess.Popen(
87-
[bun_path, "run", str(serve_script)],
72+
[str(serve_script)],
8873
cwd=project_root,
8974
env=env,
9075
stdout=subprocess.PIPE,

tests/mocks/serve.ts

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
#!/usr/bin/env -S bun run
12
/**
23
* Standalone HTTP server for MCP mock testing.
34
* Imports createMcpApp from stackone-ai-node vendor submodule.
45
*
56
* Usage:
7+
* ./tests/mocks/serve.ts [port]
8+
* # or
69
* bun run tests/mocks/serve.ts [port]
710
*/
811
import { Hono } from "hono";

0 commit comments

Comments
 (0)