Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test in Travis with Makefile #46

Merged
merged 3 commits into from Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -8,6 +8,8 @@ vendor/
cmd/goversioninfo/goversioninfo
*.exe
*.syso
versioninfo.go
/bin

# OS Files
.DS_Store
Expand Down
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -5,11 +5,15 @@ go:
- "1.12"
- "1.13"
- "1.14"
env:
- GO111MODULE=on
before_install:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
script:
# Output directory.
- pwd
# Install binary.
- go install github.com/$TRAVIS_REPO_SLUG/cmd/goversioninfo
# Test building 32 and 64 on Windows.
Expand Down
26 changes: 26 additions & 0 deletions Makefile
@@ -0,0 +1,26 @@
# This Makefile is an easy way to run common operations.
# Execute commands this:
# * make test-go
# * make test-integration
#
# Tip: Each command is run on its own line so you can't CD unless you
# connect commands together using operators. See examples:
# A; B # Run A and then B, regardless of success of A
# A && B # Run B if and only if A succeeded
# A || B # Run B if and only if A failed
# A & # Run A in background.
# Source: https://askubuntu.com/a/539293
#
# Tip: Use $(shell app param) syntax when expanding a shell return value.

.PHONY: test-go
test-go:
# Run the Go tests.
go test ./...

.PHONY: test-integration
test-integration:
# Build the application.
mkdir -p bin && go build -o bin/goversioninfo cmd/goversioninfo/main.go
# Test the application.
PATH="${PATH}:$(shell pwd)/bin" ./testdata/bash/build.sh
22 changes: 8 additions & 14 deletions testdata/bash/build.sh 100644 → 100755
Expand Up @@ -3,24 +3,18 @@
# Exit on error.
set -e

# Copy the icon to test file closing.
cp $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/resource/icon.ico $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/resource/icon2.ico

# Test Windows 32.
cd $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/example32
cd testdata/example32
GOOS=windows GOARCH=386 go generate
GOOS=windows GOARCH=386 go build
rm $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/resource/icon.ico

# Restore the icon.
cp $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/resource/icon2.ico $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/resource/icon.ico
rm example32.exe
rm resource.syso
cd ../../

# Test Windows 64.
cd $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/example64
cd testdata/example64
GOOS=windows GOARCH=amd64 go generate
GOOS=windows GOARCH=amd64 go build
rm $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/resource/icon.ico

# Reset the icons.
mv $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/resource/icon2.ico $GOPATH/src/github.com/josephspurrier/goversioninfo/testdata/resource/icon.ico
cd $GOPATH/src/github.com/josephspurrier/goversioninfo
rm example64.exe
rm resource.syso
cd ../../