sync the repo
[hiphop-php.git] / hphp / test / run
blob392c9457c02d5341f84bc43382f9c65aef117992
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 # If HHVM_BIN is set, only consider that
17 if [[ -n "$HHVM_BIN" ]]; then
18 candidates=("${HHVM_BIN}")
21 for binary in "${candidates[@]}"; do
22 if [[ ! -d "$binary" && -x "$binary" ]]; then
23 echo "$binary"
24 return
26 done
28 if command -v hhvm 2>/dev/null; then
29 return
32 return 1
35 if ! hhvm_bin="$(get_hhvm_bin)"; then
36 echo "Couldn't find hhvm binary to run test/run" 1>&2
37 exit 1
40 # Try to find a cli config.
41 function get_cli_config {
42 local -a candidates
43 candidates=(
44 "/usr/local/hphpi/cli.hdf"
47 for config in "${candidates[@]}"; do
48 if [[ ! -d "$config" && -r "$config" ]]; then
49 echo "$config"
50 return
52 done
54 return 1
57 if hhvm_cfg="$(get_cli_config)"; then
58 exec "$hhvm_bin" -c "$hhvm_cfg" -vBCCache.Enabled=false -vEval.EnableLogBridge=false -vEval.PreludePath= "$script_dir/run.php" "$@"
59 else
60 exec "$hhvm_bin" -vBCCache.Enabled=false -vEval.EnableLogBridge=false "$script_dir/run.php" "$@"