[igt-dev] [PATCH i-g-t v2 06/19] scripts/igt_doc.py: add error handler for subprocess

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Mon Mar 13 06:55:55 UTC 2023


On Fri, Mar 10, 2023 at 08:41:12PM +0100, Zbigniew Kempczyński wrote:
> From: Mauro Carvalho Chehab <mchehab at kernel.org>
> 
> Handle exceptions when trying to excecute IGT runner.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
> ---
>  scripts/igt_doc.py | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/scripts/igt_doc.py b/scripts/igt_doc.py
> index 712e22c9d3..c06c6e4eae 100755
> --- a/scripts/igt_doc.py
> +++ b/scripts/igt_doc.py
> @@ -754,14 +754,15 @@ class TestList:
>              doc_subtests[i] = re.sub(r'\<[^\>]+\>', r'\\d+', doc_subtests[i])
>  
>          # Get a list of tests from
> -        result = subprocess.run([ f"{IGT_BUILD_PATH}/{IGT_RUNNER}",  # pylint: disable=W1510
> -                                "-L", "-t",  self.min_test_prefix,
> -                                f"{IGT_BUILD_PATH}/tests"],
> -                                capture_output = True, text = True)
> -        if result.returncode:
> -            print( result.stdout)
> -            print("Error:", result.stderr)
> -            sys.exit(result.returncode)
> +        try:
> +            result = subprocess.run([ f"{IGT_BUILD_PATH}/{IGT_RUNNER}",
> +                                    "-L", "-t",  self.min_test_prefix,
> +                                    f"{IGT_BUILD_PATH}/tests"], check = True,
> +                                    capture_output = True, text = True)
> +        except subprocess.CalledProcessError as sub_err:
> +            print(sub_err.stderr)
> +            print("Error:", sub_err)
> +            sys.exit(1)
>  
>          run_subtests = sorted(result.stdout.splitlines())
>  
> -- 
> 2.34.1
>

Acked-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
--
Zbigniew


More information about the igt-dev mailing list