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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ lit-coverage:
@echo "Running lit tests with coverage"
$(DIALECTS_BUILD_DIR)/bin/catalyst --tool=opt --emit-bytecode --register-decomp-rule-resource $(MK_DIR)/frontend/test/lit/GraphDecomposition/test_rules.mlir > $(MK_DIR)/frontend/test/lit/GraphDecomposition/test_rules.mlirbc
CATALYST_LIBPYTHON=$$($(PYTHON) -c 'from catalyst.utils.runtime_environment import get_libpython_path; print(get_libpython_path())') ENABLE_LIT_COVERAGE=1 COVERAGE_FILE=$(MK_DIR)/.coverage.lit $(PYTHON) $(LLVM_BUILD_DIR)/bin/llvm-lit -sv frontend/test/lit -j$(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)
# Each lit worker writes its own .coverage.lit.<host>.<pid>.<random>; merge them into
# .coverage.lit, which coverage-frontend then combines with the pytest data.
$(PYTHON) -m coverage combine --data-file=$(MK_DIR)/.coverage.lit

coverage-frontend:
ifeq ($(ENABLE_ASAN),ON)
Expand Down
5 changes: 4 additions & 1 deletion frontend/test/lit/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@
config.environment["COVERAGE_FILE"] = os.environ.get(
"COVERAGE_FILE", os.path.join(project_root, ".coverage.lit")
)
# lit runs tests in parallel, and coverage's data file is a SQLite database that does not
# tolerate concurrent writers. `--parallel-mode` gives each process its own
# `.coverage.lit.<host>.<pid>.<random>` file, which `coverage combine` merges afterwards.
python_executable = (
f"{python_executable} -m coverage run --source={catalyst_source} --append --branch"
f"{python_executable} -m coverage run --source={catalyst_source} --parallel-mode --branch"
)

config.substitutions.append(("%PYTHON", python_executable))
Expand Down
Loading