1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
############################################
#
# Structure of the Makefile
# * Some defaults
# * One-time preparation of mails used for testing.
# * Targets for the whole test suite
# * Targets for a single test
# * Targets for overall maintenance
#
# Important Targets:
# test -- runs all tests. Stops at the first failing test
# check -- runs all tests. Continues after failed tests
# clean -- removes all logs, etc from running tests
# distclean -- removes all generated files
#
############################################
############################################
# Defaults
#
# the used mairix
MAIRIX_EXE=../mairix
# the place for helper scripts
SCRIPT_DIR=scripts
# Each file ending in .test-spec signifies a test
TEST_SPEC_FILES=$(shell ls -1 *.test-spec )
TESTS=$(TEST_SPEC_FILES:%.test-spec=%)
all: check
############################################
# One-time preparation of mails used for testing.
#
# - big messages are generated by a script when testing.
# (Shipping them directly would unnecessary increase source-code size.)
# - mboxen are split into individual messages for easier reference.
#
# big messages:
BIG_MESSAGES_INDICES=1 2 3 4
BIG_MESSAGES=$(BIG_MESSAGES_INDICES:%=messages/mh/BigMessages/%)
big-messages: $(BIG_MESSAGES)
messages/mh/BigMessages/%:
$(SCRIPT_DIR)/generate_big_message.sh $@
# splitting the mboxen
.split_mboxen_marker:
find messages/mbox -type f -exec $(SCRIPT_DIR)/split_mbox.sh {} \;
touch $@
# message-preparations is used to assert all required preprocessing is done
message-preparations: .split_mboxen_marker big-messages
# maintenance for the generated files
distclean-message-preparations:
-rm -f .split_mboxen_marker
-rm -rf messages/mbox_split
-rm -rf $(BIG_MESSAGES)
############################################
# Targets for the whole test suite
#
# test runs all tests and aborts upon errer
test: clean $(TESTS:%=test-%)
# check runs all tests but does not abort upon error.
# It collects results and presents them in a summary.
# Finally this target fails if any test did not succeed
check: clean $(TESTS:%=%.status)
$(SCRIPT_DIR)/print_test_statistics.sh
if grep '^[^#]*\(dump_database\|log_remaining_matched_unasserted_messages\)' $(TEST_SPEC_FILES) ; then echo ; echo "Above files use dump_database or log_remaining_matched_unasserted_messages. But they should only be used when developing tests. Aborting" >&2 ; exit 1 ; fi
# clean removes the logs and outcomes of all tests
clean-tests: $(TESTS:%=clean-%)
############################################
# Targets for a single test
#
# almostclean-TEST removes the logs for the test TEST, but not the outcome of the test
almostclean-%:
-rm -rf $(@:almostclean-test-%=%.data)
# almostclean-TEST removes the logs and outcome for the test TEST
clean-%: almostclean-test-%
-rm -f $(@:clean-%=%.status)
# test-TEST runs the test TEST, aborting on failure
test-%: %.test-spec message-preparations almostclean-test-% $(MAIRIX_EXE)
$(SCRIPT_DIR)/test.sh $<
# TEST.status runs the test TEST, not aborting on failure, but collecting the outcome in TEST.status. Either "failed" if the test fauled, or "passed", if the test passed
%.status: %.test-spec $(MAIRIX_EXE)
echo "failed" >$@
$(MAKE) test-$(<:%.test-spec=%) && \
echo "passed" >$@ || \
echo "Test $< did not succeed."
############################################
# Maintenance targets
#
clean: clean-tests
distclean: clean distclean-message-preparations
|