v2 / vlib / x / async / tools / validate.sh
46 lines · 37 sloc · 1.1 KB · 15fb60b77ea6073658aa8355b247f2e1ae03b714
Raw
1#!/usr/bin/env sh
2set -eu
3
4script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
5repo_root=$(CDPATH= cd "$script_dir/../../../.." && pwd)
6cd "$repo_root"
7
8if [ ! -x ./v ]; then
9 echo "x.async validation must be run from a V checkout with local ./v" >&2
10 exit 1
11fi
12
13tmp_root=$(mktemp -d "${TMPDIR:-/tmp}/xasync-validate.XXXXXX")
14cleanup() {
15 rm -rf "$tmp_root"
16}
17trap cleanup EXIT INT TERM
18
19vtmp="$tmp_root/vtmp"
20vcache="$tmp_root/vcache"
21mkdir -p "$vtmp" "$vcache"
22
23run_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.
36v_files=$(find vlib/x/async -type f -name '*.v' | sort)
37example_files=$(find vlib/x/async/examples -type f -name '*.v' | sort)
38
39run_v 60 fmt -verify $v_files
40
41for example in $example_files; do
42 run_v 60 run "$example"
43done
44
45run_v 120 test vlib/x/async
46run_v 180 -prod test vlib/x/async
47