tinymux/tests/format/Makefile
Stephen Dennis 8d3c59d848 test(build): track header dependencies in the standalone harnesses (#1952)
Editing a header a tests/ harness compiles against rebuilt nothing, so the
suite reported green against objects built from the previous version of the
header.  This is the failure mode that let #1949's negative control come
back 59 passed with the #1930 defect present in alloc.h.

-MMD -MP on every compile, -include of the generated .d files, and *.d in
each clean rule.  tests/libmux already got this in #1949; this is the
remaining eight.

The hand-written header prerequisite lists in color_ops, db and dbt stay.
They are what makes the FIRST build correct, before any .d exists; what
they cannot do is notice an #include nobody remembers to add, which is the
drift -MMD removes.

tests/hir takes the flags via CPPFLAGS rather than CXXFLAGS: that harness
declares CXXFLAGS with ?=, so a caller overriding it would silently drop
the dependency tracking -- the same shape as the bug being fixed.

tests/slave and tests/stubslave compile nothing (both are shell drivers)
and are unchanged.

Verified per harness rather than by inspection: build, read a header out of
the generated .d, touch it, require a rebuild -- 9 of 9 live.  Then checked
that the check itself has power by restoring master's tests/table/Makefile
and running both in the same tree against the same header: master prints
"Nothing to be done for 'all'", this branch recompiles and relinks.

make test: 30 targets, 29 passed, 1 skipped, 0 failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 00:06:02 -06:00

54 lines
2.1 KiB
Makefile

# Makefile — differential tests for mux_vsnprintf against the platform's
# snprintf (#1382 follow-up).
#
# mux_vsnprintf implements printf conversions by hand and used to abort the
# process via mux_assert(0) on any conversion it did not know -- which is how
# %f took the server down twice. %i, %o and the floating-point conversions
# are now implemented, with digits from mux_dtoa rather than the host libc,
# and an unimplemented spec is echoed literally instead of aborting (#1429).
# Hand-assembled float formatting needs an oracle, so these tests compare
# against snprintf over a wide corpus; the unimplemented-conversion cases
# cannot use that oracle, since echoing literally deliberately differs from
# printf.
#
# Links against libmux, which supplies mux_vsnprintf, mux_dtoa and mux_utoo.
# Needs a built tree: make install (from the repo root)
#
# Build: make
# Run: make test
CXX = g++
# -MMD -MP: emit header prerequisites next to each object (#1952). Without
# them the .o depends only on the .cpp, so editing a header this harness
# compiles against rebuilds nothing and the suite reports green against the
# previous header.
CXXFLAGS = -std=c++17 -g -O2 -Wall -Wextra -fPIC -MMD -MP
INCDIR = ../../mux/include
LIBDIR = ../../mux/lib
TARGET = test_format
all: $(TARGET)
test_format.o: test_format.cpp
$(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -I$(INCDIR) -c -o $@ $<
$(TARGET): test_format.o
$(CXX) $(CXXFLAGS) -o $@ $^ -L$(LIBDIR) -lmux -Wl,-rpath,$(LIBDIR)
# The source guard runs first and is independent of the built binary: it is
# the half that catches a BAD FORMAT BEING ADDED, which the runtime tests
# cannot see. Since #1429 an unsupported spec is echoed and the rest of the
# message dropped rather than aborting -- quieter in production, and quieter
# is exactly why the noise has to happen here.
test: $(TARGET)
python3 ./check_formats.py
LD_LIBRARY_PATH=$(LIBDIR):$$LD_LIBRARY_PATH ./$(TARGET)
clean:
rm -f $(TARGET) test_format.o test_format.d
# Generated by -MMD; absent on the first build, hence the leading '-'.
-include $(wildcard *.d)
.PHONY: all test clean