libgo: compile examples in _test packages
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
This commit is contained in:
parent
acd43917df
commit
fcee603081
@ -1,4 +1,4 @@
|
|||||||
f9d1bfb3eec2d388c5f239779fd25a580064dd9d
|
92ee4c2e295fc760105f187f6ea6dc65c81fa892
|
||||||
|
|
||||||
The first line of this file holds the git revision number of the last
|
The first line of this file holds the git revision number of the last
|
||||||
merge done from the gofrontend repository.
|
merge done from the gofrontend repository.
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package flate_test
|
package flate_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package gzip_test
|
package gzip_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package ring_test
|
package ring_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package sha256_test
|
package sha256_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package sql_test
|
package sql_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package sql_test
|
package sql_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package csv_test
|
package csv_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package hex_test
|
package hex_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package json_test
|
package json_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package json_test
|
package json_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package pem_test
|
package pem_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package xml_test
|
package xml_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package xml_test
|
package xml_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package fmt_test
|
package fmt_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package fmt_test
|
package fmt_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package fmt_test
|
package fmt_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// Only run where builders (build.golang.org) have
|
// Only run where builders (build.golang.org) have
|
||||||
// access to compiled packages for import.
|
// access to compiled packages for import.
|
||||||
//
|
//
|
||||||
// +build ignore,!arm,!arm64,!nacl
|
// +build !arm,!arm64,!nacl
|
||||||
|
|
||||||
package types_test
|
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]*`)
|
rx := regexp.MustCompile(` 0x[a-fA-F0-9]*`)
|
||||||
fmt.Println(rx.ReplaceAllString(buf.String(), ""))
|
fmt.Println(rx.ReplaceAllString(buf.String(), ""))
|
||||||
|
|
||||||
// Output:
|
// no output for gccgo--can't import "fmt"
|
||||||
// package "temperature" scope {
|
// package "temperature" scope {
|
||||||
// . const temperature.Boiling temperature.Celsius
|
// . const temperature.Boiling temperature.Celsius
|
||||||
// . type temperature.Celsius float64
|
// . type temperature.Celsius float64
|
||||||
@ -147,7 +147,7 @@ func (c *Celsius) SetF(f float64) { *c = Celsius(f - 32 / 9 * 5) }
|
|||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output:
|
// no output for gccgo--can't import "fmt"
|
||||||
// Method set of temperature.Celsius:
|
// Method set of temperature.Celsius:
|
||||||
// method (temperature.Celsius) String() string
|
// method (temperature.Celsius) String() string
|
||||||
//
|
//
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package crc32_test
|
package crc32_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package hash_test
|
package hash_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package html_test
|
package html_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package template_test
|
package template_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package template_test
|
package template_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package draw_test
|
package draw_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package png_test
|
package png_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package suffixarray_test
|
package suffixarray_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package ioutil_test
|
package ioutil_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
1
libgo/go/io/ioutil/testdata/hello
vendored
Normal file
1
libgo/go/io/ioutil/testdata/hello
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
Hello, Gophers!
|
@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
// +build !windows,!nacl,!plan9
|
// +build !windows,!nacl,!plan9
|
||||||
|
|
||||||
package syslog_test
|
package syslog_test
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package big_test
|
package big_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package big_test
|
package big_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
// Code generated by go run make_examples.go. DO NOT EDIT.
|
// Code generated by go run make_examples.go. DO NOT EDIT.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package bits_test
|
package bits_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package cmplx_test
|
package cmplx_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package mime_test
|
package mime_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package quotedprintable_test
|
package quotedprintable_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package cookiejar_test
|
package cookiejar_test
|
||||||
|
|
||||||
import "net/http/cookiejar"
|
import "net/http/cookiejar"
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package cookiejar_test
|
package cookiejar_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package httptrace_test
|
package httptrace_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package httputil_test
|
package httputil_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package mail_test
|
package mail_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package filepath_test
|
package filepath_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package trace_test
|
package trace_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package scanner_test
|
package scanner_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -475,7 +475,7 @@ if $havex; then
|
|||||||
cp _gotest_.o `dirname $package`/lib`basename $package`.a
|
cp _gotest_.o `dirname $package`/lib`basename $package`.a
|
||||||
|
|
||||||
# Force the test version of the package to be imported first,
|
# 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.
|
# methods appear in export_test.go files.
|
||||||
echo "package $xpackage" > _first_test.go
|
echo "package $xpackage" > _first_test.go
|
||||||
echo 'import _ "'$package'"' >> _first_test.go
|
echo 'import _ "'$package'"' >> _first_test.go
|
||||||
@ -535,6 +535,28 @@ symtogo() {
|
|||||||
done
|
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
|
# On systems using PPC64 ELF ABI v1 function symbols show up
|
||||||
# as descriptors in the data section.
|
# as descriptors in the data section.
|
||||||
@ -546,7 +568,12 @@ symtogo() {
|
|||||||
pattern='Test([^a-z].*)?'
|
pattern='Test([^a-z].*)?'
|
||||||
# The -p option tells GNU nm not to sort.
|
# The -p option tells GNU nm not to sort.
|
||||||
# The -v option tells Solaris nm to sort by value.
|
# 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")
|
tests=$(symtogo "$testsyms")
|
||||||
if [ "x$tests" = x ]; then
|
if [ "x$tests" = x ]; then
|
||||||
echo 'gotest: warning: no tests matching '$pattern in _gotest_.o $xofile 1>&2
|
echo 'gotest: warning: no tests matching '$pattern in _gotest_.o $xofile 1>&2
|
||||||
@ -554,12 +581,20 @@ symtogo() {
|
|||||||
fi
|
fi
|
||||||
# benchmarks are named BenchmarkFoo.
|
# benchmarks are named BenchmarkFoo.
|
||||||
pattern='Benchmark([^a-z].*)?'
|
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")
|
benchmarks=$(symtogo "$benchmarksyms")
|
||||||
|
|
||||||
# examples are named ExampleFoo
|
# examples are named ExampleFoo
|
||||||
pattern='Example([^a-z].*)?'
|
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")
|
examples=$(symtogo "$examplesyms")
|
||||||
|
|
||||||
# package spec
|
# package spec
|
||||||
@ -570,7 +605,25 @@ symtogo() {
|
|||||||
echo 'import "./_gotest_"'
|
echo 'import "./_gotest_"'
|
||||||
fi
|
fi
|
||||||
if $havex; then
|
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_"'
|
echo 'import "./_xtest_"'
|
||||||
|
else
|
||||||
|
echo 'import _ "./_xtest_"'
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo 'import "testing"'
|
echo 'import "testing"'
|
||||||
echo 'import "testing/internal/testdeps"'
|
echo 'import "testing/internal/testdeps"'
|
||||||
@ -590,7 +643,7 @@ symtogo() {
|
|||||||
# benchmark array
|
# benchmark array
|
||||||
# The comment makes the multiline declaration
|
# The comment makes the multiline declaration
|
||||||
# gofmt-safe even when there are no benchmarks.
|
# gofmt-safe even when there are no benchmarks.
|
||||||
echo 'var benchmarks = []testing.InternalBenchmark{ //'
|
echo 'var benchmarks = []testing.InternalBenchmark{'
|
||||||
for i in $benchmarks; do
|
for i in $benchmarks; do
|
||||||
n=$(testname $i)
|
n=$(testname $i)
|
||||||
j=$(localname $i)
|
j=$(localname $i)
|
||||||
@ -599,7 +652,7 @@ symtogo() {
|
|||||||
echo '}'
|
echo '}'
|
||||||
|
|
||||||
# examples array
|
# examples array
|
||||||
echo 'var examples = []testing.InternalExample{ //'
|
echo 'var examples = []testing.InternalExample{'
|
||||||
for i in $examples; do
|
for i in $examples; do
|
||||||
n=$(testname $i)
|
n=$(testname $i)
|
||||||
j=$(localname $i)
|
j=$(localname $i)
|
||||||
@ -607,54 +660,37 @@ symtogo() {
|
|||||||
hasoutput=false
|
hasoutput=false
|
||||||
unordered=false
|
unordered=false
|
||||||
output=
|
output=
|
||||||
for f in $gofiles $xgofiles; do
|
exampleoutput $i
|
||||||
if ! grep "^func $n(" $f >/dev/null 2>&1; then
|
if ! test -f example.txt; then
|
||||||
continue
|
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
|
|
||||||
fi
|
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
|
done
|
||||||
echo '}'
|
echo '}'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user