git.iko.soy/rowtype-yoga/purescript-yoga-om-layer
on v1.1.1 help sign in
99 lines 2.5 kB history raw
1#!/usr/bin/env bash
2set -e
4echo "Testing custom error messages..."
5echo ""
7WORKSPACE_ROOT="/Users/mark/Developer/purescript-yoga-om"
8PACKAGE_DIR="$WORKSPACE_ROOT/packages/yoga-om-layer"
9TEST_DIR="$PACKAGE_DIR/test-negative"
10SRC_DIR="$PACKAGE_DIR/src"
12if [ ! -d "$TEST_DIR" ]; then
13 echo "❌ Test directory not found: $TEST_DIR"
14 exit 1
15fi
17passed=0
18failed=0
20# First, ensure the main package compiles (without negative tests)
21echo "Building main package..."
22cd "$WORKSPACE_ROOT"
23if ! bunx spago build -p yoga-om-layer > /dev/null 2>&1; then
24 echo "❌ Main package failed to build"
25 exit 1
26fi
27echo "✓ Main package builds successfully"
28echo ""
30# Now test each negative test individually
31for test_file in "$TEST_DIR"/*.purs; do
32 if [ ! -f "$test_file" ]; then
33 continue
34 fi
36 base_name=$(basename "$test_file" .purs)
37 expected_file="$TEST_DIR/$base_name.expected"
39 if [ ! -f "$expected_file" ]; then
40 echo "⚠️ No .expected file for $base_name, skipping"
41 continue
42 fi
44 expected_content=$(cat "$expected_file")
46 echo -n "Testing $base_name... "
48 # Compile this specific test file with the already-built package
49 # First ensure output exists
50 if [ ! -d "$WORKSPACE_ROOT/output" ]; then
51 echo "❌ Output directory not found, run 'npx spago build' first"
52 exit 1
53 fi
55 error_output=$(cd "$WORKSPACE_ROOT" && \
56 bunx purs compile \
57 "$test_file" \
58 "$SRC_DIR/**/*.purs" \
59 "packages/yoga-om-core/src/**/*.purs" \
60 "output/**/*.js" \
61 2>&1 || true)
63 # Special case: should compile successfully
64 if [ "$expected_content" = "SHOULD_COMPILE" ]; then
65 if echo "$error_output" | grep -q "Error"; then
66 echo "❌ (should compile but doesn't)"
67 echo "$error_output" | head -20
68 ((failed++))
69 else
70 echo "✅ (compiles as expected)"
71 ((passed++))
72 fi
73 continue
74 fi
76 # Check if expected error appears in output
77 if echo "$error_output" | grep -q "$expected_content"; then
78 echo "✅"
79 ((passed++))
80 else
81 echo "❌"
82 echo "Expected to find:"
83 echo "$expected_content"
84 echo ""
85 echo "But got:"
86 echo "$error_output" | grep -A 10 "Error" | head -20
87 echo ""
88 ((failed++))
89 fi
90done
92echo ""
93echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
94echo "Results: $passed passed, $failed failed"
95echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
97if [ $failed -gt 0 ]; then
98 exit 1
99fi