From dbaee8b4912036e8080cc32369b76e690487c6b6 Mon Sep 17 00:00:00 2001 From: Yaqiang Zhu Date: Wed, 25 Dec 2024 15:11:05 +0800 Subject: [PATCH] Fail build when test fail (#53) Why I did it In current PR check, we would build dhcp6relay debian package, but even if the unit test failed, the build would still be ongoing, then the PR check would pass. It would cause we miss some unexpected damage change image How I did it Modify Makefile to exit with code 1 if test fail How I verify it PR check --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eb77866..00d2e54 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ $(DHCP6RELAY_TEST_TARGET): $(TEST_OBJS) $(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LDLIBS_TEST) -o $@ test: $(DHCP6RELAY_TEST_TARGET) - sudo ASAN_OPTIONS=detect_leaks=0 ./$(DHCP6RELAY_TEST_TARGET) --gtest_output=xml:$(DHCP6RELAY_TEST_TARGET)-test-result.xml || true + sudo ASAN_OPTIONS=detect_leaks=0 ./$(DHCP6RELAY_TEST_TARGET) --gtest_output=xml:$(DHCP6RELAY_TEST_TARGET)-test-result.xml || { echo 'Tests failed'; exit 1; } $(GCOVR) -r ./ --html --html-details -o $(DHCP6RELAY_TEST_TARGET)-code-coverage.html $(GCOVR) -r ./ --xml-pretty -o $(DHCP6RELAY_TEST_TARGET)-code-coverage.xml