Felix Lechner pushed to branch master at lintian / lintian


Commits:
7cea4d32 by Louis-Philippe VĂ©ronneau at 2022-01-19T15:43:44-08:00
Check that tests pulling in all Python versions also query which ones are 
available. (Closes: !361)

Autopkgtests that depend on python3-all or equivalent should run under all
installed Python versions.

- - - - -


7 changed files:

- lib/Lintian/Check/Testsuite.pm
- + 
t/recipes/checks/testsuite/should-query-all-python-versions/build-spec/debian/tests/control
- + 
t/recipes/checks/testsuite/should-query-all-python-versions/build-spec/debian/tests/some-python
- + 
t/recipes/checks/testsuite/should-query-all-python-versions/build-spec/fill-values
- + t/recipes/checks/testsuite/should-query-all-python-versions/eval/desc
- + t/recipes/checks/testsuite/should-query-all-python-versions/eval/hints
- + tags/t/test-leaves-python-version-untested.tag


Changes:

=====================================
lib/Lintian/Check/Testsuite.pm
=====================================
@@ -275,6 +275,13 @@ sub check_test_file {
     return
       unless $item->is_open_ok;
 
+    my $debian_control = $self->processable->debian_control;
+
+    my $depends_norestriction = Lintian::Relation->new;
+    $depends_norestriction->load($section->unfolded_value('Depends'));
+
+    my $queries_all_python_versions = 0;
+
     open(my $fd, '<', $item->unpacked_path)
       or die encode_utf8('Cannot open ' . $item->unpacked_path);
 
@@ -296,9 +303,6 @@ sub check_test_file {
                 $pointer, $command)
               if $options =~ /\s(?:-\w*i|--installed)/;
 
-            my $depends_norestriction = Lintian::Relation->new;
-            $depends_norestriction->load($section->unfolded_value('Depends'));
-
             $self->pointed_hint(
 'runtime-test-file-uses-supported-python-versions-without-test-depends',
                 $pointer,
@@ -307,8 +311,6 @@ sub check_test_file {
               if $options =~ /\s(?:-\w*s|--supported)/
               && !$depends_norestriction->satisfies($PYTHON3_ALL_DEPEND);
 
-            my $debian_control = $self->processable->debian_control;
-
             $self->pointed_hint('declare-python-versions-for-test',
                 $pointer, $command)
               if $options =~ m{ \s (?: -\w*r | --requested ) }x
@@ -320,6 +322,9 @@ sub check_test_file {
                 $debian_control->source_fields->value('X-Python3-Version'))
               if $options =~ m{ \s (?: -\w*s | --supported ) }x
               && $debian_control->source_fields->declares('X-Python3-Version');
+
+            $queries_all_python_versions = 1
+              if $options =~ m{ \s (?: -\w*s | --supported ) }x;
         }
 
     } continue {
@@ -328,6 +333,10 @@ sub check_test_file {
 
     close $fd;
 
+    $self->pointed_hint('test-leaves-python-version-untested',$item->pointer)
+      if $depends_norestriction->satisfies($PYTHON3_ALL_DEPEND)
+      && !$queries_all_python_versions;
+
     return;
 }
 


=====================================
t/recipes/checks/testsuite/should-query-all-python-versions/build-spec/debian/tests/control
=====================================
@@ -0,0 +1,2 @@
+Tests: some-python
+Depends: python3-all


=====================================
t/recipes/checks/testsuite/should-query-all-python-versions/build-spec/debian/tests/some-python
=====================================
@@ -0,0 +1,7 @@
+#!/bin/sh
+set -efu
+
+cp -a tests "$AUTOPKGTEST_TMP"
+cd "$AUTOPKGTEST_TMP"
+
+python3 -m unittest tests -v


=====================================
t/recipes/checks/testsuite/should-query-all-python-versions/build-spec/fill-values
=====================================
@@ -0,0 +1,3 @@
+Skeleton: source-native
+Testname: should-query-all-python-versions
+Description: Autopkgtest depends on python3-all but does not invoke 
'py3versions --supported'


=====================================
t/recipes/checks/testsuite/should-query-all-python-versions/eval/desc
=====================================
@@ -0,0 +1,2 @@
+Testname: should-query-all-python-versions
+Check: testsuite


=====================================
t/recipes/checks/testsuite/should-query-all-python-versions/eval/hints
=====================================
@@ -0,0 +1 @@
+should-query-all-python-versions (source): test-leaves-python-version-untested 
[debian/tests/some-python]


=====================================
tags/t/test-leaves-python-version-untested.tag
=====================================
@@ -0,0 +1,11 @@
+Tag: test-leaves-python-version-untested
+Severity: warning
+Check: testsuite
+Explanation: The named autopkgtest declares <code>python3-all</code> or an 
equivalent
+ as a runtime prerquisite but the test script does not query the installed 
Python
+ versions with <code>py3versions --supported</code>.
+ .
+ The test may pass with the standard Python version but could fail in the 
future with
+ a Python version that is already available now.
+ .
+ It is best to run tests for all available Python versions.



View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/commit/7cea4d3264f8eb715e36503fc29e5548179448e2

-- 
View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/commit/7cea4d3264f8eb715e36503fc29e5548179448e2
You're receiving this email because of your account on salsa.debian.org.


Reply via email to