Skip to content

Commit afc23e9

Browse files
committed
Configure Windows CI
1 parent f4157b5 commit afc23e9

File tree

8 files changed

+53
-15
lines changed

8 files changed

+53
-15
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ gaper
22
=====
33

44
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
5-
[![Build Status](https://travis-ci.org/maxcnunes/gaper.svg?branch=master)](https://travis-ci.org/maxcnunes/gaper)
5+
[![Linux - Build Status](https://travis-ci.org/maxcnunes/gaper.svg?branch=master)](https://travis-ci.org/maxcnunes/gaper)
6+
[![Windows - Build status](https://ci.appveyor.com/api/projects/status/e0g00kmxwv44?svg=true)](https://ci.appveyor.com/project/maxcnunes/gaper)
67
[![Coverage Status](https://codecov.io/gh/maxcnunes/gaper/branch/master/graph/badge.svg)](https://codecov.io/gh/maxcnunes/gaper)
78
[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/maxcnunes/gaper)
89
[![Go Report Card](https://goreportcard.com/badge/github.com/maxcnunes/gaper)](https://goreportcard.com/report/github.com/maxcnunes/gaper)

appveyor.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: "{build}"
2+
3+
# Source Config
4+
5+
clone_folder: c:\gopath\src\github.com\golang\gaper
6+
7+
# Build host
8+
9+
environment:
10+
GOPATH: c:\gopath
11+
GOBIN: c:\gopath\bin
12+
13+
init:
14+
- git config --global core.autocrlf input
15+
16+
# Build
17+
18+
install:
19+
- set Path=c:\go\bin;c:\gopath\bin;%Path%
20+
- go version
21+
- go env
22+
- go get -u github.com/golang/dep/cmd/dep
23+
- choco install make
24+
- make setup
25+
26+
build: false
27+
deploy: false
28+
29+
test_script:
30+
- go build github.com/golang/gaper
31+
- make test

builder_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package main
33
import (
44
"os"
55
"path/filepath"
6+
"runtime"
67
"testing"
78

89
"github.com/stretchr/testify/assert"
910
)
1011

1112
func TestBuilderSuccessBuild(t *testing.T) {
1213
bArgs := []string{}
13-
bin := "srv"
14+
bin := resolveBinNameByOS("srv")
1415
dir := filepath.Join("testdata", "server")
1516
wd, err := os.Getwd()
1617
if err != nil {
@@ -48,5 +49,12 @@ func TestBuilderDefaultBinName(t *testing.T) {
4849
dir := filepath.Join("testdata", "server")
4950
wd := "/src/projects/project-name"
5051
b := NewBuilder(dir, bin, wd, nil)
51-
assert.Equal(t, b.Binary(), "project-name")
52+
assert.Equal(t, b.Binary(), resolveBinNameByOS("project-name"))
53+
}
54+
55+
func resolveBinNameByOS(name string) string {
56+
if runtime.GOOS == OSWindows {
57+
name += ".exe"
58+
}
59+
return name
5260
}

runner.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ func (r *runner) Kill() error {
8787
// Wait for our process to die before we return or hard kill after 3 sec
8888
select {
8989
case <-time.After(3 * time.Second):
90-
if err := r.command.Process.Kill(); err != nil && err.Error() != errFinished.Error() {
91-
return fmt.Errorf("failed to kill: %v", err)
90+
if err := r.command.Process.Kill(); err != nil {
91+
errMsg := err.Error()
92+
// ignore error if the processed has been killed already
93+
if errMsg != errFinished.Error() && errMsg != os.ErrInvalid.Error() {
94+
return fmt.Errorf("failed to kill: %v", err)
95+
}
9296
}
9397
case <-done:
9498
}

runner_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ func TestRunnerSuccessRun(t *testing.T) {
2727

2828
errCmd := <-runner.Errors()
2929
assert.Nil(t, errCmd, "async error running binary")
30-
31-
if runtime.GOOS == OSWindows {
32-
assert.Equal(t, "Gaper\r\n", stdout.String())
33-
} else {
34-
assert.Equal(t, "Gaper\n", stdout.String())
35-
}
30+
assert.Contains(t, stdout.String(), "Gaper Test Message")
3631
}
3732

3833
func TestRunnerSuccessKill(t *testing.T) {

testdata/print-gaper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22
sleep 2
3-
echo "Gaper"
3+
echo "Gaper Test Message"

testdata/print-gaper.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
timeout 2 > nul
2-
@echo Gaper
2+
@echo Gaper Test Message

watcher_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ func TestWatcherGlobPath(t *testing.T) {
3131
var extensions []string
3232

3333
w, err := NewWatcher(pollInterval, watchItems, ignoreItems, extensions)
34-
file := filepath.Join("testdata", "server", "main_test.go")
3534
assert.Nil(t, err, "wacher error")
36-
assert.Equal(t, []string{file}, w.IgnoreItems)
35+
assert.Equal(t, []string{"testdata/server/main_test.go"}, w.IgnoreItems)
3736
}
3837

3938
func TestWatcherWatchChange(t *testing.T) {

0 commit comments

Comments
 (0)