| 1 | #!/usr/bin/env sh |
| 2 | set -eu |
| 3 | |
| 4 | script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd) |
| 5 | repo_root=$(CDPATH= cd "$script_dir/../../../.." && pwd) |
| 6 | cd "$repo_root" |
| 7 | |
| 8 | if [ ! -x ./v ]; then |
| 9 | echo "x.async validation must be run from a V checkout with local ./v" >&2 |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | tmp_root=$(mktemp -d "${TMPDIR:-/tmp}/xasync-validate.XXXXXX") |
| 14 | cleanup() { |
| 15 | rm -rf "$tmp_root" |
| 16 | } |
| 17 | trap cleanup EXIT INT TERM |
| 18 | |
| 19 | vtmp="$tmp_root/vtmp" |
| 20 | vcache="$tmp_root/vcache" |
| 21 | mkdir -p "$vtmp" "$vcache" |
| 22 | |
| 23 | run_v() { |
| 24 | seconds=$1 |
| 25 | shift |
| 26 | echo "+ ./v $*" |
| 27 | if command -v timeout >/dev/null 2>&1; then |
| 28 | timeout "$seconds" env VTMP="$vtmp" VCACHE="$vcache" ./v "$@" |
| 29 | else |
| 30 | env VTMP="$vtmp" VCACHE="$vcache" ./v "$@" |
| 31 | fi |
| 32 | } |
| 33 | |
| 34 | # Keep the official x.async validation serial. Running two V runners against the |
| 35 | # same checkout/cache can make build artefacts collide before x.async code runs. |
| 36 | v_files=$(find vlib/x/async -type f -name '*.v' | sort) |
| 37 | example_files=$(find vlib/x/async/examples -type f -name '*.v' | sort) |
| 38 | |
| 39 | run_v 60 fmt -verify $v_files |
| 40 | |
| 41 | for example in $example_files; do |
| 42 | run_v 60 run "$example" |
| 43 | done |
| 44 | |
| 45 | run_v 120 test vlib/x/async |
| 46 | run_v 180 -prod test vlib/x/async |
| 47 | |