# Runs every regression check under audit/ against this tree's built artifacts
# (build/bin/runtime_interop_server, build/example/living-server, build/molo, and
# a few checks that compile a tiny harness straight from src/).
# Usage:
#   make -C audit test          # sequential, stops at the first FAIL
#   make -C audit -j8 test      # concurrent, one job per check directory (recursive make)
#   make -C audit report        # runs every check, never stops, prefixes output with the check id
#   make -C audit list          # names the check directories this covers
#
# Each check's Makefile delegates to that directory's reproduce.py or reproduce.cpp,
# which prints exactly one of PASS, FAIL or SKIP and exits 0 for PASS/SKIP, 1 for FAIL.
# "test" is the hard cap: this file does not invent new checks, it only fans out to
# the fixed, named list below. See README.md.

MOLO_BUILD ?= $(abspath ../build)
CHECKS := $(sort $(wildcard MOLO-*))
export MOLO_BUILD

.PHONY: test $(CHECKS) list report

test: $(CHECKS)
	@echo "audit: $(words $(CHECKS)) checks run against $(MOLO_BUILD)"

$(CHECKS):
	@$(MAKE) -s -C $@ test MOLO_BUILD=$(MOLO_BUILD)

list:
	@for c in $(CHECKS); do echo $$c; done

report:
	@status=0; for c in $(CHECKS); do \
		$(MAKE) -s -C $$c test MOLO_BUILD=$(MOLO_BUILD) 2>&1 | sed "s/^/$$c: /" || status=1; \
	done; exit $$status
