|
12 | 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | 13 | # See the License for the specific language governing permissions and |
14 | 14 | # limitations under the License. |
15 | | -# set -e |
16 | 15 |
|
17 | | -# THIS FILE ASSUMES IT IS RUN INSIDE THE tests-sdk DIRECTORY. SEE BELOW FOR CUSTOMIZATION. |
| 16 | +# THIS FILE ASSUMES IT IS RUN INSIDE THE tests DIRECTORY. |
18 | 17 |
|
19 | 18 | # Batch size for testing: Determines how many standalone test invocations run in parallel |
20 | | -# It can be set through the env variable NUM_PARALLEL_TESTS and defaults to 10 if not set |
21 | | - |
22 | | -# Source directory for coverage runs can be set with PARALLEL_TESTS_SOURCE and defaults to |
23 | | -# lightning_sdk. |
24 | | - |
25 | | -# The directory to run tests from (in parallel) can be set with PARALLEL_TESTS_DIR and |
26 | | -# defaults to the directory of this file. Should be set correctly for each test suite |
27 | | -# (e.g. to "tests_filesystem" to run filesystem tests) |
| 19 | +# It can be set through the env variable NUM_PARALLEL_TESTS and defaults to 5 if not set |
28 | 20 | test_batch_size="${NUM_PARALLEL_TESTS:-5}" |
| 21 | + |
| 22 | +# Source directory for coverage runs can be set with CODECOV_SOURCE and defaults to lightning. |
29 | 23 | codecov_source="${CODECOV_SOURCE:-"lightning"}" |
30 | | -# this is the directory where the tests are located |
| 24 | + |
| 25 | +# The test directory is passed as the first argument to the script |
31 | 26 | test_dir=$1 # parse the first argument |
32 | | -test_timeout="${TEST_TIMEOUT:-1200}" # set the test timeout |
| 27 | + |
| 28 | +# There is also timeout for the tests. |
| 29 | +# It can be set through the env variable TEST_TIMEOUT and defaults to 1200 seconds if not set 1200 seconds |
| 30 | +test_timeout="${TEST_TIMEOUT:-1200}" |
| 31 | + |
| 32 | +# Temporary file to store the collected tests |
33 | 33 | COLLECTED_TESTS_FILE="collected_tests.txt" |
34 | 34 |
|
35 | 35 | ls -lh . # show the contents of the directory |
36 | 36 |
|
37 | | -# python arguments |
| 37 | +# Python arguments for running the tests and coverage |
38 | 38 | defaults=" -m coverage run --source ${codecov_source} --append -m pytest --no-header -v -s --color=yes --timeout=${test_timeout} --durations=0 " |
39 | 39 | echo "Using defaults: ${defaults}" |
40 | 40 |
|
41 | | -# get the list of parametrizations. we need to call them separately. the last two lines are removed. |
| 41 | +# Get the list of parametrizations. we need to call them separately. the last two lines are removed. |
42 | 42 | # note: if there's a syntax error, this will fail with some garbled output |
43 | 43 | python -um pytest ${test_dir} -q --collect-only --pythonwarnings ignore 2>&1 > $COLLECTED_TESTS_FILE |
44 | | -# early terminate if collection failed (e.g. syntax error) |
| 44 | +# Early terminate if collection failed (e.g. syntax error) |
45 | 45 | if [[ $? != 0 ]]; then |
46 | 46 | cat $COLLECTED_TESTS_FILE |
47 | 47 | printf "ERROR: test collection failed!\n" |
|
80 | 80 | # clear all the collected reports |
81 | 81 | rm -f parallel_test_output-*.txt # in case it exists, remove it |
82 | 82 |
|
83 | | -status=0 # reset the script status |
| 83 | +status=0 # aggregated script status |
84 | 84 | report="" # final report |
85 | 85 | pids=() # array of PID for running tests |
86 | 86 | test_ids=() # array of indexes of running tests |
@@ -123,13 +123,13 @@ for i in "${!tests[@]}"; do |
123 | 123 | fi |
124 | 124 | done |
125 | 125 |
|
126 | | -# print test report |
| 126 | +# print test report with exit code for each test |
127 | 127 | printf '=%.s' {1..80} |
128 | 128 | printf "\n$report" |
129 | 129 | printf '=%.s' {1..80} |
130 | 130 | printf '\n' |
131 | 131 |
|
132 | | -# print failed tests |
| 132 | +# print failed tests from duped logs |
133 | 133 | if [[ ${#failed_tests[@]} -gt 0 ]]; then |
134 | 134 | printf "Failed tests:\n" |
135 | 135 | for i in "${failed_tests[@]}"; do |
|
0 commit comments