]> gcc.gnu.org Git - gcc.git/commitdiff
libgo: compile examples in _test packages
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 9 Jan 2020 23:14:57 +0000 (23:14 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 9 Jan 2020 23:14:57 +0000 (23:14 +0000)
    Previously if the only names defined by _test packages were examples,
    the gotest script would emit an incorrect _testmain.go file.
    I worked around that by marking the example_test.go files +build ignored.

    This CL changes the gotest script to handle this case correctly,
    and removes the now-unnecessary build tags.

    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214039

From-SVN: r280085

44 files changed:
gcc/go/gofrontend/MERGE
libgo/go/compress/flate/example_test.go
libgo/go/compress/gzip/example_test.go
libgo/go/container/ring/example_test.go
libgo/go/crypto/sha256/example_test.go
libgo/go/database/sql/example_cli_test.go
libgo/go/database/sql/example_service_test.go
libgo/go/encoding/csv/example_test.go
libgo/go/encoding/hex/example_test.go
libgo/go/encoding/json/example_marshaling_test.go
libgo/go/encoding/json/example_text_marshaling_test.go
libgo/go/encoding/pem/example_test.go
libgo/go/encoding/xml/example_marshaling_test.go
libgo/go/encoding/xml/example_text_marshaling_test.go
libgo/go/fmt/example_test.go
libgo/go/fmt/gostringer_example_test.go
libgo/go/fmt/stringer_example_test.go
libgo/go/go/types/example_test.go
libgo/go/hash/crc32/example_test.go
libgo/go/hash/example_test.go
libgo/go/html/example_test.go
libgo/go/html/template/example_test.go
libgo/go/html/template/examplefiles_test.go
libgo/go/image/draw/example_test.go
libgo/go/image/png/example_test.go
libgo/go/index/suffixarray/example_test.go
libgo/go/io/ioutil/example_test.go
libgo/go/io/ioutil/testdata/hello [new file with mode: 0644]
libgo/go/log/syslog/example_test.go
libgo/go/math/big/example_rat_test.go
libgo/go/math/big/floatexample_test.go
libgo/go/math/bits/example_test.go
libgo/go/math/cmplx/example_test.go
libgo/go/mime/example_test.go
libgo/go/mime/quotedprintable/example_test.go
libgo/go/net/http/cookiejar/dummy_publicsuffix_test.go
libgo/go/net/http/cookiejar/example_test.go
libgo/go/net/http/httptrace/example_test.go
libgo/go/net/http/httputil/example_test.go
libgo/go/net/mail/example_test.go
libgo/go/path/filepath/example_test.go
libgo/go/runtime/trace/example_test.go
libgo/go/text/scanner/example_test.go
libgo/testsuite/gotest

index e712bef13324e7b7f1560623e031cb3f443036b4..9189bed5e89d923341dddf5a45cc55a6a209292a 100644 (file)
@@ -1,4 +1,4 @@
-f9d1bfb3eec2d388c5f239779fd25a580064dd9d
+92ee4c2e295fc760105f187f6ea6dc65c81fa892
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 3d44dde7ae1f6d4896b54109a06cceb99ac08d41..578009248f5704d89eef7a3fb6adee2e4c6b8ecd 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package flate_test
 
 import (
index 4764bcb090adff2cf2567ee29919cb00b2586f8f..ce29e9ba3656ed1e0b9eeaa3e6ddbd2373735672 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package gzip_test
 
 import (
index d8f16390eef9abc7ef4783c1871c4eb1d6e1c146..30bd0d74c9eee01d444f50d15ef69ab8fefec24c 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package ring_test
 
 import (
index 89d5c977787ba00162bd5da5c6733b1678a5202f..7d73120155cab815bf542fefebb48e57b0300387 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package sha256_test
 
 import (
index c87c508a1412c60034520b1613662934c7daf6b4..8c61d755bb8458f0a1116019a84b08741406b355 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package sql_test
 
 import (
index 7605e2f75d382c497cfc8b5c7a410268358da29f..768307c1471a7875d4e804addcd053cff2dc2ca0 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package sql_test
 
 import (
index e3c3bd51228633888a7844e83a9a047e2717812a..dc227d4c8ba85e00783c5fe4daca299cb5f7cf3c 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package csv_test
 
 import (
index fb1554eba7e9f5c9a46f9db89e88097ec1bbfd5c..3580757a541d6188764515ac9401cbc91a8221c6 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package hex_test
 
 import (
index 1c4f783a693fb806a3ebfde38c2dc82e9d7e222d..7f15c742b8ef86d4a86711f45b93bc8390f601a1 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package json_test
 
 import (
index a8a3f830f68d5ac99f452f755d1d50ef0903d11f..04c7813b2678355a68fe9be74a7424bb78248050 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package json_test
 
 import (
index 22081b4d8acd8b68a147d497697f9ef9a231673f..806e7bbbf72e881461b4a9a14d3307106947847e 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package pem_test
 
 import (
index 04d3470cac0ec4bae36314f53e7f17efc374b35c..9f9e801e74ecad91d55213ef136e43ec5aad7714 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package xml_test
 
 import (
index 8d1f33257835729b240d32c92beeb936d2097256..2549cb16ae54f9476aeb55260b20e441cb8fa731 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package xml_test
 
 import (
index ae60abef0b29d53a495b6bf1fdfe2d2dec1605b2..5962834226b9d58564eafa1b240a9ff4e99171fc 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package fmt_test
 
 import (
index 7c6b9f0545334aba5c5e31b4f203a4789db21fd9..ab19ee3b94d2e310c8962e85aed95cabd0203bd2 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package fmt_test
 
 import (
index aa3cd05e3ef22e4ace9e27e37fbd575d9c73e836..c77e78809cc56ccdfa0f13aaddeed1a7a58e3abc 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package fmt_test
 
 import (
index a2e481bd300a87bf99be2c37ce61e3bfe65aa069..5619d20d49438f245e6cd6604424a016bf276381 100644 (file)
@@ -5,7 +5,7 @@
 // Only run where builders (build.golang.org) have
 // access to compiled packages for import.
 //
-// +build ignore,!arm,!arm64,!nacl
+// +build !arm,!arm64,!nacl
 
 package types_test
 
@@ -77,7 +77,7 @@ func Unused() { {}; {{ var x int; _ = x }} } // make sure empty block scopes get
        rx := regexp.MustCompile(` 0x[a-fA-F0-9]*`)
        fmt.Println(rx.ReplaceAllString(buf.String(), ""))
 
-       // Output:
+       // no output for gccgo--can't import "fmt"
        // package "temperature" scope {
        // .  const temperature.Boiling temperature.Celsius
        // .  type temperature.Celsius float64
@@ -147,7 +147,7 @@ func (c *Celsius) SetF(f float64) { *c = Celsius(f - 32 / 9 * 5) }
                fmt.Println()
        }
 
-       // Output:
+       // no output for gccgo--can't import "fmt"
        // Method set of temperature.Celsius:
        // method (temperature.Celsius) String() string
        //
index a1d9e165280dff42245efef054eb60f24d6bf94c..621bf838309ed7cc2613a01097237cdf34463f5f 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package crc32_test
 
 import (
index 49dc8fc8abb7df5bc08e619f9d1e4e0ceb74b596..f07b9aaa2c4898b5765ba66da0faf6cf48fa4e42 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package hash_test
 
 import (
index d0f0a9bd850f4be71963e91ca13917bc0848b4ff..0e28cac1be5e4f8ead17ffb4b4cfd90803fc2e48 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package html_test
 
 import (
index 80107a63239a202f670d706f476d3d030fdde7c5..533c0dd9616a022b852a872708c351d10e525785 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package template_test
 
 import (
index ffca8d5a7870dc7a0e20fa7c87bf325182cc4511..60518aee9ec0867820414be4985fd3ef02670369 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package template_test
 
 import (
index d381c1c67fd37180abdd04ebff475a08aa3a2443..2ccc2f4acdbffd88469ca27df79e6c3479adf32c 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package draw_test
 
 import (
index 2a03be5a1a0fe81cbedd94c702e29dba615d9478..c4376320041cfc45575f0a1cc0d2e3453024cb70 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package png_test
 
 import (
index a23a58026be2f86f365f5992e4e547f53690f6e0..ea10bfd06a158f069c9fc29667ad4ac4a42a60dc 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package suffixarray_test
 
 import (
index 3066c94ee3227d1da4be74f973f5ecbb2bcd86e9..a7d340b77fa595a607dc2d4de1828a8742b241c3 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package ioutil_test
 
 import (
diff --git a/libgo/go/io/ioutil/testdata/hello b/libgo/go/io/ioutil/testdata/hello
new file mode 100644 (file)
index 0000000..e47c092
--- /dev/null
@@ -0,0 +1 @@
+Hello, Gophers!
index 0513b26da17c013aee6069ccb477d2791521f695..3d5b76d219cd03e7fac46d8501eed07daeda6ee5 100644 (file)
@@ -2,7 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
 // +build !windows,!nacl,!plan9
 
 package syslog_test
index f3127bb4717b999ced9d5b54d08165074cebde1c..a97117001c0b5e8a35e7101030a0d216438a842a 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package big_test
 
 import (
index 8645c44f1037b8f4e79e3ea7c0cc945b216bd761..0c6668c93bc592edafc9a826a877f19af1ca35bc 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package big_test
 
 import (
index 14cea6f700e9ff834619a1326432ec52dfeefe25..b2ed2cba4bfb72287dd1189382684baf41995e51 100644 (file)
@@ -4,8 +4,6 @@
 
 // Code generated by go run make_examples.go. DO NOT EDIT.
 
-// +build ignore
-
 package bits_test
 
 import (
index be87cff5ef10cf24ee54afe06a9f60e919608d11..f0ed9631142295458aee9e3430ec0df0cf67333a 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package cmplx_test
 
 import (
index 12aafdc06d7a58ec177b4ddaf3edf8f2ac604377..c7d13cdcdb550c0b284855d04e85a8be6240eaf7 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package mime_test
 
 import (
index 0593b04935597e514d9f63ef5d0b142fa185f686..5a9ab450a3cb6e2a868da5bf585923234917ccf9 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package quotedprintable_test
 
 import (
index 748ec5cc431b734e760c8dbfce6c26d72ce82fe7..9b3117358f8a879ff5ba38d585e238abd639ceda 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package cookiejar_test
 
 import "net/http/cookiejar"
index 19a57465ff6525234f0e28232a081dc57032b6f6..91728ca9821b11924014d72cf7c9d55360cf4d39 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package cookiejar_test
 
 import (
index 27cdcdec31bfa64aca1565185860f00688dfa8e6..07fdc0a4726fc35e9f1b776171eb10e404e0e096 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package httptrace_test
 
 import (
index e8dc962d3e31787b3f68c4c646f9c60345d242a1..619160367453ad9180857b4438536863ae7d7acf 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package httputil_test
 
 import (
index 972cfd6c42445bb978e7d2beb590677ba0c8cfb3..c3365642aa4473883179a0fc5b92ea6b8a5194b9 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package mail_test
 
 import (
index d019c260c58343c51f52ee64e61b39c624a00f6a..a1d680e4a054d1599cbed9b36201b9e7eb01ef81 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package filepath_test
 
 import (
index 8e0ee5a1a3fe8dd7e47d43a136223d01db446f04..ba96a829a3d064e9185943721a46aaecb27d145e 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package trace_test
 
 import (
index 88b992b136ea194db64f008333d46cfdcc5ff600..5e8c3fbda4ff88abe0551b807fc6b8d0cce61a60 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package scanner_test
 
 import (
index 4f1a2f822e46338e27392a1511f9bd210ad65d2e..4293db92664f6711aeebc4bbe6d286297249fb16 100755 (executable)
@@ -475,7 +475,7 @@ if $havex; then
        cp _gotest_.o `dirname $package`/lib`basename $package`.a
 
        # Force the test version of the package to be imported first,
-       # so that it's type definitions will be used, in case any new
+       # so that its type definitions will be used, in case any new
        # methods appear in export_test.go files.
        echo "package $xpackage" > _first_test.go
        echo 'import _ "'$package'"' >> _first_test.go
@@ -535,6 +535,28 @@ symtogo() {
   done
 }
 
+# Takes an example name and puts any output into the file example.txt.
+# It strips comment markers but does not otherwise change the output.
+exampleoutput() {
+    local n=$(testname $1)
+    local f
+    for f in $gofiles $xgofiles; do
+       if ! grep "^func $n(" $f >/dev/null 2>&1; then
+           continue
+       fi
+       # Copy the output comment, if any, into example.txt.
+       # Remove the comment markers.
+       sed -n "/^func $n(/,/^}$/ p" $f |
+           sed -n '\|// \([Uu]nordered \)\?[Oo]utput:|,$ p' |
+           sed -n '\|//| s|[   ]*// \?||p' > example.txt
+       # Check whether we found an output comment.
+       if ! sed -n '1p' < example.txt | grep '[Oo]utput:' >/dev/null 2>&1; then
+           rm -f example.txt
+       fi
+       return
+    done
+}
+
 {
        # On systems using PPC64 ELF ABI v1 function symbols show up
        # as descriptors in the data section.
@@ -546,7 +568,12 @@ symtogo() {
        pattern='Test([^a-z].*)?'
        # The -p option tells GNU nm not to sort.
        # The -v option tells Solaris nm to sort by value.
-        testsyms=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+        testsyms=$($NM -p -v _gotest_.o | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+       testxsyms=
+       if $havex; then
+           testxsyms=$($NM -p -v $xofile | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+           testsyms="$testsyms $testxsyms"
+       fi
         tests=$(symtogo "$testsyms")
        if [ "x$tests" = x ]; then
                echo 'gotest: warning: no tests matching '$pattern in _gotest_.o $xofile 1>&2
@@ -554,12 +581,20 @@ symtogo() {
        fi
        # benchmarks are named BenchmarkFoo.
        pattern='Benchmark([^a-z].*)?'
-       benchmarksyms=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+       benchmarksyms=$($NM -p -v _gotest_.o | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+       if $havex; then
+           benchmarkxsyms=$($NM -p -v $xofile | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+           benchmarksyms="$benchmarksyms $benchmarkxsyms"
+       fi
         benchmarks=$(symtogo "$benchmarksyms")
 
        # examples are named ExampleFoo
        pattern='Example([^a-z].*)?'
-       examplesyms=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+       examplesyms=$($NM -p -v _gotest_.o | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+       if $havex; then
+           examplexsyms=$($NM -p -v $xofile | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+           examplesyms="$examplesyms $examplexsyms"
+       fi
        examples=$(symtogo "$examplesyms")
 
        # package spec
@@ -570,7 +605,25 @@ symtogo() {
                echo 'import "./_gotest_"'
        fi
        if $havex; then
+           needxtest=false
+           if test -n "$testxsyms" -o -n "$benchmarkxsyms"; then
+               needxtest=true
+           else
+               # Check whether any example has output.
+               for i in $(symtogo "$examplexsyms"); do
+                   exampleoutput $i
+                   if test -f example.txt; then
+                       rm -f example.txt
+                       needxtest=true
+                       break
+                   fi
+               done
+           fi
+           if test x$needxtest = xtrue; then
                echo 'import "./_xtest_"'
+           else
+               echo 'import _ "./_xtest_"'
+           fi
        fi
        echo 'import "testing"'
        echo 'import "testing/internal/testdeps"'
@@ -590,7 +643,7 @@ symtogo() {
        # benchmark array
        # The comment makes the multiline declaration
        # gofmt-safe even when there are no benchmarks.
-       echo 'var benchmarks = []testing.InternalBenchmark{ //'
+       echo 'var benchmarks = []testing.InternalBenchmark{'
        for i in $benchmarks; do
                n=$(testname $i)
                j=$(localname $i)
@@ -599,7 +652,7 @@ symtogo() {
        echo '}'
 
        # examples array
-       echo 'var examples = []testing.InternalExample{ //'
+       echo 'var examples = []testing.InternalExample{'
        for i in $examples; do
                n=$(testname $i)
                j=$(localname $i)
@@ -607,54 +660,37 @@ symtogo() {
                hasoutput=false
                unordered=false
                output=
-               for f in $gofiles $xgofiles; do
-                   if ! grep "^func $n(" $f >/dev/null 2>&1; then
-                       continue
-                   fi
-                   # Copy the output comment, if any, into example.txt.
-                   # Remove the comment markers.
-                   sed -n "/^func $n(/,/^}$/ p" $f |
-                       sed -n '\|// \([Uu]nordered \)\?[Oo]utput:|,$ p' |
-                       sed -n '\|//| s|[       ]*// \?||p' > example.txt
-                   # Check whether we found an output comment.
-                   if ! sed -n '1p' < example.txt | grep '[Oo]utput:' >/dev/null 2>&1; then
-                       # An example with no output is only compiled, not run,
-                       # so don't add it to the examples slice.
-                       rm -f example.txt
-                       break
-                   fi
-                   # Check whether the output can be unordered.
-                   unordered=false
-                   if sed -n '1p' < example.txt | grep -i unordered; then
-                       unordered=true
-                   fi
-                   # Remove the output header.
-                   # Quote backslashes.
-                   # Quote quotation characters.
-                   # Turn tab into \t.
-                   # Turn pairs of spaces into " \x20", because $() will
-                   # drop duplicate spaces.
-                   # Drop trailing spaces, and turn newlines into \n.
-                   # Remove leading and trailing \n.
-                   sed '1 s/\([Uu]nordered \)\?[Oo]utput:[     ]*//' < example.txt |
-                                sed -e 's/\\/\\\\/g' \
-                                    -e 's/"/\\"/g' \
-                                    -e 's/     /\\t/g' \
-                                    -e 's/  / \\x20/g' \
-                                    -e 's/[    ]*$/\\n/g' |
-                                tr -d '\n' |
-                                sed -e 's/^\(\\n\)*//' \
-                                    -e 's/\(\\n\)*$//' > example2.txt
-                   hasoutput=true
-                   rm -f example.txt
-                   break
-               done
-               if test x$hasoutput = xtrue; then
-                   echo '      {"'$n'", '$j','
-                   sed -e 's/^/                "/' -e 's/$/", /' < example2.txt
-                   echo $unordered'},'
-                   rm -f example2.txt
+               exampleoutput $i
+               if ! test -f example.txt; then
+                   continue
+               fi
+               # Check whether the output can be unordered.
+               unordered=false
+               if sed -n '1p' < example.txt | grep -i unordered >/dev/null 2>&1; then
+                   unordered=true
                fi
+               # Remove the output header.
+               # Quote backslashes.
+               # Quote quotation characters.
+               # Turn tab into \t.
+               # Turn pairs of spaces into " \x20", because $() will
+               # drop duplicate spaces.
+               # Drop trailing spaces, and turn newlines into \n.
+               # Remove leading and trailing \n.
+               sed '1 s/\([Uu]nordered \)\?[Oo]utput:[         ]*//' < example.txt |
+                            sed -e 's/\\/\\\\/g' \
+                                -e 's/"/\\"/g' \
+                                -e 's/ /\\t/g' \
+                                -e 's/  / \\x20/g' \
+                                -e 's/[        ]*$/\\n/g' |
+                            tr -d '\n' |
+                            sed -e 's/^\(\\n\)*//' \
+                                -e 's/\(\\n\)*$//' > example2.txt
+               hasoutput=true
+               echo '  {"'$n'", '$j','
+               sed -e 's/^/            "/' -e 's/$/", /' < example2.txt
+               echo $unordered'},'
+               rm -f example.txt example2.txt
        done
        echo '}'
 
This page took 0.114212 seconds and 5 git commands to generate.