Hi,

Cyril Brulebois <k...@debian.org> (2018-12-28):
> It was a bit curious at first since I couldn't reproduce it in my sid
> amd64 devel chroot, but could in my sid amd64 sbuild chroot… Checking
> strace's output, it seemed like it might be that some leftover from a
> previous test might have been missing:
> 
>     […]/test/./target/empty.ini
> 
> so I've tried sorting the tests to run, and I've got a reproducible
> success, both inside devel & sbuild chroots.

Based on slightly different results in #907765 (where order matters but
natural sorting doesn't work[1]), I've decided to propose a different
patch: I've chosen to encode a sequence of tests that makes the test
suite run OK. This way, it should be obvious when new tests are added,
so that one can find and document a suitable sequence of tests.

 1. https://bugs.debian.org/907765#25


Cheers,
-- 
Cyril Brulebois (k...@debian.org)            <https://debamax.com/>
D-I release manager -- Release team member -- Freelance Consultant
diff -Nru trapperkeeper-status-clojure-0.7.1/debian/changelog trapperkeeper-status-clojure-0.7.1/debian/changelog
--- trapperkeeper-status-clojure-0.7.1/debian/changelog	2017-08-05 22:05:17.000000000 +0000
+++ trapperkeeper-status-clojure-0.7.1/debian/changelog	2018-12-29 00:14:15.000000000 +0000
@@ -1,3 +1,13 @@
+trapperkeeper-status-clojure (0.7.1-2) UNRELEASED; urgency=medium
+
+  * Fix FTBFS by running tests in a specific order. Instead of blindly
+    sorting the results of the find command and trusting it to be right,
+    encode a suitable sequence of tests (Closes: #880351). Also make sure
+    to error out when tests are added or removed, to make sure this
+    sequence get refreshed when needed.
+
+ -- Cyril Brulebois <k...@debian.org>  Sat, 29 Dec 2018 00:14:15 +0000
+
 trapperkeeper-status-clojure (0.7.1-1) unstable; urgency=medium
 
   * Initial release (Closes: #855744)
diff -Nru trapperkeeper-status-clojure-0.7.1/debian/rules trapperkeeper-status-clojure-0.7.1/debian/rules
--- trapperkeeper-status-clojure-0.7.1/debian/rules	2017-08-05 22:05:17.000000000 +0000
+++ trapperkeeper-status-clojure-0.7.1/debian/rules	2018-12-29 00:13:56.000000000 +0000
@@ -40,6 +40,18 @@
 	markdown $< >> $@
 	cat debian/footer.html >> $@
 
+# Tests can't run in a random order (#880351):
+override_dh_auto_test: ORDERED_TESTS=puppetlabs/trapperkeeper/services/status/check_test.clj puppetlabs/trapperkeeper/services/status/status_core_test.clj puppetlabs/trapperkeeper/services/status/status_proxy_service_test.clj puppetlabs/trapperkeeper/services/status/status_service_test.clj
+override_dh_auto_test: EXPECTED=$(shell echo "$(ORDERED_TESTS)" | sed 's/ /\n/g' | sort | xargs)
+override_dh_auto_test: FOUND=$(shell cd test && find -name '*.clj' | sed 's,^[.]/,,' | sort | xargs)
 override_dh_auto_test:
-	(cd test && find . -name "*.clj" | \
-		xargs --verbose clojure -cp $(CURDIR)/$(PRODUCED_JAR):$(CLASSPATH):$(TEST_CLASSPATH))
+	# Make sure to detect when tests appear or disappear:
+	@if [ "$(FOUND)" != "$(EXPECTED)" ]; then \
+		echo "E: sanity check failed, available tests don't match known tests:"; \
+		echo "    - found:    $(FOUND)"; \
+		echo "    - expected: $(EXPECTED)"; \
+		echo "=> Please update ORDERED_TESTS in debian/rules accordingly"; \
+		exit 1; \
+	fi
+	# Run tests:
+	(cd test && clojure -cp $(CURDIR)/$(PRODUCED_JAR):$(CLASSPATH):$(TEST_CLASSPATH) $(ORDERED_TESTS))

Attachment: signature.asc
Description: PGP signature

Reply via email to