Merge pull request #214 from thaJeztah/19.03_backport_log-daemon-exit-before-tests-finish

[19.03 backport] Ensure all integration daemon logging happens before test exit
diff --git a/internal/test/daemon/daemon.go b/internal/test/daemon/daemon.go
index d9bf53d..cb94d80 100644
--- a/internal/test/daemon/daemon.go
+++ b/internal/test/daemon/daemon.go
@@ -271,8 +271,11 @@
 	wait := make(chan error)
 
 	go func() {
-		wait <- d.cmd.Wait()
+		ret := d.cmd.Wait()
 		d.log.Logf("[%s] exiting daemon", d.id)
+		// If we send before logging, we might accidentally log _after_ the test is done.
+		// As of Go 1.12, this incurs a panic instead of silently being dropped.
+		wait <- ret
 		close(wait)
 	}()