test-brew-manual.shโข2.7 kB
#!/bin/bash
set -euo pipefail
echo "๐งช Testing Homebrew formula manually with local binary..."
# Create a temporary directory for our test tap
TEST_TAP_DIR="/tmp/homebrew-test-tap"
rm -rf "$TEST_TAP_DIR"
mkdir -p "$TEST_TAP_DIR/Formula"
# Build the binary if not already built
if [ ! -f "target/release/ht-mcp" ]; then
echo "๐จ Building release binary..."
cargo build --release
fi
# Create a local file URL for the binary
BINARY_PATH="$(pwd)/target/release/ht-mcp"
BINARY_SHA=$(shasum -a 256 "$BINARY_PATH" | cut -d' ' -f1)
echo "๐ Creating test formula with local binary..."
cat > "$TEST_TAP_DIR/Formula/ht-mcp.rb" << EOF
class HtMcp < Formula
desc "Headless Terminal MCP Server - Control terminal sessions via Model Context Protocol"
homepage "https://github.com/memextech/ht-mcp"
version "0.1.3-test-local"
url "file://$BINARY_PATH"
sha256 "$BINARY_SHA"
def install
bin.install "ht-mcp"
end
test do
# Test that the binary exists and shows help
assert_match "Pure Rust MCP server", shell_output("#{bin}/ht-mcp --help 2>&1")
end
end
EOF
echo "โ
Formula created!"
echo "๐ Formula content:"
cat "$TEST_TAP_DIR/Formula/ht-mcp.rb"
echo ""
# Check if we can add this tap
echo "๐ง Adding temporary tap..."
if brew tap-new test/local || true; then
echo "Tap created or already exists"
fi
# Copy our formula to the tap
LOCAL_TAP_DIR="$(brew --repository)/Library/Taps/test/homebrew-local"
if [ -d "$LOCAL_TAP_DIR" ]; then
cp "$TEST_TAP_DIR/Formula/ht-mcp.rb" "$LOCAL_TAP_DIR/Formula/"
echo "โ
Formula copied to local tap"
echo "๐งช Testing formula installation..."
# Uninstall if already installed
brew uninstall test/local/ht-mcp 2>/dev/null || true
# Install from our local tap
if brew install test/local/ht-mcp; then
echo "โ
Installation successful!"
echo "๐งช Testing installed binary..."
if ht-mcp --help | grep -q "Pure Rust MCP server"; then
echo "โ
Binary test successful!"
else
echo "โ Binary test failed"
exit 1
fi
echo "๐งช Running brew test..."
if brew test test/local/ht-mcp; then
echo "โ
Brew test successful!"
else
echo "โ Brew test failed"
exit 1
fi
echo ""
echo "๐ ALL TESTS PASSED!"
echo "โ
Homebrew formula works correctly"
echo ""
echo "Clean up with: brew uninstall test/local/ht-mcp && brew untap test/local"
else
echo "โ Installation failed"
exit 1
fi
else
echo "โ Could not create local tap directory"
exit 1
fi