|
|
|
# TODO: Place file direct to .bin directory
|
make -coverprofile include toolexec processes (#216)
testscript already included magic to also account for commands in the
total code coverage. That does not happen with plain tests, since those
only include coverage from the main test process.
The main problem was that, before, indirectly executed commands did not
properly save their coverage profile anywhere for testscript to collect
it at the end. In other words, we only collected coverage from direct
garble executions like "garble -help", but not indirect ones like "go
build -toolexec=garble".
$ go test -coverprofile=cover.out
PASS
coverage: 3.6% of statements
total coverage: 16.6% of statements
ok mvdan.cc/garble 6.453s
After the delicate changes to testscript, any direct or indirect
executions of commands all go through $PATH and properly count towards
the total coverage:
$ go test -coverprofile=cover.out
PASS
coverage: 3.6% of statements
total coverage: 90.5% of statements
ok mvdan.cc/garble 33.258s
Note that we can also get rid of our code to set up $PATH, since
testscript now does it for us.
goversion.txt needed minor tweaks, since we no longer set up $WORK/.bin.
Finally, note that we disable the reuse of $GOCACHE when collecting
coverage information. This is to do "full builds", as otherwise the
cached package builds would result in lower coverage.
Fixes #35.
4 years ago
|
|
|
mkdir .bin
|
|
|
|
cp go.sh .bin/go
|
|
|
|
cp go.bat .bin/go.bat
|
|
|
|
chmod 777 .bin/go
|
make -coverprofile include toolexec processes (#216)
testscript already included magic to also account for commands in the
total code coverage. That does not happen with plain tests, since those
only include coverage from the main test process.
The main problem was that, before, indirectly executed commands did not
properly save their coverage profile anywhere for testscript to collect
it at the end. In other words, we only collected coverage from direct
garble executions like "garble -help", but not indirect ones like "go
build -toolexec=garble".
$ go test -coverprofile=cover.out
PASS
coverage: 3.6% of statements
total coverage: 16.6% of statements
ok mvdan.cc/garble 6.453s
After the delicate changes to testscript, any direct or indirect
executions of commands all go through $PATH and properly count towards
the total coverage:
$ go test -coverprofile=cover.out
PASS
coverage: 3.6% of statements
total coverage: 90.5% of statements
ok mvdan.cc/garble 33.258s
Note that we can also get rid of our code to set up $PATH, since
testscript now does it for us.
goversion.txt needed minor tweaks, since we no longer set up $WORK/.bin.
Finally, note that we disable the reuse of $GOCACHE when collecting
coverage information. This is to do "full builds", as otherwise the
cached package builds would result in lower coverage.
Fixes #35.
4 years ago
|
|
|
env PATH=.bin${:}${PATH}
|
|
|
|
|
|
|
|
# Check incorrect go install
|
|
|
|
env GO_VERSION=''
|
|
|
|
! garble build
|
|
|
|
stderr 'Can''t get Go version'
|
|
|
|
|
|
|
|
[short] stop
|
|
|
|
|
|
|
|
# Check invalid devel format
|
|
|
|
env GO_VERSION='go version devel someinvalidversion'
|
|
|
|
! garble build
|
|
|
|
stderr 'Can''t recognize devel build timestamp'
|
|
|
|
|
|
|
|
# Check invalid devel date
|
|
|
|
env GO_VERSION='go version devel +afb5fca Sun Sep 99 99:99:99 9999 +0000 linux/amd64'
|
|
|
|
! garble build
|
|
|
|
stderr 'Can''t recognize devel build timestamp: parsing time'
|
|
|
|
|
|
|
|
# Check invalid old devel version
|
|
|
|
env GO_VERSION='go version devel +afb5fca Sun Aug 07 00:00:00 2020 +0000 linux/amd64'
|
|
|
|
! garble build
|
|
|
|
stderr 'You use the old unstable'
|
|
|
|
|
|
|
|
# Check invalid new devel version
|
|
|
|
env GO_VERSION='go version devel +afb5fca Sun Sep 13 07:54:42 2020 +0000 linux/amd64'
|
|
|
|
! garble build
|
|
|
|
! stderr 'You use the old unstable'
|
|
|
|
|
|
|
|
# Check old version
|
|
|
|
env GO_VERSION='go version go1.14 windows/amd64'
|
|
|
|
! garble build
|
|
|
|
stderr 'Outdated Go version'
|
|
|
|
|
|
|
|
# Check supported version
|
|
|
|
env GO_VERSION='go version go1.15.2 windows/amd64'
|
|
|
|
! garble build
|
|
|
|
! stderr 'Outdated Go version'
|
|
|
|
|
|
|
|
-- main.go --
|
|
|
|
package main
|
|
|
|
|
|
|
|
-- go.sh --
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
[ -z "$GO_VERSION" ] && exit 1 || echo "$GO_VERSION"
|
|
|
|
|
|
|
|
-- go.bat --
|
|
|
|
@echo off
|
|
|
|
IF DEFINED GO_VERSION (echo %GO_VERSION%) ELSE (exit 1)
|