Re: [PATCH] t5541: don't call start_httpd after sourcing lib-terminal.sh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 14, 2014 at 10:18:32PM +0100, Jens Lehmann wrote:

> Since 83d842dc8 "make test" using prove fails for some setups in t5541
> with:
> 
>    "Parse errors: No plan found in TAP output"
> 
> Running t5541 on its own fails with:
> 
>    "error: Can't use skip_all after running some tests"
> 
> This happens because "start_httpd" (which determines if the test is to
> be skipped) is called after sourcing lib-terminal.sh (which sets up the
> terminal using test_expect_success).
> 
> Fix that by calling "start_httpd" before sourcing lib-terminal.sh.

Thanks, your solution seems reasonable. lib-terminal runs a test behind
our back when we source it, which is a little funny.

Potentially we could turn its test into a lazy prereq, but I think that
does not quite work. In addition to setting the TTY prereq, it defines
the test_terminal function, and lazy prereqs happen in a subshell, IIRC.

One option would be to _always_ define test_terminal. Right now we rely
on it failing to exist to catch tests which should fail to correctly
depend on the TTY prerequisite. But we could just as easily have it
report failure in such a case.

Something like the patch below (looks like we should be using $PERL_PATH
instead of "perl", too).

> Since recently t5541 fails for me on master and pu. I'm not sure what
> detail in my setup causes this breakage (I have httpd installed and it
> is running), but this patch fixes it for me.

Yeah, this is because we now try to run the tests by default, and skip
them if webserver setup fails. If you want to know why it's failing on
your machine, try running with "-v -i" to see output, and/or looking in
httpd/error.log in the trash directory.

---
diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh
index 9a2dca5..55b708f 100644
--- a/t/lib-terminal.sh
+++ b/t/lib-terminal.sh
@@ -1,35 +1,36 @@
 # Helpers for terminal output tests.
 
-test_expect_success PERL 'set up terminal for tests' '
+# Catch tests which should depend on TTY but forgot to. There's no need
+# to check that TTY is set here. If the test declared it and we are running
+# it, then it is set.
+test_terminal() {
+	if ! test_declared_prereq TTY
+	then
+		echo >&4 "test_terminal: need to declare TTY prerequisite"
+		return 127
+	fi
+	perl "$TEST_DIRECTORY"/test-terminal.perl "$@"
+}
+
+test_lazy_prereq TTY '
+	test_have_prereq PERL &&
+
 	# Reading from the pty master seems to get stuck _sometimes_
 	# on Mac OS X 10.5.0, using Perl 5.10.0 or 5.8.9.
 	#
 	# Reproduction recipe: run
 	#
 	#	i=0
 	#	while ./test-terminal.perl echo hi $i
 	#	do
 	#		: $((i = $i + 1))
 	#	done
 	#
 	# After 2000 iterations or so it hangs.
 	# https://rt.cpan.org/Ticket/Display.html?id=65692
 	#
-	if test "$(uname -s)" = Darwin
-	then
-		:
-	elif
-		perl "$TEST_DIRECTORY"/test-terminal.perl \
-			sh -c "test -t 1 && test -t 2"
-	then
-		test_set_prereq TTY &&
-		test_terminal () {
-			if ! test_declared_prereq TTY
-			then
-				echo >&4 "test_terminal: need to declare TTY prerequisite"
-				return 127
-			fi
-			perl "$TEST_DIRECTORY"/test-terminal.perl "$@"
-		}
-	fi
+	test "$(uname -s)" != Darwin &&
+
+	perl "$TEST_DIRECTORY"/test-terminal.perl \
+		sh -c "test -t 1 && test -t 2"
 '
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]