|
| 1 | +#!/bin/bash |
| 2 | +# Test Vim integration |
| 3 | +# Usage: test-vim.sh |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 8 | +EXAMPLES_DIR="$SCRIPT_DIR/../examples" |
| 9 | + |
| 10 | +echo "=== Testing Vim integration ===" |
| 11 | + |
| 12 | +# Test 1: Check if vim is available |
| 13 | +echo "" |
| 14 | +echo "--- Test 1: Check Vim availability ---" |
| 15 | +if command -v vim &> /dev/null; then |
| 16 | + VERSION=$(vim --version | head -1) |
| 17 | + echo "Vim: $VERSION" |
| 18 | + echo "PASS: Vim available" |
| 19 | +else |
| 20 | + echo "FAIL: Vim not installed" |
| 21 | + exit 1 |
| 22 | +fi |
| 23 | + |
| 24 | +# Test 2: Check Vim config exists |
| 25 | +echo "" |
| 26 | +echo "--- Test 2: Check Vim config ---" |
| 27 | +CONFIG_PATH="$HOME/.vimrc" |
| 28 | +if [ -f "$CONFIG_PATH" ]; then |
| 29 | + grep -q "syntax on" "$CONFIG_PATH" && echo "PASS: Vim syntax highlighting enabled" || echo "WARN: syntax highlighting not configured" |
| 30 | + grep -q "filetype plugin indent on" "$CONFIG_PATH" && echo "PASS: Vim filetype detection enabled" || echo "WARN: filetype detection not configured" |
| 31 | +else |
| 32 | + echo "WARN: Vim config not found at $CONFIG_PATH" |
| 33 | +fi |
| 34 | + |
| 35 | +# Test 3: Test Vim can start and exit cleanly |
| 36 | +echo "" |
| 37 | +echo "--- Test 3: Test Vim startup ---" |
| 38 | +vim -es -c 'quit' 2>&1 || { echo "FAIL: Vim failed to start"; exit 1; } |
| 39 | +echo "PASS: Vim starts and exits cleanly" |
| 40 | + |
| 41 | +# Test 4: Test opening an OCaml file |
| 42 | +echo "" |
| 43 | +echo "--- Test 4: Test opening OCaml file ---" |
| 44 | +cd "$EXAMPLES_DIR/hello" |
| 45 | +vim -es hello.ml -c 'quit' 2>&1 || { echo "FAIL: Vim failed to open OCaml file"; exit 1; } |
| 46 | +echo "PASS: Vim can open OCaml files" |
| 47 | + |
| 48 | +echo "" |
| 49 | +echo "=== Vim tests completed ===" |
0 commit comments