Skip to content

Commit

Permalink
Build the cache warmer test before any other (including everything in…
Browse files Browse the repository at this point in the history
… the plugins directory)

Update the "tests failed" output to be a little bit more friendly
  • Loading branch information
obra committed Dec 14, 2023
1 parent f518a94 commit ec00315
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 11 deletions.
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/bin/
**/lib/
**/obj/
_cache-warmer/warm-cache/generated-all-plugins.h
72 changes: 61 additions & 11 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,65 @@ include $(top_dir)/etc/makefiles/arduino-cli.mk
KALEIDOSCOPE_ETC_DIR ?= $(top_dir)/etc

.PHONY: all
all: ${libcommon_a} googletest ${TESTS}
all: ${libcommon_a} googletest ${TESTS}
@:

.PHONY: cmake-clean
cmake-clean:
rm -rf "${top_dir}"/testing/googletest/build/*

run-all: ${TESTS}
@for test in ${TESTS}; do \
${MAKE} -s -f ${top_dir}/testing/makefiles/testcase.mk \
-C $${test} \
testcase=$${test} run || ERROR=$$?; \
.PHONY: run-all
run-all: generate-all-plugins-header run-cache-warmer run-other-tests aggregate-test-results

.PHONY: run-cache-warmer
run-cache-warmer: $(filter ./_cache-warmer/%,${TESTS})

.PHONY: run-other-tests
run-other-tests: run-cache-warmer
@$(MAKE) $(filter-out ./_cache-warmer/%,${TESTS})


${TESTS}: ${libcommon_a} googletest
$(QUIET) { \
$(MAKE) -s -f ${top_dir}/testing/makefiles/testcase.mk -C $@ testcase=$@ build run; \
if [ $$? -ne 0 ]; then \
hash=$$(echo "$$@" | shasum | cut -f1 -d' '); \
echo "$@ failed" > ${build_dir}/test_failures_$$hash.log; \
fi; \
}


.PHONY: aggregate-test-results
aggregate-test-results: run-other-tests
$(QUIET) TEST_ERRORS=0; \
for file in ${build_dir}/test_failures_*.log; do \
if [ -f "$$file" ]; then \
TEST_ERRORS=$$((TEST_ERRORS + 1)); \
cat "$$file" >> ${build_dir}/combined_test_failures.log; \
rm -f "$$file"; \
fi; \
done; \
if [ -n $${ERROR} ]; then exit $${ERROR}; fi
if [ -f ${build_dir}/combined_test_failures.log ]; then \
echo "Test failures: $$TEST_ERRORS"; \
cat ${build_dir}/combined_test_failures.log; \
rm -f ${build_dir}/combined_test_failures.log; \
exit 1; \
else \
$(QUIET) echo "All tests passed."; \
fi





.PHONY: clean
clean: cmake-clean
@for test in ${TESTS}; do \
$(QUIET) for test in ${TESTS}; do \
${MAKE} -s -f ${top_dir}/testing/makefiles/testcase.mk \
-C $${test} \
testcase=$${test} clean; \
done
rm -rf "${build_dir}"/*
$(QUIET) rm -rf "${build_dir}"/*

.PHONY: googletest
googletest: ${top_dir}/testing/googletest/build/Makefile
Expand All @@ -92,5 +128,19 @@ ${libcommon_a}:
Makefile:
@:

${TESTS}: ${libcommon_a} googletest
$(QUIET) ${MAKE} -f ${top_dir}/testing/makefiles/testcase.mk -C $@ testcase=$@ build run


.PHONY: generate-all-plugins-header
generate-all-plugins-header:
$(QUIET) echo "// This file is generated automatically. Do not edit." > _cache-warmer/warm-cache/generated-all-plugins.h
$(QUIET) for dir in ../plugins/*; do \
if [ -d "$$dir" ]; then \
header_path="$$dir/$$(basename $$dir).h"; \
header_src_path="$$dir/src/$$(basename $$dir).h"; \
header="$$(basename $$dir).h"; \
if [ -f "$$header_path" -o -f "$$header_src_path" ]; then \
echo '#include "'$$header'"' >> _cache-warmer/warm-cache/generated-all-plugins.h; \
fi; \
fi; \
done

0 comments on commit ec00315

Please sign in to comment.