diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 40e59683..35cf6253 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -359,7 +359,7 @@ jobs: - name: Install dependencies run: | python -m pip install --no-cache-dir --upgrade pip - python -m pip install --no-cache-dir build + python -m pip install --no-cache-dir build pytest make install-no-extras-for-test - name: Show dependencies diff --git a/Makefile b/Makefile index 73cced08..68ac230b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -clean: clean-pyc clean-ipynb clean-catboost clean-build clean-test +clean: clean-pyc clean-ipynb clean-catboost clean-build clean-test clean-progress_board clean-progress_board: find . -name '*.csv~' -exec rm -f {} + @@ -30,16 +30,16 @@ clean-test: test-search_space: cd tests/; \ - i=0; while [ "$$i" -le 100 ]; do \ + i=0; while [ "$$i" -lt 100 ]; do \ i=$$((i + 1));\ pytest -q test_search_spaces.py; \ done test-pytest: - python -m pytest --durations=10 -x -p no:warnings tests/; \ + python -m pytest --durations=10 -x -p no:warnings tests/ test-src: - python -m pytest --durations=10 --verbose -x -p no:warnings src/hyperactive/; \ + python -m pytest --durations=10 --verbose -x -p no:warnings src/hyperactive/ test-timings: cd tests/_local_test_timings; \ @@ -54,12 +54,12 @@ test-examples: cd tests; \ python _test_examples.py -test-extensive: test test-local test-examples +test-extensive: test test-examples push: test git push -release: reinstall test-extensive +release: reinstall build test-extensive python -m twine upload dist/* dist: @@ -87,7 +87,7 @@ install-all-extras: python -m pip install --no-cache-dir .[all_extras] install-no-extras-for-test: - python -m pip install --no-cache-dir .[test] + python -m pip install --no-cache-dir . install-all-extras-for-test: python -m pip install --no-cache-dir .[all_extras,test,test_parallel_backends,sktime-integration] diff --git a/tests/test_makefile.py b/tests/test_makefile.py new file mode 100644 index 00000000..ff0a6904 --- /dev/null +++ b/tests/test_makefile.py @@ -0,0 +1,92 @@ +"""Regression tests for Makefile targets and build/test recipes.""" + +import re +import unittest +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[1] +MAKEFILE_PATH = REPO_ROOT / "Makefile" + + +def _parse_targets(makefile_text: str) -> dict[str, tuple[list[str], list[str]]]: + """Parse Makefile targets into {name: (prerequisites, recipe_lines)}.""" + targets: dict[str, tuple[list[str], list[str]]] = {} + current_target: str | None = None + for line in makefile_text.splitlines(): + if not line or line.lstrip().startswith("#"): + if not line: + current_target = None + continue + if line.startswith("\t"): + if current_target is not None: + targets[current_target][1].append(line.lstrip("\t")) + continue + match = re.match(r"^([A-Za-z0-9_.-]+)\s*:\s*(.*)$", line) + if match: + name = match.group(1) + prereqs = match.group(2).split() + targets[name] = (prereqs, []) + current_target = name + else: + current_target = None + return targets + + +class TestMakefileTargets(unittest.TestCase): + """Verify Makefile targets satisfy issue #244 requirements.""" + + @classmethod + def setUpClass(cls) -> None: + """Load and parse the repository Makefile.""" + cls.makefile_text = MAKEFILE_PATH.read_text(encoding="utf-8") + cls.targets = _parse_targets(cls.makefile_text) + + def test_clean_includes_clean_progress_board(self) -> None: + """Verify clean target includes clean-progress_board.""" + prereqs, _ = self.targets["clean"] + self.assertIn("clean-progress_board", prereqs) + + def test_test_extensive_avoids_duplicate_test_local(self) -> None: + """Verify test-extensive does not redundantly include test-local.""" + test_prereqs, _ = self.targets["test"] + extensive_prereqs, _ = self.targets["test-extensive"] + self.assertIn("test-local", test_prereqs) + self.assertIn("test", extensive_prereqs) + self.assertNotIn("test-local", extensive_prereqs) + + def test_test_pytest_and_src_have_no_trailing_continuation(self) -> None: + """Verify single-command pytest targets have no trailing continuation.""" + for target_name in ("test-pytest", "test-src"): + _, recipe = self.targets[target_name] + self.assertTrue(recipe, f"Expected recipe for {target_name}") + self.assertFalse( + recipe[-1].rstrip().endswith("; \\"), + f"{target_name} recipe ends with unnecessary '; \\'", + ) + + def test_install_no_extras_for_test_omits_extras(self) -> None: + """Verify install-no-extras-for-test installs without [test] extra.""" + _, recipe = self.targets["install-no-extras-for-test"] + self.assertEqual( + recipe, + ["python -m pip install --no-cache-dir ."], + ) + + def test_release_depends_on_build_or_dist(self) -> None: + """Verify release target declares build or dist prerequisite.""" + prereqs, _ = self.targets["release"] + self.assertTrue( + "build" in prereqs or "dist" in prereqs, + f"release prerequisites {prereqs} omit build/dist", + ) + + def test_test_search_space_runs_100_iterations(self) -> None: + """Verify test-search_space executes exactly 100 iterations.""" + _, recipe = self.targets["test-search_space"] + joined = "\n".join(recipe) + self.assertNotRegex(joined, r"i=0;.*-le\s+100") + self.assertRegex(joined, r"(i=0;.*-lt\s+100|i=1;.*-le\s+100)") + + +if __name__ == "__main__": + unittest.main()