* Patch RFC: Add check target to gotool to check go command
@ 2017-06-14 16:48 Ian Lance Taylor
2017-06-14 19:26 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Ian Lance Taylor @ 2017-06-14 16:48 UTC (permalink / raw)
To: Than McIntosh, gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 482 bytes --]
This patch to the gotools Makefile adds a check target. This initial
implementation of the check target tests the go tool by running the
existing testsuite in libgo/go/cmd/go. Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.
Ian
2017-06-14 Ian Lance Taylor <iant@golang.org>
* Makefile.am (libgosrcdir): Define.
(check-head, check-gccgo, check-go-tool): New targets.
(CHECK_ENV): Define.
(check): New target.
(mostlyclean-local): New target.
* Makefile.in: Rebuild.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 4347 bytes --]
Index: Makefile.am
===================================================================
--- Makefile.am (revision 249171)
+++ Makefile.am (working copy)
@@ -42,7 +42,8 @@ AM_GOCFLAGS = -I $(libgodir)
AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
-cmdsrcdir = $(srcdir)/../libgo/go/cmd
+libgosrcdir = $(srcdir)/../libgo/go
+cmdsrcdir = $(libgosrcdir)/cmd
go_cmd_go_files = \
$(cmdsrcdir)/go/alldocs.go \
@@ -131,6 +132,90 @@ install-exec-local: cgo$(EXEEXT)
uninstall-local:
rm -f $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
+# Run tests using the go tool, and frob the output to look like that
+# generated by DejaGNU. The main output of this is two files:
+# gotools.sum and gotools.log.
+
+# check-head starts generating the log files in DejaGNU format. This
+# is a separate target so that the date is approximately when we start
+# running the tests.
+check-head:
+ @echo "Test Run By $${USER} on `date`" > gotools.head
+ @echo "Native configuration is $(host_triplet)" >> gotools.head
+ @echo >> gotools.head
+ @echo " === gotools tests ===" >> gotools.head
+ @echo >> gotools.head
+
+# check-gccgo is a little shell script that executes gccgo with the
+# options to pick up the newly built libgo.
+check-gccgo: Makefile
+ rm -f $@
+ echo "#!/bin/sh" > $@
+ abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
+ echo "$(GOCOMPILE)" '"$$@"' "-I $${abs_libgodir} -L $${abs_libgodir} -L $${abs_libgodir}/.libs" >> $@
+ chmod +x $@
+
+# CHECK_ENV sets up the environment to run the newly built go tool.
+CHECK_ENV = \
+ PATH=`echo $(abs_builddir):$${PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
+ export PATH; \
+ GCCGO="$(abs_builddir)/check-gccgo"; \
+ export GCCGO; \
+ GCCGOTOOLDIR="$(abs_builddir)"; \
+ export GCCGOTOOLDIR; \
+ GO_TESTING_GOTOOLS=yes; \
+ export GO_TESTING_GOTOOLS; \
+ abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
+ LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
+ export LD_LIBRARY_PATH;
+
+# check-go-tools runs `go test cmd/go` in our environment.
+check-go-tool: go$(EXEEXT) check-head check-gccgo
+ rm -rf check-go-dir
+ $(MKDIR_P) check-go-dir/src/cmd/go
+ cp $(cmdsrcdir)/go/*.go check-go-dir/src/cmd/go/
+ cp $(libgodir)/zstdpkglist.go check-go-dir/src/cmd/go/
+ cp zdefaultcc.go check-go-dir/src/cmd/go/
+ cp -r $(cmdsrcdir)/go/testdata check-go-dir/src/cmd/go/
+ $(CHECK_ENV) \
+ GOPATH=`cd check-go-dir && $(PWD_COMMAND)`; \
+ export GOPATH; \
+ (cd check-go-dir/src/cmd/go && $(abs_builddir)/go$(EXEEXT) test -test.short -test.v) >& cmd_go-testlog || true
+ grep '^--- ' gotools-log
+ if grep '^--- FAIL' gotools-log >/dev/null 2>&1; then exit 1; fi
+
+# The check targets runs the tests and assembles the output files.
+check: check-head check-go-tool
+ mv gotools.head gotools.sum
+ cp gotools.sum gotools.log
+ for file in cmd_go-testlog; do \
+ testname=`echo $${file} | sed -e 's/-testlog//' -e 's|_|/|'`; \
+ echo "Running $${testname}" >> gotools.sum; \
+ echo "Running $${testname}" >> gotools.log; \
+ sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' < $${file} >> gotools.log; \
+ grep '^--- ' $${file} | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' -e 's/SKIP/UNTESTED/' >> gotools.sum; \
+ done
+ @echo >> gotools.sum
+ @echo " === gotools Summary ===" >> gotools.sum
+ pass=`grep -c '^PASS' gotools.sum`; \
+ if test "$${pass}" -ne "0"; then \
+ echo "# of expected passes $${pass}" >> gotools.sum; \
+ fi
+ fail=`grep -c '^FAIL' gotools.sum`; \
+ if test "$${fail}" -ne "0"; then \
+ echo "# of unexpected failures $${fail}" >> gotools.sum; \
+ fi
+ untested=`grep -c '^UNTESTED' gotools.sum`; \
+ if test "$${untested}" -ne "0"; then \
+ echo "# of untested testcases $${untested}" >> gotools.sum; \
+ fi
+ echo `echo $(GOC_FOR_TARGET) | sed -e 's/ .*//'` `$(GOC_FOR_TARGET) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> gotools.sum
+ echo >> gotools.log
+ echo "runtest completed at `date`" >> gotools.log
+ if grep '^FAIL' gotools.sum >/dev/null 2>&1; then exit 1; fi
+
+.PHONY: check check-head check-go-tool
+
else
# For a non-native build we have to build the programs using a
@@ -140,3 +225,6 @@ else
# the go/build package. Figure this out later.
endif
+
+mostlyclean-local:
+ rm -rf check-go-dir
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Patch RFC: Add check target to gotool to check go command
2017-06-14 16:48 Patch RFC: Add check target to gotool to check go command Ian Lance Taylor
@ 2017-06-14 19:26 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2017-06-14 19:26 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 634 bytes --]
On Wed, Jun 14, 2017 at 9:48 AM, Ian Lance Taylor <iant@golang.org> wrote:
> This patch to the gotools Makefile adds a check target. This initial
> implementation of the check target tests the go tool by running the
> existing testsuite in libgo/go/cmd/go. Bootstrapped and ran Go
> testsuite on x86_64-pc-linux-gnu.
>
> Ian
>
> 2017-06-14 Ian Lance Taylor <iant@golang.org>
>
> * Makefile.am (libgosrcdir): Define.
> (check-head, check-gccgo, check-go-tool): New targets.
> (CHECK_ENV): Define.
> (check): New target.
> (mostlyclean-local): New target.
> * Makefile.in: Rebuild.
Committed after further testing as follows.
Ian
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 4322 bytes --]
Index: Makefile.am
===================================================================
--- Makefile.am (revision 249171)
+++ Makefile.am (working copy)
@@ -42,7 +42,8 @@ AM_GOCFLAGS = -I $(libgodir)
AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
-cmdsrcdir = $(srcdir)/../libgo/go/cmd
+libgosrcdir = $(srcdir)/../libgo/go
+cmdsrcdir = $(libgosrcdir)/cmd
go_cmd_go_files = \
$(cmdsrcdir)/go/alldocs.go \
@@ -131,6 +132,89 @@ install-exec-local: cgo$(EXEEXT)
uninstall-local:
rm -f $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
+# Run tests using the go tool, and frob the output to look like that
+# generated by DejaGNU. The main output of this is two files:
+# gotools.sum and gotools.log.
+
+# check-head starts generating the log files in DejaGNU format. This
+# is a separate target so that the date is approximately when we start
+# running the tests.
+check-head:
+ @echo "Test Run By $${USER} on `date`" > gotools.head
+ @echo "Native configuration is $(host_triplet)" >> gotools.head
+ @echo >> gotools.head
+ @echo " === gotools tests ===" >> gotools.head
+ @echo >> gotools.head
+
+# check-gccgo is a little shell script that executes gccgo with the
+# options to pick up the newly built libgo.
+check-gccgo: Makefile
+ rm -f $@
+ echo "#!/bin/sh" > $@
+ abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
+ echo "$(GOCOMPILE)" '"$$@"' "-I $${abs_libgodir} -L $${abs_libgodir} -L $${abs_libgodir}/.libs" >> $@
+ chmod +x $@
+
+# CHECK_ENV sets up the environment to run the newly built go tool.
+CHECK_ENV = \
+ PATH=`echo $(abs_builddir):$${PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
+ export PATH; \
+ GCCGO="$(abs_builddir)/check-gccgo"; \
+ export GCCGO; \
+ GCCGOTOOLDIR="$(abs_builddir)"; \
+ export GCCGOTOOLDIR; \
+ GO_TESTING_GOTOOLS=yes; \
+ export GO_TESTING_GOTOOLS; \
+ abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
+ LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
+ export LD_LIBRARY_PATH;
+
+# check-go-tools runs `go test cmd/go` in our environment.
+check-go-tool: go$(EXEEXT) check-head check-gccgo
+ rm -rf check-go-dir
+ $(MKDIR_P) check-go-dir/src/cmd/go
+ cp $(cmdsrcdir)/go/*.go check-go-dir/src/cmd/go/
+ cp $(libgodir)/zstdpkglist.go check-go-dir/src/cmd/go/
+ cp zdefaultcc.go check-go-dir/src/cmd/go/
+ cp -r $(cmdsrcdir)/go/testdata check-go-dir/src/cmd/go/
+ $(CHECK_ENV) \
+ GOPATH=`cd check-go-dir && $(PWD_COMMAND)`; \
+ export GOPATH; \
+ (cd check-go-dir/src/cmd/go && $(abs_builddir)/go$(EXEEXT) test -test.short -test.v) >& cmd_go-testlog || true
+ grep '^--- ' cmd_go-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/'
+
+# The check targets runs the tests and assembles the output files.
+check: check-head check-go-tool
+ mv gotools.head gotools.sum
+ cp gotools.sum gotools.log
+ for file in cmd_go-testlog; do \
+ testname=`echo $${file} | sed -e 's/-testlog//' -e 's|_|/|'`; \
+ echo "Running $${testname}" >> gotools.sum; \
+ echo "Running $${testname}" >> gotools.log; \
+ sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' < $${file} >> gotools.log; \
+ grep '^--- ' $${file} | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' -e 's/SKIP/UNTESTED/' >> gotools.sum; \
+ done
+ @echo >> gotools.sum
+ @echo " === gotools Summary ===" >> gotools.sum
+ pass=`grep -c '^PASS' gotools.sum`; \
+ if test "$${pass}" -ne "0"; then \
+ echo "# of expected passes $${pass}" >> gotools.sum; \
+ fi
+ fail=`grep -c '^FAIL' gotools.sum`; \
+ if test "$${fail}" -ne "0"; then \
+ echo "# of unexpected failures $${fail}" >> gotools.sum; \
+ fi
+ untested=`grep -c '^UNTESTED' gotools.sum`; \
+ if test "$${untested}" -ne "0"; then \
+ echo "# of untested testcases $${untested}" >> gotools.sum; \
+ fi
+ echo `echo $(GOC_FOR_TARGET) | sed -e 's/ .*//'` `$(GOC_FOR_TARGET) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> gotools.sum
+ echo >> gotools.log
+ echo "runtest completed at `date`" >> gotools.log
+ if grep '^FAIL' gotools.sum >/dev/null 2>&1; then exit 1; fi
+
+.PHONY: check check-head check-go-tool
+
else
# For a non-native build we have to build the programs using a
@@ -140,3 +224,6 @@ else
# the go/build package. Figure this out later.
endif
+
+mostlyclean-local:
+ rm -rf check-go-dir
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-14 19:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-14 16:48 Patch RFC: Add check target to gotool to check go command Ian Lance Taylor
2017-06-14 19:26 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).