#!/bin/sh # build smoke: `jolt build` compiles a multi-namespace app (macro + cross-ns + # clojure.string) into a standalone binary, which then runs with no jolt source # or Chez install on the path — args reach -main, output matches. root="$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)" cd "$root" app="$root/test/chez/build-app" out="$(mktemp -d)/app-bin" trap 'rm -rf "$(dirname "$out")"' EXIT echo "build smoke: compiling app.core -> $out" if ! JOLT_PWD="$app" bin/joltc build -m app.core -o "$out" >/dev/null 2>&1; then echo " FAIL: jolt build exited non-zero" exit 1 fi [ -x "$out" ] || { echo " FAIL: no executable produced"; exit 1; } # Run from a neutral cwd with args; check the three output lines. got="$(cd / && "$out" alpha bb ccc 2>&1)" want='HELLO FROM A BUILT BINARY! HELLO FROM A BUILT BINARY! args: [alpha bb ccc] sum: 10' if [ "$got" != "$want" ]; then echo " FAIL: binary output mismatch" echo "--- want ---"; echo "$want" echo "--- got ----"; echo "$got" exit 1 fi # Optimized mode (inference + flatten + scalar-replace) must produce the same # result — a sanity check that the passes don't miscompile this app. if ! JOLT_PWD="$app" bin/joltc build -m app.core -o "$out" --opt >/dev/null 2>&1; then echo " FAIL: jolt build --opt exited non-zero"; exit 1 fi got_opt="$(cd / && "$out" alpha bb ccc 2>&1)" if [ "$got_opt" != "$want" ]; then echo " FAIL: --opt binary output mismatch" echo "--- got ----"; echo "$got_opt" exit 1 fi echo "build smoke: passed (release + optimized)"