This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v2-10-test by this push:
     new e36e521dcb Fix Non-DB test calculation for main builds (#41499) 
(#41543)
e36e521dcb is described below

commit e36e521dcb317548a159d98587aff18c979419f7
Author: Jarek Potiuk <[email protected]>
AuthorDate: Fri Aug 16 21:24:46 2024 +0200

    Fix Non-DB test calculation for main builds (#41499) (#41543)
    
    Pytest has a weird behaviour that it will not collect tests
    from parent folder when subfolder of it is specified after the
    parent folder. This caused some non-db tests from providers folder
    have been skipped during main build.
    
    The issue in Pytest 8.2 (used to work before) is tracked at
    https://github.com/pytest-dev/pytest/issues/12605
    
    (cherry picked from commit d48982692c54d024d7c05e1efb7cd2adeb7d896c)
---
 dev/breeze/src/airflow_breeze/utils/run_tests.py    | 14 +++++++++++---
 dev/breeze/tests/test_pytest_args_for_test_types.py | 13 +++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/utils/run_tests.py 
b/dev/breeze/src/airflow_breeze/utils/run_tests.py
index fe099efbc0..375dc56847 100644
--- a/dev/breeze/src/airflow_breeze/utils/run_tests.py
+++ b/dev/breeze/src/airflow_breeze/utils/run_tests.py
@@ -374,7 +374,7 @@ def generate_args_for_pytest(
     args.extend(get_excluded_provider_args(python_version))
     if use_xdist:
         args.extend(["-n", str(parallelism) if parallelism else "auto"])
-    # We have to disabke coverage for Python 3.12 because of the issue with 
coverage that takes too long, despite
+    # We have to disable coverage for Python 3.12 because of the issue with 
coverage that takes too long, despite
     # Using experimental support for Python 3.12 PEP 669. The coverage.py is 
not yet fully compatible with the
     # full scope of PEP-669. That will be fully done when 
https://github.com/nedbat/coveragepy/issues/1746 is
     # resolve for now we are disabling coverage for Python 3.12, and it causes 
slower execution and occasional
@@ -417,5 +417,13 @@ def convert_parallel_types_to_folders(
                 python_version=python_version,
             )
         )
-    # leave only folders, strip --pytest-args
-    return [arg for arg in args if arg.startswith("test")]
+    # leave only folders, strip --pytest-args that exclude some folders with 
`-' prefix
+    folders = [arg for arg in args if arg.startswith("test")]
+    # remove specific provider sub-folders if "tests/providers" is already in 
the list
+    # This workarounds pytest issues where it will only run tests from 
specific subfolders
+    # if both parent and child folders are in the list
+    # The issue in Pytest (changed behaviour in Pytest 8.2 is tracked here
+    # https://github.com/pytest-dev/pytest/issues/12605
+    if "tests/providers" in folders:
+        folders = [folder for folder in folders if not 
folder.startswith("tests/providers/")]
+    return folders
diff --git a/dev/breeze/tests/test_pytest_args_for_test_types.py 
b/dev/breeze/tests/test_pytest_args_for_test_types.py
index a64dccbd06..fbb3785949 100644
--- a/dev/breeze/tests/test_pytest_args_for_test_types.py
+++ b/dev/breeze/tests/test_pytest_args_for_test_types.py
@@ -329,6 +329,19 @@ def 
test_pytest_args_for_helm_test_types(helm_test_package: str, pytest_args: li
             ],
             True,
         ),
+        (
+            "Core Providers[-amazon,google] Providers[amazon] 
Providers[google]",
+            [
+                "tests/core",
+                "tests/executors",
+                "tests/jobs",
+                "tests/models",
+                "tests/ti_deps",
+                "tests/utils",
+                "tests/providers",
+            ],
+            False,
+        ),
     ],
 )
 def test_folders_for_parallel_test_types(

Reply via email to