]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117166: Ignore empty and temporary dirs in `test_makefile` (#117190)
authorNikita Sobolev <mail@sobolevn.me>
Fri, 29 Mar 2024 11:14:25 +0000 (14:14 +0300)
committerGitHub <noreply@github.com>
Fri, 29 Mar 2024 11:14:25 +0000 (14:14 +0300)
Lib/test/test_tools/test_makefile.py

index 7222a054dcd61ca5a088f7821ab47849fd6f081d..17a1a6d0d38d7d9411fb4c1f2ae9f16371f6ff74 100644 (file)
@@ -41,9 +41,17 @@ class TestMakefile(unittest.TestCase):
         self.assertIn(idle_test, test_dirs)
 
         used = [idle_test]
-        for dirpath, _, _ in os.walk(support.TEST_HOME_DIR):
+        for dirpath, dirs, files in os.walk(support.TEST_HOME_DIR):
             dirname = os.path.basename(dirpath)
-            if dirname == '__pycache__':
+            # Skip temporary dirs:
+            if dirname == '__pycache__' or dirname.startswith('.'):
+                dirs.clear()  # do not process subfolders
+                continue
+            # Skip empty dirs:
+            if not dirs and not files:
+                continue
+            # Skip dirs with hidden-only files:
+            if files and all(filename.startswith('.') for filename in files):
                 continue
 
             relpath = os.path.relpath(dirpath, support.STDLIB_DIR)