diff mbox series

[02/10] iotests/297: Add get_files() function

Message ID 20210625182021.803227-3-jsnow@redhat.com (mailing list archive)
State New, archived
Headers show
Series python/iotests: Run iotest linters during Python CI | expand

Commit Message

John Snow June 25, 2021, 6:20 p.m. UTC
Split out file discovery into its own method to begin separating out the
"environment setup" and "test execution" phases.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/qemu-iotests/297 | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Vladimir Sementsov-Ogievskiy July 6, 2021, 9:01 a.m. UTC | #1
25.06.2021 21:20, John Snow wrote:
> Split out file discovery into its own method to begin separating out the
> "environment setup" and "test execution" phases.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

> ---
>   tests/qemu-iotests/297 | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
> index 493dda17fb..0bc1195805 100755
> --- a/tests/qemu-iotests/297
> +++ b/tests/qemu-iotests/297
> @@ -21,6 +21,7 @@ import re
>   import shutil
>   import subprocess
>   import sys
> +from typing import List
>   
>   import iotests
>   
> @@ -56,9 +57,15 @@ def is_python_file(filename: str, directory: str = '.') -> bool:
>               return False
>   
>   
> +def get_test_files(directory: str = '.') -> List[str]:
> +    return [
> +        f for f in (set(os.listdir(directory)) - set(SKIP_FILES))
> +        if is_python_file(f, directory)
> +    ]
> +
> +
>   def run_linters():
> -    files = [filename for filename in (set(os.listdir('.')) - set(SKIP_FILES))
> -             if is_python_file(filename)]
> +    files = get_test_files()

Hmm. It looks like files in tests/qemu-iotests/tests are ignored now.. That's bad

>   
>       iotests.logger.debug('Files to be checked:')
>       iotests.logger.debug(', '.join(sorted(files)))
>
John Snow July 20, 2021, 3:16 p.m. UTC | #2
On Tue, Jul 6, 2021 at 5:02 AM Vladimir Sementsov-Ogievskiy <
vsementsov@virtuozzo.com> wrote:

> 25.06.2021 21:20, John Snow wrote:
> > Split out file discovery into its own method to begin separating out the
> > "environment setup" and "test execution" phases.
> >
> > Signed-off-by: John Snow <jsnow@redhat.com>
>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>
> > ---
> >   tests/qemu-iotests/297 | 11 +++++++++--
> >   1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
> > index 493dda17fb..0bc1195805 100755
> > --- a/tests/qemu-iotests/297
> > +++ b/tests/qemu-iotests/297
> > @@ -21,6 +21,7 @@ import re
> >   import shutil
> >   import subprocess
> >   import sys
> > +from typing import List
> >
> >   import iotests
> >
> > @@ -56,9 +57,15 @@ def is_python_file(filename: str, directory: str =
> '.') -> bool:
> >               return False
> >
> >
> > +def get_test_files(directory: str = '.') -> List[str]:
> > +    return [
> > +        f for f in (set(os.listdir(directory)) - set(SKIP_FILES))
> > +        if is_python_file(f, directory)
> > +    ]
> > +
> > +
> >   def run_linters():
> > -    files = [filename for filename in (set(os.listdir('.')) -
> set(SKIP_FILES))
> > -             if is_python_file(filename)]
> > +    files = get_test_files()
>
> Hmm. It looks like files in tests/qemu-iotests/tests are ignored now..
> That's bad
>
>
Oh, it seems likely we were never checking them -- listdir doesn't recurse
before *or* after this patch. OK, I can fix that. It'll be in a new patch.


> >
> >       iotests.logger.debug('Files to be checked:')
> >       iotests.logger.debug(', '.join(sorted(files)))
> >
>
>
> --
> Best regards,
> Vladimir
>
>
diff mbox series

Patch

diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
index 493dda17fb..0bc1195805 100755
--- a/tests/qemu-iotests/297
+++ b/tests/qemu-iotests/297
@@ -21,6 +21,7 @@  import re
 import shutil
 import subprocess
 import sys
+from typing import List
 
 import iotests
 
@@ -56,9 +57,15 @@  def is_python_file(filename: str, directory: str = '.') -> bool:
             return False
 
 
+def get_test_files(directory: str = '.') -> List[str]:
+    return [
+        f for f in (set(os.listdir(directory)) - set(SKIP_FILES))
+        if is_python_file(f, directory)
+    ]
+
+
 def run_linters():
-    files = [filename for filename in (set(os.listdir('.')) - set(SKIP_FILES))
-             if is_python_file(filename)]
+    files = get_test_files()
 
     iotests.logger.debug('Files to be checked:')
     iotests.logger.debug(', '.join(sorted(files)))