diff mbox series

[ovs-dev,1/2] atlocal: Fix setting HAVE_PYTEST on unexpected errors.

Message ID 20240517184716.133519-2-i.maximets@ovn.org
State Accepted
Commit 4d2c64ca1b6bc009f4d9cdd975f23605d0879f1e
Delegated to: Ilya Maximets
Headers show
Series atlocal: Fixes for dependency detection. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation fail test: fail

Commit Message

Ilya Maximets May 17, 2024, 6:47 p.m. UTC
If the python script throws an unexpected exception, the HAVE_PYTEST
variable remains undefined.  If at the same time dependencies are not
actually present, pytest tests will fail instead of being skipped.

Define the variable to 'no' on unexpected failures to skip the tests
when dependencies cannot be verified.

The issue can be reproduced on systems with python 3.12+ in case the
deprecated 'pkg_resources' module is not available.

Fixes: 445dceb88461 ("python: Introduce unit tests.")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 tests/atlocal.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Eelco Chaudron May 21, 2024, 6:31 a.m. UTC | #1
On 17 May 2024, at 20:47, Ilya Maximets wrote:

> If the python script throws an unexpected exception, the HAVE_PYTEST
> variable remains undefined.  If at the same time dependencies are not
> actually present, pytest tests will fail instead of being skipped.
>
> Define the variable to 'no' on unexpected failures to skip the tests
> when dependencies cannot be verified.
>
> The issue can be reproduced on systems with python 3.12+ in case the
> deprecated 'pkg_resources' module is not available.
>
> Fixes: 445dceb88461 ("python: Introduce unit tests.")
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>

Thanks for fixing this. The changes looks good to me.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
diff mbox series

Patch

diff --git a/tests/atlocal.in b/tests/atlocal.in
index f321bae55..466fd4ed4 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -242,5 +242,6 @@  with pathlib.Path(os.path.join(os.getenv("REQUIREMENT_PATH"))).open() as reqs:
 case $? in
     0) HAVE_PYTEST=yes ;;
     2) HAVE_PYTEST=no ;;
-    *) echo "$0: unexpected error probing Python unit test requirements" >&2 ;;
+    *) HAVE_PYTEST=no
+       echo "$0: unexpected error probing Python unit test requirements" >&2 ;;
 esac