StateId + LabelId
[hiphop-php.git] / hphp / test / run
bloba83fd5f2e627f650b77997e98abdf4a9114cd8b9
1 #!/bin/bash
3 readonly script_dir="$(dirname "$0")"
5 # Try to find an hhvm binary. Prefer a version built from this source tree,
6 # then in /usr/local, and finally from $PATH.
7 function get_hhvm_bin {
8 local -a candidates
9 candidates=(
10 "$script_dir/../../buck-out/gen/hphp/hhvm/hhvm/hhvm"
11 "$script_dir/../../../buck-out/v2/gen/fbcode/hphp/hhvm/out/hhvm"
12 "$script_dir/../hhvm/hhvm"
13 "/usr/local/hphpi/bin/hhvm"
16 for binary in "${candidates[@]}"; do
17 if [[ ! -d "$binary" && -x "$binary" ]]; then
18 echo "$binary"
19 return
21 done
23 if command -v hhvm 2>/dev/null; then
24 return
27 return 1
30 if ! hhvm_bin="$(get_hhvm_bin)"; then
31 echo "Couldn't find hhvm binary to run test/run" 1>&2
32 exit 1
35 # Try to find a cli config.
36 function get_cli_config {
37 local -a candidates
38 candidates=(
39 "/usr/local/hphpi/cli.hdf"
42 for config in "${candidates[@]}"; do
43 if [[ ! -d "$config" && -r "$config" ]]; then
44 echo "$config"
45 return
47 done
49 return 1
52 if hhvm_cfg="$(get_cli_config)"; then
53 exec "$hhvm_bin" -c "$hhvm_cfg" "$script_dir/run.php" "$@"
54 else
55 exec "$hhvm_bin" "$script_dir/run.php" "$@"