|
| 1 | +#!/usr/bin/env bash |
| 2 | +# SPDX-License-Identifier: PMPL-1.0-or-later |
| 3 | +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> |
| 4 | +# |
| 5 | +# tests/e2e.sh — End-to-end structural and pipeline validation for vql-ut (VCL-total). |
| 6 | +# |
| 7 | +# Validates: |
| 8 | +# 1. Required structural files exist (Cargo.toml, README, grammar, spec) |
| 9 | +# 2. Source layout follows expected structure |
| 10 | +# 3. Cargo build succeeds |
| 11 | +# 4. Full Rust test suite (unit + integration + property + e2e) passes |
| 12 | +# 5. Key VCL-total examples round-trip through format → lint |
| 13 | +# |
| 14 | +# Usage: |
| 15 | +# bash tests/e2e.sh # run all checks |
| 16 | +# E2E_BUILD=0 bash tests/e2e.sh # skip build (structural only) |
| 17 | + |
| 18 | +set -euo pipefail |
| 19 | + |
| 20 | +RED='\033[0;31m' |
| 21 | +GREEN='\033[0;32m' |
| 22 | +YELLOW='\033[1;33m' |
| 23 | +CYAN='\033[0;36m' |
| 24 | +NC='\033[0m' |
| 25 | + |
| 26 | +PASSED=0 |
| 27 | +FAILED=0 |
| 28 | +SKIPPED=0 |
| 29 | + |
| 30 | +check() { |
| 31 | + local desc="$1" |
| 32 | + local result="$2" |
| 33 | + if [ "$result" = "0" ]; then |
| 34 | + echo -e " ${GREEN}PASS${NC} $desc" |
| 35 | + PASSED=$((PASSED + 1)) |
| 36 | + else |
| 37 | + echo -e " ${RED}FAIL${NC} $desc" |
| 38 | + FAILED=$((FAILED + 1)) |
| 39 | + fi |
| 40 | +} |
| 41 | + |
| 42 | +skip() { |
| 43 | + echo -e " ${YELLOW}SKIP${NC} $1" |
| 44 | + SKIPPED=$((SKIPPED + 1)) |
| 45 | +} |
| 46 | + |
| 47 | +echo -e "${CYAN}=== VCL-total (vql-ut) E2E Validation ===${NC}" |
| 48 | +echo "" |
| 49 | + |
| 50 | +# ── Category 1: Required structural files ────────────────────────────────── |
| 51 | +echo "Category 1: Structural files" |
| 52 | + |
| 53 | +check "Cargo.toml exists" "$([ -f Cargo.toml ] && echo 0 || echo 1)" |
| 54 | +check "README.adoc exists" "$([ -f README.adoc ] && echo 0 || echo 1)" |
| 55 | +check "EXPLAINME.adoc exists" "$([ -f EXPLAINME.adoc ] && echo 0 || echo 1)" |
| 56 | +check "SECURITY.md exists" "$([ -f SECURITY.md ] && echo 0 || echo 1)" |
| 57 | +check "LICENSE exists" "$([ -f LICENSE ] && echo 0 || echo 1)" |
| 58 | +check "SPDX header in Cargo.toml" "$(grep -q 'SPDX-License-Identifier' Cargo.toml && echo 0 || echo 1)" |
| 59 | +echo "" |
| 60 | + |
| 61 | +# ── Category 2: Source layout ────────────────────────────────────────────── |
| 62 | +echo "Category 2: Source layout" |
| 63 | + |
| 64 | +check "src/ directory exists" "$([ -d src ] && echo 0 || echo 1)" |
| 65 | +check "src/lib.rs exists" "$([ -f src/lib.rs ] && echo 0 || echo 1)" |
| 66 | +check "tests/ directory exists" "$([ -d tests ] && echo 0 || echo 1)" |
| 67 | +check "tests/e2e_test.rs exists" "$([ -f tests/e2e_test.rs ] && echo 0 || echo 1)" |
| 68 | +check "tests/integration_test.rs exists" "$([ -f tests/integration_test.rs ] && echo 0 || echo 1)" |
| 69 | +check "tests/property_test.rs exists" "$([ -f tests/property_test.rs ] && echo 0 || echo 1)" |
| 70 | +check ".machine_readable/ exists" "$([ -d .machine_readable ] && echo 0 || echo 1)" |
| 71 | +echo "" |
| 72 | + |
| 73 | +# ── Category 3: VCL-total artefacts ─────────────────────────────────────── |
| 74 | +echo "Category 3: VCL-total artefacts" |
| 75 | + |
| 76 | +check "arcvix paper (arXiv source) exists" "$([ -f arcvix-10-level-query-safety.tex ] && echo 0 || echo 1)" |
| 77 | +check "examples/ directory has content" "$([ -d examples ] && ls examples/*.vcl 2>/dev/null | head -1 | grep -q . && echo 0 || echo 1)" |
| 78 | +check "features/ directory exists" "$([ -d features ] && echo 0 || echo 1)" |
| 79 | +check "verification/ directory exists" "$([ -d verification ] && echo 0 || echo 1)" |
| 80 | +echo "" |
| 81 | + |
| 82 | +# ── Category 4: Build ────────────────────────────────────────────────────── |
| 83 | +echo "Category 4: Build" |
| 84 | + |
| 85 | +if [ "${E2E_BUILD:-1}" = "0" ]; then |
| 86 | + skip "Build check skipped (E2E_BUILD=0)" |
| 87 | +else |
| 88 | + cargo build --release 2>/dev/null |
| 89 | + check "cargo build --release succeeds" "$?" |
| 90 | +fi |
| 91 | +echo "" |
| 92 | + |
| 93 | +# ── Category 5: Full test suite ──────────────────────────────────────────── |
| 94 | +echo "Category 5: Rust test suite" |
| 95 | + |
| 96 | +if [ "${E2E_BUILD:-1}" = "0" ]; then |
| 97 | + skip "Test suite skipped (E2E_BUILD=0)" |
| 98 | +else |
| 99 | + cargo test 2>/dev/null |
| 100 | + check "cargo test (all: unit + integration + property + e2e)" "$?" |
| 101 | +fi |
| 102 | +echo "" |
| 103 | + |
| 104 | +# ── Summary ──────────────────────────────────────────────────────────────── |
| 105 | +echo -e "${CYAN}=== Results: ${GREEN}${PASSED} passed${NC}, ${RED}${FAILED} failed${NC}, ${YELLOW}${SKIPPED} skipped${NC} ===" |
| 106 | +[ "$FAILED" -eq 0 ] |
0 commit comments