Sha256: a4f84f9e050edddd3cac57cdec087ee041ac265bbbbdc9cfa1716ca35afaa683
Contents?: true
Size: 1.8 KB
Versions: 52
Compression:
Stored size: 1.8 KB
Contents
#!/bin/sh # This file moves all stub files out of the way so that they don't get built, # runs the tests, then moves the stub files back. # We use this instead of build constraints to have less noise in stub files. # Newcomers to go might be confused by build constraints # It's useful to move the stub files back instead of outright deleting them. # That way no maintainer will mistakenly commit the deleted files, # which could otherwise happen after running tests locally. for dir in exercises/*/; do stub=$(echo $(basename $dir) | tr - _) file="$dir/$stub.go" if [ -f $file ]; then echo "moving stub $file" mv $file "$dir/$stub.notgo" fi done root=$(pwd) cleanup () { echo "moving stub files back" # the cd for go fmt or go vet could leave us in an unexpected place. # cd to a known place. cd "$root" # could use `rename` here, but it's not uniform among platforms. # some renames take two arguments while others take a single regex. for file in exercises/*/*.notgo; do dir=$(dirname $file) base=$(basename $file .notgo) mv "$dir/$base.notgo" "$dir/$base.go" done } trap cleanup EXIT INT TERM if [ "$1" = "fmt" ]; then for dir in exercises/*/; do cd $dir if [ -n "$(go fmt)" ]; then echo "please run 'go fmt' on $dir" >&2 exit 1 fi cd "$root" done exit 0 fi if [ "$1" = "vet" ]; then for dir in exercises/*/; do cd $dir if ! go vet; then echo "please follow the 'go vet' suggestions in $dir" >&2 exit 1 fi cd "$root" done exit 0 fi # This is the last command in the file, # so the exit status of this script is the exit status of go test. # If this ever changes, remember to preserve the exit status acordingly. # Otherwise Travis may falsely report a test as passed when it has failed. go test -cpu 2 $RACE ./...
Version data entries
52 entries across 52 versions & 1 rubygems