From 68385635d5bf8f455177dd7dd9006d963720b9bd Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Tue, 10 Feb 2026 16:08:10 +0000 Subject: [PATCH 1/2] Fix & test `process_changed_files()` --- Lib/test/test_tools/test_compute_changes.py | 147 ++++++++++++++++++++ Tools/build/compute-changes.py | 12 +- 2 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 Lib/test/test_tools/test_compute_changes.py diff --git a/Lib/test/test_tools/test_compute_changes.py b/Lib/test/test_tools/test_compute_changes.py new file mode 100644 index 00000000000000..e3d96c9cfa8292 --- /dev/null +++ b/Lib/test/test_tools/test_compute_changes.py @@ -0,0 +1,147 @@ +"""Tests to cover the Tools/build/compite-changes.py script.""" + +import importlib +import os +import unittest +from pathlib import Path +from unittest.mock import patch + +from test.test_tools import skip_if_missing, imports_under_tool + +skip_if_missing("build") + +with patch.dict(os.environ, {"GITHUB_DEFAULT_BRANCH": "main"}): + with imports_under_tool("build"): + compute_changes = importlib.import_module("compute-changes") + +process_changed_files = compute_changes.process_changed_files +Outputs = compute_changes.Outputs +ANDROID_DIRS = compute_changes.ANDROID_DIRS +IOS_DIRS = compute_changes.IOS_DIRS +MACOS_DIRS = compute_changes.MACOS_DIRS +WASI_DIRS = compute_changes.WASI_DIRS +RUN_TESTS_IGNORE = compute_changes.RUN_TESTS_IGNORE +UNIX_BUILD_SYSTEM_FILE_NAMES = compute_changes.UNIX_BUILD_SYSTEM_FILE_NAMES +LIBRARY_FUZZER_PATHS = compute_changes.LIBRARY_FUZZER_PATHS + + +class TestProcessChangedFiles(unittest.TestCase): + + def test_windows(self): + f = {Path(".github/workflows/reusable-windows.yml")} + result = process_changed_files(f) + self.assertTrue(result.run_tests) + self.assertTrue(result.run_windows_tests) + + def test_docs(self): + files = ( + ".github/workflows/reusable-docs.yml", + "Doc/library/datetime.rst", + "Doc/Makefile" + ) + for f in files: + with self.subTest(f=f): + result = process_changed_files({Path(f)}) + self.assertTrue(result.run_docs) + self.assertFalse(result.run_tests) + + def test_ci_fuzz_stdlib(self): + for p in LIBRARY_FUZZER_PATHS: + with self.subTest(p=p): + if p.is_dir(): + f = p / "comhad" + elif p.is_file(): + f = p + else: + continue + result = process_changed_files({f}) + self.assertTrue(result.run_ci_fuzz_stdlib) + + def test_android(self): + for d in ANDROID_DIRS: + with self.subTest(d=d): + result = process_changed_files({Path(d) / "comhad"}) + self.assertTrue(result.run_tests) + self.assertTrue(result.run_android) + self.assertFalse(result.run_windows_tests) + + def test_ios(self): + for d in IOS_DIRS: + with self.subTest(d=d): + result = process_changed_files({Path(d) / "comhad"}) + self.assertTrue(result.run_tests) + self.assertTrue(result.run_ios) + self.assertFalse(result.run_windows_tests) + + def test_macos(self): + f = {Path(".github/workflows/reusable-macos.yml")} + result = process_changed_files(f) + self.assertTrue(result.run_tests) + self.assertTrue(result.run_macos) + + for d in MACOS_DIRS: + with self.subTest(d=d): + result = process_changed_files({Path(d) / "comhad"}) + self.assertTrue(result.run_tests) + self.assertTrue(result.run_macos) + self.assertFalse(result.run_windows_tests) + + def test_wasi(self): + f = {Path(".github/workflows/reusable-wasi.yml")} + result = process_changed_files(f) + self.assertTrue(result.run_tests) + self.assertTrue(result.run_wasi) + + for d in WASI_DIRS: + with self.subTest(d=d): + result = process_changed_files({d / "comhad"}) + self.assertTrue(result.run_tests) + self.assertTrue(result.run_wasi) + self.assertFalse(result.run_windows_tests) + + def test_unix(self): + for f in UNIX_BUILD_SYSTEM_FILE_NAMES: + with self.subTest(f=f): + result = process_changed_files({f}) + self.assertTrue(result.run_tests) + self.assertFalse(result.run_windows_tests) + + def test_msi(self): + files = ( + ".github/workflows/reusable-windows-msi.yml", + "Tools/msi/build.bat", + ) + for f in files: + with self.subTest(f=f): + result = process_changed_files({Path(f)}) + self.assertTrue(result.run_windows_msi) + + def test_all_run(self): + files = [ + ".github/workflows/some-new-workflow.yml", + ".github/workflows/build.yml", + ] + for f in files: + with self.subTest(f=f): + result = process_changed_files({Path(f)}) + self.assertTrue(result.run_tests) + self.assertTrue(result.run_android) + self.assertTrue(result.run_ios) + self.assertTrue(result.run_macos) + self.assertTrue(result.run_ubuntu) + self.assertTrue(result.run_wasi) + + def test_all_ignored(self): + for f in RUN_TESTS_IGNORE: + with self.subTest(f=f): + self.assertEqual(process_changed_files({Path(f)}), Outputs()) + + def test_wasi_and_android(self): + f = {Path(".github/workflows/reusable-wasi.yml"), Path("Android/comhad")} + result = process_changed_files(f) + self.assertTrue(result.run_tests) + self.assertTrue(result.run_wasi) + + +if __name__ == "__main__": + unittest.main() diff --git a/Tools/build/compute-changes.py b/Tools/build/compute-changes.py index 00fd0edd8537bf..67d2b060969660 100644 --- a/Tools/build/compute-changes.py +++ b/Tools/build/compute-changes.py @@ -225,19 +225,27 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: if file.parent == GITHUB_WORKFLOWS_PATH: if file.name in ("build.yml", "reusable-cifuzz.yml"): - run_tests = run_ci_fuzz = run_ci_fuzz_stdlib = True + run_tests = run_ci_fuzz = run_ci_fuzz_stdlib = run_windows_tests = True has_platform_specific_change = False + continue if file.name == "reusable-docs.yml": run_docs = True + continue + if file.name == "reusable-windows.yml": + run_tests = True + run_windows_tests = True + continue if file.name == "reusable-windows-msi.yml": run_windows_msi = True + continue if file.name == "reusable-macos.yml": run_tests = True platforms_changed.add("macos") + continue if file.name == "reusable-wasi.yml": run_tests = True platforms_changed.add("wasi") - continue + continue if not doc_file and file not in RUN_TESTS_IGNORE: run_tests = True From 476d1067c3e57c0c0337aac4c0de276a8afc90c9 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Wed, 11 Feb 2026 15:52:26 +0000 Subject: [PATCH 2/2] Requested changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tá cosc ar an nGaeilge :-( --- .github/CODEOWNERS | 7 ++--- Lib/test/test_tools/test_compute_changes.py | 29 +++++++++------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6b6074be0a5728..c89a5aa672bcc2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -63,9 +63,10 @@ .azure-pipelines/ @AA-Turner # GitHub & related scripts -.github/ @ezio-melotti @hugovk @AA-Turner @webknjaz -Tools/build/compute-changes.py @AA-Turner @hugovk @webknjaz -Tools/build/verify_ensurepip_wheels.py @AA-Turner @pfmoore @pradyunsg +.github/ @ezio-melotti @hugovk @AA-Turner @webknjaz +Tools/build/compute-changes.py @AA-Turner @hugovk @webknjaz +Lib/test/test_tools/test_compute_changes.py @AA-Turner @hugovk @webknjaz +Tools/build/verify_ensurepip_wheels.py @AA-Turner @pfmoore @pradyunsg # Pre-commit .pre-commit-config.yaml @hugovk diff --git a/Lib/test/test_tools/test_compute_changes.py b/Lib/test/test_tools/test_compute_changes.py index e3d96c9cfa8292..1ab8be2446f5ea 100644 --- a/Lib/test/test_tools/test_compute_changes.py +++ b/Lib/test/test_tools/test_compute_changes.py @@ -34,12 +34,11 @@ def test_windows(self): self.assertTrue(result.run_windows_tests) def test_docs(self): - files = ( + for f in ( ".github/workflows/reusable-docs.yml", "Doc/library/datetime.rst", - "Doc/Makefile" - ) - for f in files: + "Doc/Makefile", + ): with self.subTest(f=f): result = process_changed_files({Path(f)}) self.assertTrue(result.run_docs) @@ -49,7 +48,7 @@ def test_ci_fuzz_stdlib(self): for p in LIBRARY_FUZZER_PATHS: with self.subTest(p=p): if p.is_dir(): - f = p / "comhad" + f = p / "file" elif p.is_file(): f = p else: @@ -60,7 +59,7 @@ def test_ci_fuzz_stdlib(self): def test_android(self): for d in ANDROID_DIRS: with self.subTest(d=d): - result = process_changed_files({Path(d) / "comhad"}) + result = process_changed_files({Path(d) / "file"}) self.assertTrue(result.run_tests) self.assertTrue(result.run_android) self.assertFalse(result.run_windows_tests) @@ -68,7 +67,7 @@ def test_android(self): def test_ios(self): for d in IOS_DIRS: with self.subTest(d=d): - result = process_changed_files({Path(d) / "comhad"}) + result = process_changed_files({Path(d) / "file"}) self.assertTrue(result.run_tests) self.assertTrue(result.run_ios) self.assertFalse(result.run_windows_tests) @@ -81,7 +80,7 @@ def test_macos(self): for d in MACOS_DIRS: with self.subTest(d=d): - result = process_changed_files({Path(d) / "comhad"}) + result = process_changed_files({Path(d) / "file"}) self.assertTrue(result.run_tests) self.assertTrue(result.run_macos) self.assertFalse(result.run_windows_tests) @@ -94,7 +93,7 @@ def test_wasi(self): for d in WASI_DIRS: with self.subTest(d=d): - result = process_changed_files({d / "comhad"}) + result = process_changed_files({d / "file"}) self.assertTrue(result.run_tests) self.assertTrue(result.run_wasi) self.assertFalse(result.run_windows_tests) @@ -107,21 +106,19 @@ def test_unix(self): self.assertFalse(result.run_windows_tests) def test_msi(self): - files = ( + for f in ( ".github/workflows/reusable-windows-msi.yml", "Tools/msi/build.bat", - ) - for f in files: + ): with self.subTest(f=f): result = process_changed_files({Path(f)}) self.assertTrue(result.run_windows_msi) def test_all_run(self): - files = [ + for f in ( ".github/workflows/some-new-workflow.yml", ".github/workflows/build.yml", - ] - for f in files: + ): with self.subTest(f=f): result = process_changed_files({Path(f)}) self.assertTrue(result.run_tests) @@ -137,7 +134,7 @@ def test_all_ignored(self): self.assertEqual(process_changed_files({Path(f)}), Outputs()) def test_wasi_and_android(self): - f = {Path(".github/workflows/reusable-wasi.yml"), Path("Android/comhad")} + f = {Path(".github/workflows/reusable-wasi.yml"), Path("Android/file")} result = process_changed_files(f) self.assertTrue(result.run_tests) self.assertTrue(result.run_wasi)