]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-117166: Ignore empty and temporary dirs in `test_makefile` (GH-117190)...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 3 Apr 2024 13:32:55 +0000 (15:32 +0200)
committerGitHub <noreply@github.com>
Wed, 3 Apr 2024 13:32:55 +0000 (15:32 +0200)
gh-117166: Ignore empty and temporary dirs in `test_makefile` (GH-117190)
(cherry picked from commit d9cfe7e565a6e2dc15747a904736264e31a10be4)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
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)