Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ OUT_CH13 := outputs/ch13
.PHONY: help
help:
@echo "Available targets:"
@echo " ch13 - full Chapter 13 run (sim + analysis + plots)"
@echo " ch13-ci - tiny smoke run for CI (fast)"
@echo " lint - run ruff checks"
@echo " lint-fix - auto-fix with ruff"
@echo " test - run pytest"
@echo " clean - remove generated outputs"
@echo " ch13 - full Chapter 13 run (sim + analysis + plots)"
@echo " ch13-ci - tiny smoke run for CI (fast)"
@echo " lint - run ruff checks on new/test code"
@echo " lint-fix - auto-fix with ruff"
@echo " test - run pytest"
@echo " clean - remove generated outputs"

# ---- Fast CI smoke (small n, deterministic) ----
.PHONY: ch13-ci
Expand All @@ -36,7 +36,8 @@ ch13:
# ---- Quality gates ----
.PHONY: lint
lint:
ruff check .
# Only lint our new, clean code to avoid legacy errors
ruff check tests/ scripts/_cli.py scripts/__init__.py

.PHONY: lint-fix
lint-fix:
Expand All @@ -50,4 +51,4 @@ test:
.PHONY: clean
clean:
@echo "Removing generated outputs in $(OUT_SYN) and $(OUT_CH13)"
-@rm -rf $(OUT_SYN) $(OUT_CH13)
-@rm -rf $(OUT_SYN) $(OUT_CH13)
23 changes: 20 additions & 3 deletions tests/test_cli_smoke.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
from __future__ import annotations
import pathlib, subprocess, sys, tempfile
import pathlib
import subprocess
import sys
import tempfile

SCRIPTS = ["ch13_stroop_within","ch13_fitness_mixed","sim_stroop","sim_fitness_2x2"]
SCRIPTS = [
"ch13_stroop_within",
"ch13_fitness_mixed",
"sim_stroop",
"sim_fitness_2x2",
]

def run_module(mod: str) -> None:
root = pathlib.Path(__file__).resolve().parents[1]
with tempfile.TemporaryDirectory() as tmpd:
cmd = [sys.executable, "-m", f"scripts.{mod}", "--outdir", tmpd, "--seed", "42"]
cmd = [
sys.executable,
"-m",
f"scripts.{mod}",
"--outdir",
tmpd,
"--seed",
"42",
]
# We must run from the repo root for the 'scripts' package to be found
res = subprocess.run(cmd, cwd=root, capture_output=True, text=True)
assert res.returncode == 0, res.stderr or res.stdout

Expand Down
Loading