Skip to content

Commit

Permalink
allow configuring path to node during runtests.sh
Browse files Browse the repository at this point in the history
Summary:
the custom resolver tests are relying on node from the path, but it can be helpful to override the path.

this diff introduces a `FLOW_NODE_BINARY` environment variable which you can point at a custom node:

```
FLOW_NODE_BINARY=path/to/node ./runtests.sh path/to/flow
```

This is accomplished via a wrapper script, `scripts/tests_bin/node`, which calls `$FLOW_NODE_BINARY`. `runtests.sh` sets the var to `NODE_BINARY` if it's set, or `which node` if not. `scripts/tests_bin` is added to `PATH` when running the tests, so `node` in tests picks up the wrapper.

Reviewed By: gabelevi

Differential Revision: D12964367

fbshipit-source-id: ef98fb1f89c6a32f04ef36ebb315a604f01c5e9e
  • Loading branch information
mroch authored and facebook-github-bot committed Nov 8, 2018
1 parent 94ffd92 commit 46b9055
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion runtests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)

# Use the assert functions below to expect specific exit codes.

Expand Down Expand Up @@ -66,13 +67,14 @@ show_help() {

export IN_FLOW_TEST=1
export FLOW_LOG_LEVEL=debug
export FLOW_NODE_BINARY=${FLOW_NODE_BINARY:-${NODE_BINARY:-$(which node)}}

OPTIND=1
record=0
saved_state=0
verbose=0
quiet=0
relative="$(dirname "${BASH_SOURCE[0]}")"
relative="$THIS_DIR"
list_tests=0
while getopts "b:d:f:lqrst:vh?" opt; do
case "$opt" in
Expand Down Expand Up @@ -500,6 +502,7 @@ runtest() {

if create_saved_state "$root" "$flowconfig_name"
then
PATH="$THIS_DIR/scripts/tests_bin:$PATH" \
"$FLOW" start "$root" \
$all $flowlib --wait \
--saved-state-fetcher "local" \
Expand All @@ -515,6 +518,7 @@ runtest() {
fi
else
# start server and wait
PATH="$THIS_DIR/scripts/tests_bin:$PATH" \
"$FLOW" start "$root" \
$all $flowlib --wait \
--file-watcher "$file_watcher" \
Expand All @@ -539,6 +543,7 @@ runtest() {
# run test script in subshell so it inherits functions
(
set -e # The script should probably use this option
export PATH="$THIS_DIR/scripts/tests_bin:$PATH"
source "$shell" "$FLOW"
) 1> "$abs_out_file" 2> "$stderr_dest"
code=$?
Expand Down
4 changes: 4 additions & 0 deletions scripts/tests_bin/node
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# FLOW_NODE_BINARY is set by runtests.sh
exec "$FLOW_NODE_BINARY" "$@"

0 comments on commit 46b9055

Please sign in to comment.