diff --git a/README.md b/README.md index bff3079..0523589 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ gaper ===== [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) -[![Build Status](https://travis-ci.org/maxcnunes/gaper.svg?branch=master)](https://travis-ci.org/maxcnunes/gaper) +[![Linux - Build Status](https://travis-ci.org/maxcnunes/gaper.svg?branch=master)](https://travis-ci.org/maxcnunes/gaper) +[![Windows - Build status](https://ci.appveyor.com/api/projects/status/e0g00kmxwv44?svg=true)](https://ci.appveyor.com/project/maxcnunes/gaper) [![Coverage Status](https://codecov.io/gh/maxcnunes/gaper/branch/master/graph/badge.svg)](https://codecov.io/gh/maxcnunes/gaper) [![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/maxcnunes/gaper) [![Go Report Card](https://goreportcard.com/badge/github.com/maxcnunes/gaper)](https://goreportcard.com/report/github.com/maxcnunes/gaper) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..14ad5f2 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,31 @@ +version: "{build}" + +# Source Config + +clone_folder: c:\gopath\src\github.com\golang\gaper + +# Build host + +environment: + GOPATH: c:\gopath + GOBIN: c:\gopath\bin + +init: + - git config --global core.autocrlf input + +# Build + +install: + - set Path=c:\go\bin;c:\gopath\bin;%Path% + - go version + - go env + - go get -u github.com/golang/dep/cmd/dep + - choco install make + - make setup + +build: false +deploy: false + +test_script: + - go build github.com/golang/gaper + - make test diff --git a/builder_test.go b/builder_test.go index e80727d..a51e202 100644 --- a/builder_test.go +++ b/builder_test.go @@ -3,6 +3,7 @@ package main import ( "os" "path/filepath" + "runtime" "testing" "github.com/stretchr/testify/assert" @@ -10,7 +11,7 @@ import ( func TestBuilderSuccessBuild(t *testing.T) { bArgs := []string{} - bin := "srv" + bin := resolveBinNameByOS("srv") dir := filepath.Join("testdata", "server") wd, err := os.Getwd() if err != nil { @@ -48,5 +49,12 @@ func TestBuilderDefaultBinName(t *testing.T) { dir := filepath.Join("testdata", "server") wd := "/src/projects/project-name" b := NewBuilder(dir, bin, wd, nil) - assert.Equal(t, b.Binary(), "project-name") + assert.Equal(t, b.Binary(), resolveBinNameByOS("project-name")) +} + +func resolveBinNameByOS(name string) string { + if runtime.GOOS == OSWindows { + name += ".exe" + } + return name } diff --git a/runner.go b/runner.go index 590f8f7..b99717e 100644 --- a/runner.go +++ b/runner.go @@ -87,8 +87,12 @@ func (r *runner) Kill() error { // Wait for our process to die before we return or hard kill after 3 sec select { case <-time.After(3 * time.Second): - if err := r.command.Process.Kill(); err != nil && err.Error() != errFinished.Error() { - return fmt.Errorf("failed to kill: %v", err) + if err := r.command.Process.Kill(); err != nil { + errMsg := err.Error() + // ignore error if the processed has been killed already + if errMsg != errFinished.Error() && errMsg != os.ErrInvalid.Error() { + return fmt.Errorf("failed to kill: %v", err) + } } case <-done: } diff --git a/runner_test.go b/runner_test.go index 263ff05..2bca40c 100644 --- a/runner_test.go +++ b/runner_test.go @@ -27,12 +27,7 @@ func TestRunnerSuccessRun(t *testing.T) { errCmd := <-runner.Errors() assert.Nil(t, errCmd, "async error running binary") - - if runtime.GOOS == OSWindows { - assert.Equal(t, "Gaper\r\n", stdout.String()) - } else { - assert.Equal(t, "Gaper\n", stdout.String()) - } + assert.Contains(t, stdout.String(), "Gaper Test Message") } func TestRunnerSuccessKill(t *testing.T) { diff --git a/testdata/print-gaper b/testdata/print-gaper index 8447086..1fd1ff9 100755 --- a/testdata/print-gaper +++ b/testdata/print-gaper @@ -1,3 +1,3 @@ #!/usr/bin/env bash sleep 2 -echo "Gaper" +echo "Gaper Test Message" diff --git a/testdata/print-gaper.bat b/testdata/print-gaper.bat index 76de61b..b067a80 100644 --- a/testdata/print-gaper.bat +++ b/testdata/print-gaper.bat @@ -1,2 +1,2 @@ timeout 2 > nul -@echo Gaper +@echo Gaper Test Message diff --git a/watcher_test.go b/watcher_test.go index 2baa39d..b0201bd 100644 --- a/watcher_test.go +++ b/watcher_test.go @@ -31,9 +31,8 @@ func TestWatcherGlobPath(t *testing.T) { var extensions []string w, err := NewWatcher(pollInterval, watchItems, ignoreItems, extensions) - file := filepath.Join("testdata", "server", "main_test.go") assert.Nil(t, err, "wacher error") - assert.Equal(t, []string{file}, w.IgnoreItems) + assert.Equal(t, []string{"testdata/server/main_test.go"}, w.IgnoreItems) } func TestWatcherWatchChange(t *testing.T) {