Skip to content

Commit 5e96083

Browse files
committed
update coverage the standalone script (#383)
(cherry picked from commit 3eabbad)
1 parent 8f0e313 commit 5e96083

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased] - YYYY-MM-DD
9+
10+
### Added
11+
12+
-
13+
14+
15+
### Changed
16+
17+
- script: update usage of coverage in standalone ([#383](https://github.com/Lightning-AI/utilities/pull/383))
18+
19+
20+
### Fixed
21+
22+
-
23+
24+
25+
---
26+
827
## [0.14.2] - 2025-03-20
928

1029
### Fixed

scripts/run_standalone_tests.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,36 @@
1919
# It can be set through the env variable NUM_PARALLEL_TESTS and defaults to 5 if not set
2020
test_batch_size="${NUM_PARALLEL_TESTS:-5}"
2121

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}"
2424

2525
# The test directory is passed as the first argument to the script
2626
test_dir=$1 # parse the first argument
2727

2828
# 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.
3030
test_timeout="${TEST_TIMEOUT:-1200}"
3131

3232
# Temporary file to store the collected tests
3333
COLLECTED_TESTS_FILE="collected_tests.txt"
3434

3535
ls -lh . # show the contents of the directory
3636

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
3952
printf "\e[35mUsing defaults: ${defaults}\e[0m\n"
4053

4154
# 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
7992
exit 1
8093
fi
8194

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
8498

8599
status=0 # aggregated script status
86100
report=() # final report

0 commit comments

Comments
 (0)