|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 5 | +run_dir="$(mktemp -d)" |
| 6 | +active_pid="" |
| 7 | + |
| 8 | +cleanup() { |
| 9 | + if [[ -n "$active_pid" ]] && kill -0 "$active_pid" 2>/dev/null; then |
| 10 | + kill "$active_pid" 2>/dev/null || true |
| 11 | + wait "$active_pid" 2>/dev/null || true |
| 12 | + fi |
| 13 | + rm -rf "$run_dir" |
| 14 | +} |
| 15 | +trap cleanup EXIT |
| 16 | + |
| 17 | +mvn -q -f "$repo_dir/pom.xml" \ |
| 18 | + -Pruntime-examples \ |
| 19 | + -pl examples/conformance,examples/school-management \ |
| 20 | + -am package -DskipTests |
| 21 | + |
| 22 | +run_example() { |
| 23 | + local name="$1" |
| 24 | + local jar="$2" |
| 25 | + local marker="$3" |
| 26 | + local log="$run_dir/$name.log" |
| 27 | + local database="$run_dir/$name.db" |
| 28 | + |
| 29 | + java -jar "$jar" \ |
| 30 | + "--spring.datasource.url=jdbc:sqlite:$database" \ |
| 31 | + --server.port=0 >"$log" 2>&1 & |
| 32 | + active_pid=$! |
| 33 | + |
| 34 | + for _ in $(seq 1 240); do |
| 35 | + if grep -Fq "$marker" "$log"; then |
| 36 | + kill "$active_pid" 2>/dev/null || true |
| 37 | + wait "$active_pid" 2>/dev/null || true |
| 38 | + active_pid="" |
| 39 | + printf 'PASS %s\n' "$name" |
| 40 | + return 0 |
| 41 | + fi |
| 42 | + if ! kill -0 "$active_pid" 2>/dev/null; then |
| 43 | + wait "$active_pid" || true |
| 44 | + active_pid="" |
| 45 | + printf 'FAIL %s exited before its acceptance marker\n' "$name" >&2 |
| 46 | + sed -n '1,240p' "$log" >&2 |
| 47 | + return 1 |
| 48 | + fi |
| 49 | + sleep 0.25 |
| 50 | + done |
| 51 | + |
| 52 | + printf 'FAIL %s did not emit its acceptance marker within 60 seconds\n' "$name" >&2 |
| 53 | + sed -n '1,240p' "$log" >&2 |
| 54 | + return 1 |
| 55 | +} |
| 56 | + |
| 57 | +run_example \ |
| 58 | + "conformance" \ |
| 59 | + "$repo_dir/examples/conformance/target/deploy/runtime-example-conformance-service-0.0.1-SNAPSHOT.jar" \ |
| 60 | + "PASS Java minimum runtime conformance: 8/8" |
| 61 | + |
| 62 | +run_example \ |
| 63 | + "school-management" \ |
| 64 | + "$repo_dir/examples/school-management/target/deploy/school-management-service-0.0.1-SNAPSHOT.jar" \ |
| 65 | + "PASS Java School bootstrap, portable Query, and native SQLite Facet parity" |
| 66 | + |
| 67 | +printf 'PASS Java runtime examples: 2/2\n' |
0 commit comments