Skip to content

Interrupt ctest and get a report?

It would be nice if we can Ctrl+C after make Project/test and see the report for tests that completed so far. There are at least 2 issues

  1. ctest does not produce the Testing/20210716-1434/Test.xml file when interrupted
  2. when we interrupt make, the rule does not finish so we might need some magic like
diff --git project.mk project.mk
index 39debca..692d4e7 100644
--- project.mk
+++ project.mk
@@ -118,9 +118,10 @@ endif
 # the XML output from ctest.
 test: $(BUILDDIR)/$(BUILD_CONF_FILE)
        $(RM) -r $(BUILDDIR)/Testing
-       -cd $(BUILDDIR) && $(CTEST) -T test $(value ARGS)
-       $(RM) -r $(BUILDDIR)/html
-       +@cd $(BUILDDIR) && $(CMAKE) -P $(DIR)/CTestXML2HTML.cmake
+  bash -c " \
+               trap 'cd $(BUILDDIR); rm -rf html; $(CMAKE) -P $(DIR)/CTestXML2HTML.cmake' EXIT; \
+               cd $(BUILDDIR) && $(CTEST) -T test $(value ARGS) \
+       "

 install: all
        cd $(BUILDDIR) && $(CMAKE) -P cmake_install.cmake | grep -v "^-- Up-to-date:"