Skip to content

Commit 253edc3

Browse files
feat: run-md-test.sh can now use existing binaries
Previously always deleted existing binaries. This new option is useful for testing specific binaries, as well as enabling caching for CI contexts. Behaviour is controlled by second parameter: $2 = 1: build from source $2 = 2: use existing binaries (new option) $2 = *: download binaries
1 parent faa8722 commit 253edc3

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

scripts/run-md-test.sh

+15-10
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@
1212
# (1) is controlled by the `SOURCE_MODE` parameter in the READMEs and
1313
# is set by the second flag passed to this script ($2).
1414
#
15-
# Note: although the README scripts check for the binaries existance
16-
# before re-downloading (SOURCE_MODE != 1), this script deletes
17-
# the binaries before each run.
18-
#
1915
# Has two parameters:
2016
# $1 = test name filter
2117
# $2 = source mode flag
2218
# 1: build binaries from source
23-
# *: download binaries as releases
19+
# 2: use existing binaries (or download binaries if they don't exist)
20+
# *: download binaries (replaces existing binaries)
2421

2522

23+
# $1: source mode flag
24+
# 2: don't clear binaries
25+
# *: clear binaries
2626
function clear_environment() {
2727
clear_logs
2828
free_ports
2929
clear_redis_file
30-
clear_binaries
30+
31+
if [ ! $1 -eq 2 ]; then
32+
clear_binaries
33+
fi
3134
}
3235

3336
function clear_logs() {
@@ -62,7 +65,7 @@ function clear_binaries() {
6265
}
6366

6467
# $1 = target directory
65-
# $2 = source mode in [01]
68+
# $2 = source mode
6669
# $3 = test name filter
6770
#
6871
# test_example examples/eth-settlement 0
@@ -75,11 +78,13 @@ function test_example() {
7578
pushd $target_directory > /dev/null
7679
if [ $source_mode -eq 1 ]; then
7780
printf "\e[33;1mTesting \"${target_name}\" on source mode. [%d/%d]\e[m\n" "$((TESTING_INDEX + 1))" "${TESTS_TOTAL}"
78-
clear_environment; TEST_MODE=1 SOURCE_MODE=1 $RUN_MD .
81+
clear_environment $2;
82+
TEST_MODE=1 SOURCE_MODE=1 $RUN_MD .
7983
result=$?
8084
else
8185
printf "\e[33;1mTesting \"${target_name}\" on binary mode. [%d/%d]\e[m\n" "$((TESTING_INDEX + 1))" "${TESTS_TOTAL}"
82-
clear_environment; TEST_MODE=1 $RUN_MD .
86+
clear_environment $2;
87+
TEST_MODE=1 $RUN_MD .
8388
result=$?
8489
fi
8590
mkdir -p ${LOG_DIR}/${target_name}
@@ -111,7 +116,7 @@ function add_example_tests() {
111116
}
112117

113118
# $1 = test name filter
114-
# $2 = source mode filter
119+
# $2 = source mode flag
115120

116121
BASE_DIR=$(cd $(dirname $0); pwd)
117122
RUN_MD=$BASE_DIR/run-md.sh

0 commit comments

Comments
 (0)