| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,9 +63,10 @@ | |||
| 63 | 63 | .azure-pipelines/ @AA-Turner | |
| 64 | 64 | ||
| 65 | 65 | # GitHub & related scripts | |
| 66 | - .github/ @ezio-melotti @hugovk @AA-Turner @webknjaz | ||
| 67 | - Tools/build/compute-changes.py @AA-Turner @hugovk @webknjaz | ||
| 68 | - Tools/build/verify_ensurepip_wheels.py @AA-Turner @pfmoore @pradyunsg | ||
| 66 | + .github/ @ezio-melotti @hugovk @AA-Turner @webknjaz | ||
| 67 | + Tools/build/compute-changes.py @AA-Turner @hugovk @webknjaz | ||
| 68 | + Lib/test/test_tools/test_compute_changes.py @AA-Turner @hugovk @webknjaz | ||
| 69 | + Tools/build/verify_ensurepip_wheels.py @AA-Turner @pfmoore @pradyunsg | ||
| 69 | 70 | ||
| 70 | 71 | # Pre-commit | |
| 71 | 72 | .pre-commit-config.yaml @hugovk | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,144 @@ | |||
| 1 | + """Tests to cover the Tools/build/compute-changes.py script.""" | ||
| 2 | + | ||
| 3 | + import importlib | ||
| 4 | + import os | ||
| 5 | + import unittest | ||
| 6 | + from pathlib import Path | ||
| 7 | + from unittest.mock import patch | ||
| 8 | + | ||
| 9 | + from test.test_tools import skip_if_missing, imports_under_tool | ||
| 10 | + | ||
| 11 | + skip_if_missing("build") | ||
| 12 | + | ||
| 13 | + with patch.dict(os.environ, {"GITHUB_DEFAULT_BRANCH": "main"}): | ||
| 14 | + with imports_under_tool("build"): | ||
| 15 | + compute_changes = importlib.import_module("compute-changes") | ||
| 16 | + | ||
| 17 | + process_changed_files = compute_changes.process_changed_files | ||
| 18 | + Outputs = compute_changes.Outputs | ||
| 19 | + ANDROID_DIRS = compute_changes.ANDROID_DIRS | ||
| 20 | + IOS_DIRS = compute_changes.IOS_DIRS | ||
| 21 | + MACOS_DIRS = compute_changes.MACOS_DIRS | ||
| 22 | + WASI_DIRS = compute_changes.WASI_DIRS | ||
| 23 | + RUN_TESTS_IGNORE = compute_changes.RUN_TESTS_IGNORE | ||
| 24 | + UNIX_BUILD_SYSTEM_FILE_NAMES = compute_changes.UNIX_BUILD_SYSTEM_FILE_NAMES | ||
| 25 | + LIBRARY_FUZZER_PATHS = compute_changes.LIBRARY_FUZZER_PATHS | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + class TestProcessChangedFiles(unittest.TestCase): | ||
| 29 | + | ||
| 30 | + def test_windows(self): | ||
| 31 | + f = {Path(".github/workflows/reusable-windows.yml")} | ||
| 32 | + result = process_changed_files(f) | ||
| 33 | + self.assertTrue(result.run_tests) | ||
| 34 | + self.assertTrue(result.run_windows_tests) | ||
| 35 | + | ||
| 36 | + def test_docs(self): | ||
| 37 | + for f in ( | ||
| 38 | + ".github/workflows/reusable-docs.yml", | ||
| 39 | + "Doc/library/datetime.rst", | ||
| 40 | + "Doc/Makefile", | ||
| 41 | + ): | ||
| 42 | + with self.subTest(f=f): | ||
| 43 | + result = process_changed_files({Path(f)}) | ||
| 44 | + self.assertTrue(result.run_docs) | ||
| 45 | + self.assertFalse(result.run_tests) | ||
| 46 | + | ||
| 47 | + def test_ci_fuzz_stdlib(self): | ||
| 48 | + for p in LIBRARY_FUZZER_PATHS: | ||
| 49 | + with self.subTest(p=p): | ||
| 50 | + if p.is_dir(): | ||
| 51 | + f = p / "file" | ||
| 52 | + elif p.is_file(): | ||
| 53 | + f = p | ||
| 54 | + else: | ||
| 55 | + continue | ||
| 56 | + result = process_changed_files({f}) | ||
| 57 | + self.assertTrue(result.run_ci_fuzz_stdlib) | ||
| 58 | + | ||
| 59 | + def test_android(self): | ||
| 60 | + for d in ANDROID_DIRS: | ||
| 61 | + with self.subTest(d=d): | ||
| 62 | + result = process_changed_files({Path(d) / "file"}) | ||
| 63 | + self.assertTrue(result.run_tests) | ||
| 64 | + self.assertTrue(result.run_android) | ||
| 65 | + self.assertFalse(result.run_windows_tests) | ||
| 66 | + | ||
| 67 | + def test_ios(self): | ||
| 68 | + for d in IOS_DIRS: | ||
| 69 | + with self.subTest(d=d): | ||
| 70 | + result = process_changed_files({Path(d) / "file"}) | ||
| 71 | + self.assertTrue(result.run_tests) | ||
| 72 | + self.assertTrue(result.run_ios) | ||
| 73 | + self.assertFalse(result.run_windows_tests) | ||
| 74 | + | ||
| 75 | + def test_macos(self): | ||
| 76 | + f = {Path(".github/workflows/reusable-macos.yml")} | ||
| 77 | + result = process_changed_files(f) | ||
| 78 | + self.assertTrue(result.run_tests) | ||
| 79 | + self.assertTrue(result.run_macos) | ||
| 80 | + | ||
| 81 | + for d in MACOS_DIRS: | ||
| 82 | + with self.subTest(d=d): | ||
| 83 | + result = process_changed_files({Path(d) / "file"}) | ||
| 84 | + self.assertTrue(result.run_tests) | ||
| 85 | + self.assertTrue(result.run_macos) | ||
| 86 | + self.assertFalse(result.run_windows_tests) | ||
| 87 | + | ||
| 88 | + def test_wasi(self): | ||
| 89 | + f = {Path(".github/workflows/reusable-wasi.yml")} | ||
| 90 | + result = process_changed_files(f) | ||
| 91 | + self.assertTrue(result.run_tests) | ||
| 92 | + self.assertTrue(result.run_wasi) | ||
| 93 | + | ||
| 94 | + for d in WASI_DIRS: | ||
| 95 | + with self.subTest(d=d): | ||
| 96 | + result = process_changed_files({d / "file"}) | ||
| 97 | + self.assertTrue(result.run_tests) | ||
| 98 | + self.assertTrue(result.run_wasi) | ||
| 99 | + self.assertFalse(result.run_windows_tests) | ||
| 100 | + | ||
| 101 | + def test_unix(self): | ||
| 102 | + for f in UNIX_BUILD_SYSTEM_FILE_NAMES: | ||
| 103 | + with self.subTest(f=f): | ||
| 104 | + result = process_changed_files({f}) | ||
| 105 | + self.assertTrue(result.run_tests) | ||
| 106 | + self.assertFalse(result.run_windows_tests) | ||
| 107 | + | ||
| 108 | + def test_msi(self): | ||
| 109 | + for f in ( | ||
| 110 | + ".github/workflows/reusable-windows-msi.yml", | ||
| 111 | + "Tools/msi/build.bat", | ||
| 112 | + ): | ||
| 113 | + with self.subTest(f=f): | ||
| 114 | + result = process_changed_files({Path(f)}) | ||
| 115 | + self.assertTrue(result.run_windows_msi) | ||
| 116 | + | ||
| 117 | + def test_all_run(self): | ||
| 118 | + for f in ( | ||
| 119 | + ".github/workflows/some-new-workflow.yml", | ||
| 120 | + ".github/workflows/build.yml", | ||
| 121 | + ): | ||
| 122 | + with self.subTest(f=f): | ||
| 123 | + result = process_changed_files({Path(f)}) | ||
| 124 | + self.assertTrue(result.run_tests) | ||
| 125 | + self.assertTrue(result.run_android) | ||
| 126 | + self.assertTrue(result.run_ios) | ||
| 127 | + self.assertTrue(result.run_macos) | ||
| 128 | + self.assertTrue(result.run_ubuntu) | ||
| 129 | + self.assertTrue(result.run_wasi) | ||
| 130 | + | ||
| 131 | + def test_all_ignored(self): | ||
| 132 | + for f in RUN_TESTS_IGNORE: | ||
| 133 | + with self.subTest(f=f): | ||
| 134 | + self.assertEqual(process_changed_files({Path(f)}), Outputs()) | ||
| 135 | + | ||
| 136 | + def test_wasi_and_android(self): | ||
| 137 | + f = {Path(".github/workflows/reusable-wasi.yml"), Path("Android/file")} | ||
| 138 | + result = process_changed_files(f) | ||
| 139 | + self.assertTrue(result.run_tests) | ||
| 140 | + self.assertTrue(result.run_wasi) | ||
| 141 | + | ||
| 142 | + | ||
| 143 | + if __name__ == "__main__": | ||
| 144 | + unittest.main() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,19 +225,27 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: | |||
| 225 | 225 | ||
| 226 | 226 | if file.parent == GITHUB_WORKFLOWS_PATH: | |
| 227 | 227 | if file.name in ("build.yml", "reusable-cifuzz.yml"): | |
| 228 | - run_tests = run_ci_fuzz = run_ci_fuzz_stdlib = True | ||
| 228 | + run_tests = run_ci_fuzz = run_ci_fuzz_stdlib = run_windows_tests = True | ||
| 229 | 229 | has_platform_specific_change = False | |
| 230 | + continue | ||
| 230 | 231 | if file.name == "reusable-docs.yml": | |
| 231 | 232 | run_docs = True | |
| 233 | + continue | ||
| 234 | + if file.name == "reusable-windows.yml": | ||
| 235 | + run_tests = True | ||
| 236 | + run_windows_tests = True | ||
| 237 | + continue | ||
| 232 | 238 | if file.name == "reusable-windows-msi.yml": | |
| 233 | 239 | run_windows_msi = True | |
| 240 | + continue | ||
| 234 | 241 | if file.name == "reusable-macos.yml": | |
| 235 | 242 | run_tests = True | |
| 236 | 243 | platforms_changed.add("macos") | |
| 244 | + continue | ||
| 237 | 245 | if file.name == "reusable-wasi.yml": | |
| 238 | 246 | run_tests = True | |
| 239 | 247 | platforms_changed.add("wasi") | |
| 240 | - continue | ||
| 248 | + continue | ||
| 241 | 249 | ||
| 242 | 250 | if not doc_file and file not in RUN_TESTS_IGNORE: | |
| 243 | 251 | run_tests = True | |
| Back | FazBrowse Home | New Git URL |
0 commit comments