libgo patch committed: Force test package to be imported first
diff mbox series

Message ID
State New
Headers show
  • libgo patch committed: Force test package to be imported first
Related show

Commit Message

Ian Lance Taylor Sept. 11, 2019, 12:44 p.m. UTC
When running libgo tests, when compiling the x_test package, this
patch forces the test package to be imported first.  That ensures that
we will see the types defined in the test package before the types
defined in the non-test version of the package.  This matters if the
types differ in some way, such as by adding a new method.

This avoids a failure in internal/poll on Solaris, in which the test
package adds a method to a type (FD.EOFError).  I think it was
Solaris-specific because files are sorted in a different order by

The go tool handles this kind of thing correctly, by rebuilding
dependent packages.  This is just a hack sufficient to run the libgo
testsuite without using the go tool.

This fixes PR 91712.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Ran the
failing test on Solaris.  Committed to mainline.


diff mbox series

Index: gcc/go/gofrontend/MERGE
--- gcc/go/gofrontend/MERGE	(revision 275611)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/testsuite/gotest
--- libgo/testsuite/gotest	(revision 275594)
+++ libgo/testsuite/gotest	(working copy)
@@ -419,10 +419,12 @@  esac
 # Split $gofiles into external gofiles (those in *_test packages)
 # and internal ones (those in the main package).
 for f in $gofiles; do
     package=`grep '^package[ 	]' $f | sed 1q`
     case "$package" in
+	xpackage=`echo $package | sed -e 's/package[ 	]//' -e 's/[ 	]*$//'`
 	xgofiles="$xgofiles $f"
@@ -471,10 +473,17 @@  $GC -g $pkgpatharg $prefixarg -c -I . -f
 if $havex; then
 	mkdir -p `dirname $package`
 	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
+	# methods appear in export_test.go files.
+	echo "package $xpackage" > _first_test.go
+	echo 'import _ "'$package'"' >> _first_test.go
 	if test "$trace" = "true"; then
-	    echo $GC -g $xpkgpatharg -c -I . -fno-toplevel-reorder -o $xofile $xgofiles
+	    echo $GC -g $xpkgpatharg -c -I . -fno-toplevel-reorder -o $xofile _first_test.go $xgofiles
-	$GC -g $xpkgpatharg -c -I . -fno-toplevel-reorder -o $xofile $xgofiles
+	$GC -g $xpkgpatharg -c -I . -fno-toplevel-reorder -o $xofile _first_test.go $xgofiles
 # They all compile; now generate the code to call them.