Skip to content

Commit b9f215d

Browse files
authored
Replace usage of grep -P with perl in run_standalone_tests.sh (#19942)
1 parent e0b7c04 commit b9f215d

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.azure/gpu-tests-pytorch.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pr:
3131
- "src/lightning/pytorch/**"
3232
- "src/pytorch_lightning/*"
3333
- "tests/tests_pytorch/**"
34+
- "tests/run_standalone_*.sh"
3435
- "pyproject.toml" # includes pytest config
3536
- "requirements/fabric/**"
3637
- "src/lightning/fabric/**"

.github/checkgroup.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ subprojects:
6060
- "src/lightning/pytorch/**"
6161
- "src/pytorch_lightning/*"
6262
- "tests/tests_pytorch/**"
63+
- "tests/run_standalone_*.sh"
6364
- "pyproject.toml" # includes pytest config
6465
- "requirements/fabric/**"
6566
- "src/lightning/fabric/**"
@@ -201,14 +202,14 @@ subprojects:
201202
- ".azure/gpu-tests-fabric.yml"
202203
- "examples/fabric/**"
203204
- "examples/run_fabric_examples.sh"
204-
- "tests/run_standalone_*.sh"
205205
- "requirements/fabric/**"
206206
- "src/lightning/__init__.py"
207207
- "src/lightning/__setup__.py"
208208
- "src/lightning/__version__.py"
209209
- "src/lightning/fabric/**"
210210
- "src/lightning_fabric/*"
211211
- "tests/tests_fabric/**"
212+
- "tests/run_standalone_*.sh"
212213
- "pyproject.toml" # includes pytest config
213214
- "!requirements/*/docs.txt"
214215
- "!*.md"

tests/run_standalone_tests.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ export PL_RUN_STANDALONE_TESTS=1
2626
defaults=" -m coverage run --source ${source} --append -m pytest --no-header -v -s --timeout 120 "
2727
echo "Using defaults: ${defaults}"
2828

29-
# get the testing location as the fist argument
29+
# get the testing location as the first argument
3030
test_path=$1
3131
printf "source path: $test_path\n"
3232

3333
# collect all tests with parametrization based filtering with PL_RUN_STANDALONE_TESTS
3434
standalone_tests=$(python3 -m pytest $test_path -q --collect-only --pythonwarnings ignore)
35-
printf "Collected tests: \n $standalone_tests"
35+
printf "Collected tests: \n $standalone_tests\n"
3636
# match only lines with tests
37-
parametrizations=$(grep -oP '\S+::test_\S+' <<< "$standalone_tests")
37+
parametrizations=$(perl -nle 'print $& while m{\S+::test_\S+}g' <<< "$standalone_tests")
3838
# convert the list to be array
3939
parametrizations_arr=($parametrizations)
40-
4140
report=''
4241

4342
rm -f standalone_test_output.txt # in case it exists, remove it
@@ -47,7 +46,7 @@ function show_batched_output {
4746
if [ -f standalone_test_output.txt ]; then # if exists
4847
cat standalone_test_output.txt
4948
# heuristic: stop if there's mentions of errors. this can prevent false negatives when only some of the ranks fail
50-
if grep -iE 'error|exception|traceback|failed' standalone_test_output.txt | grep -vE 'on_exception|xfailed' | grep -qv -f testnames.txt; then
49+
if perl -nle 'print if /error|(?<!(?-i)on_)exception|traceback|(?<!(?-i)x)failed/i' standalone_test_output.txt | grep -qv -f testnames.txt; then
5150
echo "Potential error! Stopping."
5251
rm standalone_test_output.txt
5352
exit 1

0 commit comments

Comments
 (0)