Skip to content

Commit

Permalink
Configure Windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcnunes committed Jun 21, 2018
1 parent f4157b5 commit afc23e9
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package main
import (
"os"
"path/filepath"
"runtime"
"testing"

"github.com/stretchr/testify/assert"
)

func TestBuilderSuccessBuild(t *testing.T) {
bArgs := []string{}
bin := "srv"
bin := resolveBinNameByOS("srv")
dir := filepath.Join("testdata", "server")
wd, err := os.Getwd()
if err != nil {
Expand Down Expand Up @@ -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
}
8 changes: 6 additions & 2 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
}
Expand Down
7 changes: 1 addition & 6 deletions runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion testdata/print-gaper
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
sleep 2
echo "Gaper"
echo "Gaper Test Message"
2 changes: 1 addition & 1 deletion testdata/print-gaper.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
timeout 2 > nul
@echo Gaper
@echo Gaper Test Message
3 changes: 1 addition & 2 deletions watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit afc23e9

Please sign in to comment.