From 39d080ea5d9bdb6ed40c03c2784a4f3539552538 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 24 Mar 2024 11:41:51 +0300 Subject: [PATCH 1/4] gh-117166: Ignore empty and temporary dirs in `test_makefile` --- Lib/test/test_tools/test_makefile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_tools/test_makefile.py b/Lib/test/test_tools/test_makefile.py index 7222a054dcd61c..25c9ab770df217 100644 --- a/Lib/test/test_tools/test_makefile.py +++ b/Lib/test/test_tools/test_makefile.py @@ -43,7 +43,11 @@ def test_makefile_test_folders(self): used = [idle_test] for dirpath, _, _ in os.walk(support.TEST_HOME_DIR): dirname = os.path.basename(dirpath) - if dirname == '__pycache__': + if ( + dirname == '__pycache__' + or dirname.startswith('.') + or not os.listdir(dirpath) + ): continue relpath = os.path.relpath(dirpath, support.STDLIB_DIR) From 59a820fe7e0eff58fe3074032c9b59c6e1a112a0 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 25 Mar 2024 14:07:35 +0300 Subject: [PATCH 2/4] Address review --- Lib/test/test_tools/test_makefile.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_tools/test_makefile.py b/Lib/test/test_tools/test_makefile.py index 25c9ab770df217..bb1ac934874cfa 100644 --- a/Lib/test/test_tools/test_makefile.py +++ b/Lib/test/test_tools/test_makefile.py @@ -41,13 +41,17 @@ def test_makefile_test_folders(self): 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__' - or dirname.startswith('.') - or not os.listdir(dirpath) - ): + # 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 not dirs and all(filename.startswith('.') for filename in files): continue relpath = os.path.relpath(dirpath, support.STDLIB_DIR) From 15d57b29da7049e1049941c3be93cbdeffc14684 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 29 Mar 2024 12:06:30 +0300 Subject: [PATCH 3/4] Address review --- Lib/test/test_tools/test_makefile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_tools/test_makefile.py b/Lib/test/test_tools/test_makefile.py index bb1ac934874cfa..763c7e1142057c 100644 --- a/Lib/test/test_tools/test_makefile.py +++ b/Lib/test/test_tools/test_makefile.py @@ -51,7 +51,7 @@ def test_makefile_test_folders(self): if not dirs and not files: continue # Skip dirs with hidden-only files: - if not dirs and all(filename.startswith('.') for filename in files): + if all(filename.startswith('.') for filename in files): continue relpath = os.path.relpath(dirpath, support.STDLIB_DIR) From 93e06508e616fbed3db78e564fa787568f0394ed Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 29 Mar 2024 13:30:03 +0300 Subject: [PATCH 4/4] Fix CI --- Lib/test/test_tools/test_makefile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_tools/test_makefile.py b/Lib/test/test_tools/test_makefile.py index 763c7e1142057c..17a1a6d0d38d7d 100644 --- a/Lib/test/test_tools/test_makefile.py +++ b/Lib/test/test_tools/test_makefile.py @@ -51,7 +51,7 @@ def test_makefile_test_folders(self): if not dirs and not files: continue # Skip dirs with hidden-only files: - if all(filename.startswith('.') for filename in files): + if files and all(filename.startswith('.') for filename in files): continue relpath = os.path.relpath(dirpath, support.STDLIB_DIR)