| 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" |
| 5 | |
| 6 | FIXTURE_SRC_DIR="$1" |
| 7 | if [ -z "$FIXTURE_SRC_DIR" ]; then |
| 8 | # Default: the compiler's own test fixtures |
| 9 | FIXTURE_SRC_DIR="$REPO_ROOT/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures" |
| 10 | fi |
| 11 | |
| 12 | # Parse source files into JSON in a temp directory |
| 13 | TMPDIR="$(mktemp -d)" |
| 14 | trap 'rm -rf "$TMPDIR"' EXIT |
| 15 | |
| 16 | echo "Parsing fixtures from $FIXTURE_SRC_DIR..." |
| 17 | node "$REPO_ROOT/compiler/scripts/babel-ast-to-json.mjs" "$FIXTURE_SRC_DIR" "$TMPDIR" |
| 18 | |
| 19 | # Bump the default 8 MiB Rust thread stack to 32 MiB. The round_trip test |
| 20 | # walks deeply-nested Babel AST fixtures via recursive serde Visitor; some |
| 21 | # fixtures exceed the default stack on Linux CI runners. RUST_MIN_STACK only |
| 22 | # affects threads spawned via std::thread (which is how the libtest harness |
| 23 | # runs each test), so this is enough without changing the test sources. |
| 24 | export RUST_MIN_STACK=33554432 |
| 25 | |
| 26 | echo "Running round-trip test..." |
| 27 | cd "$REPO_ROOT/compiler/crates" |
| 28 | FIXTURE_JSON_DIR="$TMPDIR" ~/.cargo/bin/cargo test -p react_compiler_ast --test round_trip -- --nocapture |
| 29 | |
| 30 | echo "Running scope resolution test..." |
| 31 | FIXTURE_JSON_DIR="$TMPDIR" ~/.cargo/bin/cargo test -p react_compiler_ast --test scope_resolution -- --nocapture |