mirror of https://github.com/maxcnunes/gaper.git
Configure Windows CI
This commit is contained in:
parent
f4157b5069
commit
afc23e95c9
|
@ -2,7 +2,8 @@ gaper
|
||||||
=====
|
=====
|
||||||
|
|
||||||
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
|
[![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)
|
[![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 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)
|
[![Go Report Card](https://goreportcard.com/badge/github.com/maxcnunes/gaper)](https://goreportcard.com/report/github.com/maxcnunes/gaper)
|
||||||
|
|
|
@ -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
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -10,7 +11,7 @@ import (
|
||||||
|
|
||||||
func TestBuilderSuccessBuild(t *testing.T) {
|
func TestBuilderSuccessBuild(t *testing.T) {
|
||||||
bArgs := []string{}
|
bArgs := []string{}
|
||||||
bin := "srv"
|
bin := resolveBinNameByOS("srv")
|
||||||
dir := filepath.Join("testdata", "server")
|
dir := filepath.Join("testdata", "server")
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -48,5 +49,12 @@ func TestBuilderDefaultBinName(t *testing.T) {
|
||||||
dir := filepath.Join("testdata", "server")
|
dir := filepath.Join("testdata", "server")
|
||||||
wd := "/src/projects/project-name"
|
wd := "/src/projects/project-name"
|
||||||
b := NewBuilder(dir, bin, wd, nil)
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,12 @@ func (r *runner) Kill() error {
|
||||||
// Wait for our process to die before we return or hard kill after 3 sec
|
// Wait for our process to die before we return or hard kill after 3 sec
|
||||||
select {
|
select {
|
||||||
case <-time.After(3 * time.Second):
|
case <-time.After(3 * time.Second):
|
||||||
if err := r.command.Process.Kill(); err != nil && err.Error() != errFinished.Error() {
|
if err := r.command.Process.Kill(); err != nil {
|
||||||
return fmt.Errorf("failed to kill: %v", err)
|
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:
|
case <-done:
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,7 @@ func TestRunnerSuccessRun(t *testing.T) {
|
||||||
|
|
||||||
errCmd := <-runner.Errors()
|
errCmd := <-runner.Errors()
|
||||||
assert.Nil(t, errCmd, "async error running binary")
|
assert.Nil(t, errCmd, "async error running binary")
|
||||||
|
assert.Contains(t, stdout.String(), "Gaper Test Message")
|
||||||
if runtime.GOOS == OSWindows {
|
|
||||||
assert.Equal(t, "Gaper\r\n", stdout.String())
|
|
||||||
} else {
|
|
||||||
assert.Equal(t, "Gaper\n", stdout.String())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunnerSuccessKill(t *testing.T) {
|
func TestRunnerSuccessKill(t *testing.T) {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
sleep 2
|
sleep 2
|
||||||
echo "Gaper"
|
echo "Gaper Test Message"
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
timeout 2 > nul
|
timeout 2 > nul
|
||||||
@echo Gaper
|
@echo Gaper Test Message
|
||||||
|
|
|
@ -31,9 +31,8 @@ func TestWatcherGlobPath(t *testing.T) {
|
||||||
var extensions []string
|
var extensions []string
|
||||||
|
|
||||||
w, err := NewWatcher(pollInterval, watchItems, ignoreItems, extensions)
|
w, err := NewWatcher(pollInterval, watchItems, ignoreItems, extensions)
|
||||||
file := filepath.Join("testdata", "server", "main_test.go")
|
|
||||||
assert.Nil(t, err, "wacher error")
|
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) {
|
func TestWatcherWatchChange(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue