Hi Ian, > This patch to the libgo gotest script runs examples when appropriate > in the libgo testsuite. An example with a "// Output:" comment is > supposed to be run, comparing the output of the example with the text > in the comment. Up until now we were not actually doing that, so we > were in effect skipping some tests. This changes that. The changes > to the script are not fully general for all Go code, but should be > sufficient for the code that actually appears in libgo. One example > had to be tweaked to match the output generated by gccgo. > > This patch also cleans up some cruft in gotest, and should fix GCC PR 89168. > > Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed > to mainline.
this patch badly broke a couple of tests on Solaris (10 and 11) with CONFIG_SHELL=/bin/ksh. E.g. _testmain.go:90:63: error: unterminated string 90 | {"ExampleScanner_custom", bufio_test.ExampleScanner_custom, " | ^ _testmain.go:91:1: error: expected ',' or '}' 91 | 1234 | ^ _testmain.go:93:42: error: invalid character 0x5c in input file 93 | Invalid input: strconv.ParseInt: parsing \"1234567901234567890\": value out of range", false}, | ^ _testmain.go:95:2: error: need trailing comma before newline in composite literal 95 | } | ^ FAIL: bufio make: *** [bufio/check] Error 1 where _testmain.go contains var examples = []testing.InternalExample{ // {"ExampleWriter", bufio_test.ExampleWriter, "Hello, world!", false}, {"ExampleScanner_words", bufio_test.ExampleScanner_words, "15", false}, {"ExampleScanner_custom", bufio_test.ExampleScanner_custom, " 1234 5678 Invalid input: strconv.ParseInt: parsing \"1234567901234567890\": value out of range", false}, Running with SHELL=/bin/bash doesn't make a difference either. It turns out that echo changes '\n' into literal newlines in multiline Output: comments. Looking at what configure does, I found that it uses printf %s instead of echo. Changing gotest accordingly in two places fixes the issue. I'm uncertain how to properly fix this: while autoconf defines an AS_ECHO macro, the underlying as_echo variable which could be substituted into gotest.in isn't documented. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University
# HG changeset patch # Parent 944925b73419b10399217b1e837c5ed54408b373 Fix gotest handling of multiline Output: on Solaris diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest --- a/libgo/testsuite/gotest +++ b/libgo/testsuite/gotest @@ -627,13 +627,13 @@ symtogo() { -e 's/[ ]*$/\\n/g' | tr -d '\n')" # Remove leading and trailing \n. - output="$(echo "$output" | sed -e 's/^\(\\n\)*//' -e 's/\(\\n\)*$//')" + output="$(printf %s "$output" | sed -e 's/^\(\\n\)*//' -e 's/\(\\n\)*$//')" hasoutput=true rm -f example.txt break done if test x$hasoutput = xtrue; then - echo ' {"'$n'", '$j', "'"$output"'", '$unordered'},' + printf %s ' {"'$n'", '$j', "'"$output"'", '$unordered'},' fi done echo '}'