Skip to content

Commit

Permalink
fixing notebook test errors when no tests collected (quantumlib#4196)
Browse files Browse the repository at this point in the history
Fix broken notebook tests in master.

It seems that when `pattern` does not match any tests in `pytest -k pattern`, pytest returns an exit code 5. This breaks the newly sharded notebook tests, which are leveraging the `-k partition-n` pattern for changed notebooks. 

This fix adds the fix as per the recommendations of pytest-dev/pytest#2393.
  • Loading branch information
balopat authored and rht committed May 1, 2023
1 parent f4c2b3b commit 738ca19
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion check/pytest
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,17 @@ fi

if [ -z "${ACTUALLY_QUIET}" ]; then
pytest "${PYTEST_ARGS[@]}"
RESULT=$?
else
# Filter out lines like "...F....x... [ 42%]", with coloring.
pytest -q --color=yes "${PYTEST_ARGS[@]}" |
perl -nle'print if not m{^(.\[0m)?[\.FEsx]+(.\[36m)?\s+\[\s*\d+%\](.\[0m)?$}'
exit "${PIPESTATUS[0]}"
RESULT=${PIPESTATUS[0]}
fi

if [ "$RESULT" = 5 ]; then
echo "[exit 5] No tests collected, but ignored."
exit 0
fi

exit "$RESULT"

0 comments on commit 738ca19

Please sign in to comment.