|
19 | 19 | # It can be set through the env variable NUM_PARALLEL_TESTS and defaults to 5 if not set |
20 | 20 | test_batch_size="${NUM_PARALLEL_TESTS:-5}" |
21 | 21 |
|
22 | | -# Source directory for coverage runs can be set with CODECOV_SOURCE and defaults to lightning. |
23 | | -codecov_source="${COVERAGE_SOURCE:-"lightning"}" |
| 22 | +# Source directory for coverage runs can be set with CODECOV_SOURCE. |
| 23 | +codecov_source="${COVERAGE_SOURCE}" |
24 | 24 |
|
25 | 25 | # The test directory is passed as the first argument to the script |
26 | 26 | test_dir=$1 # parse the first argument |
27 | 27 |
|
28 | 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 |
| 29 | +# It can be set through the env variable TEST_TIMEOUT and defaults to 1200 seconds. |
30 | 30 | test_timeout="${TEST_TIMEOUT:-1200}" |
31 | 31 |
|
32 | 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 for running the tests and coverage |
38 | | -defaults=" -m coverage run --source ${codecov_source} --append -m pytest --no-header -v -s --color=yes --timeout=${test_timeout} --durations=0 " |
| 37 | +# Clean up the coverage file if it exists |
| 38 | +if [ -n "$codecov_source" ]; then |
| 39 | + rm -f .coverage |
| 40 | +fi |
| 41 | + |
| 42 | +# Check if the coverage source is empty. |
| 43 | +defaults="" |
| 44 | +# If codecov_source is set, prepend the coverage command |
| 45 | +if [ -n "$codecov_source" ]; then |
| 46 | + defaults=" -m coverage run --source ${codecov_source} --append " |
| 47 | +fi |
| 48 | +# Append the common pytest arguments |
| 49 | +defaults="${defaults} -m pytest --no-header -v -s --color=yes --timeout=${test_timeout} --durations=0 " |
| 50 | + |
| 51 | +# Python arguments for running the tests and optional coverage |
39 | 52 | printf "\e[35mUsing defaults: ${defaults}\e[0m\n" |
40 | 53 |
|
41 | 54 | # Get the list of parametrizations. we need to call them separately. the last two lines are removed. |
@@ -79,8 +92,9 @@ elif [ $test_count -eq 0 ]; then |
79 | 92 | exit 1 |
80 | 93 | fi |
81 | 94 |
|
82 | | -# clear all the collected reports |
83 | | -rm -f parallel_test_output-*.txt # in case it exists, remove it |
| 95 | +if [ -n "$codecov_source" ]; then |
| 96 | + coverage combine |
| 97 | +fi |
84 | 98 |
|
85 | 99 | status=0 # aggregated script status |
86 | 100 | report=() # final report |
|
0 commit comments