summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--appveyor.yml34
-rw-r--r--data.go15
-rw-r--r--data_test.go2
-rw-r--r--process_test.go6
5 files changed, 52 insertions, 8 deletions
diff --git a/README.md b/README.md
index 2a90b4e2..fd4a9214 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
[![Build Status][circleci-image]][circleci-url]
+[![Windows Build][appveyor-image]][appveyor-url]
[![Go Report Card][reportcard-image]][reportcard-url]
[![Codebeat Status][codebeat-image]][codebeat-url]
[![Coverage][gocover-image]][gocover-url]
@@ -54,6 +55,8 @@ Copyright (c) 2016-2017 Dave Henderson
[circleci-image]: https://img.shields.io/circleci/project/hairyhenderson/gomplate.svg?style=flat
[circleci-url]: https://circleci.com/gh/hairyhenderson/gomplate
+[appveyor-image]: https://ci.appveyor.com/api/projects/status/eymky02f5snclyxp/branch/master?svg=true
+[appveyor-url]: https://ci.appveyor.com/project/hairyhenderson/gomplate/branch/master
[reportcard-image]: https://goreportcard.com/badge/github.com/hairyhenderson/gomplate
[reportcard-url]: https://goreportcard.com/report/github.com/hairyhenderson/gomplate
[codebeat-image]: https://codebeat.co/badges/39ed2148-4b86-4d1e-8526-25f60e159ba1
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 00000000..6fc25241
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,34 @@
+version: "{build}"
+
+# Source Config
+clone_folder: c:\gopath\src\github.com\hairyhenderson\gomplate
+
+# Build host
+
+environment:
+ GOPATH: c:\gopath
+ DEPTESTBYPASS501: 1
+ GOVERSION: 1.8
+
+init:
+ - git config --global core.autocrlf input
+
+# Build
+
+install:
+ # Install the specific Go version.
+ - rmdir c:\go /s /q
+ - appveyor DownloadFile https://storage.googleapis.com/golang/go%GOVERSION%.windows-amd64.msi
+ - msiexec /i go%GOVERSION%.windows-amd64.msi /q
+ # - choco install bzr
+ # - set Path=c:\go\bin;c:\gopath\bin;C:\Program Files (x86)\Bazaar\;C:\Program Files\Mercurial\%Path%
+ - set Path=c:\go\bin;c:\gopath\bin;%Path%
+ - go version
+ - go env
+
+build: false
+deploy: false
+
+test_script:
+ - go build github.com/hairyhenderson/gomplate
+ - for /f "" %%G in ('go list github.com/hairyhenderson/gomplate/... ^| find /i /v "/vendor/"') do ( go test -v %%G & IF ERRORLEVEL == 1 EXIT 1) \ No newline at end of file
diff --git a/data.go b/data.go
index 995eb5bd..3a1ded08 100644
--- a/data.go
+++ b/data.go
@@ -153,9 +153,10 @@ func absURL(value string) *url.URL {
if err != nil {
log.Fatalf("Can't get working directory: %s", err)
}
+ urlCwd := strings.Replace(cwd, string(os.PathSeparator), "/", -1)
baseURL := &url.URL{
Scheme: "file",
- Path: cwd + "/",
+ Path: urlCwd + "/",
}
relURL := &url.URL{
Path: value,
@@ -241,22 +242,24 @@ func readFile(source *Source, args ...string) ([]byte, error) {
source.FS = vfs.OS()
}
+ p := filepath.FromSlash(source.URL.Path)
+
// make sure we can access the file
- _, err := source.FS.Stat(source.URL.Path)
+ _, err := source.FS.Stat(p)
if err != nil {
- log.Fatalf("Can't stat %s: %#v", source.URL.Path, err)
+ log.Fatalf("Can't stat %s: %#v", p, err)
return nil, err
}
- f, err := source.FS.OpenFile(source.URL.Path, os.O_RDONLY, 0)
+ f, err := source.FS.OpenFile(p, os.O_RDONLY, 0)
if err != nil {
- log.Fatalf("Can't open %s: %#v", source.URL.Path, err)
+ log.Fatalf("Can't open %s: %#v", p, err)
return nil, err
}
b, err := ioutil.ReadAll(f)
if err != nil {
- log.Fatalf("Can't read %s: %#v", source.URL.Path, err)
+ log.Fatalf("Can't read %s: %#v", p, err)
return nil, err
}
return b, nil
diff --git a/data_test.go b/data_test.go
index 2301f1d4..1be57e3e 100644
--- a/data_test.go
+++ b/data_test.go
@@ -1,3 +1,5 @@
+// +build !windows
+
package main
import (
diff --git a/process_test.go b/process_test.go
index feea2f1c..23a4e1a7 100644
--- a/process_test.go
+++ b/process_test.go
@@ -1,3 +1,5 @@
+// +build !windows
+
package main
import (
@@ -30,7 +32,7 @@ func TestReadInput(t *testing.T) {
}
func TestInputDir(t *testing.T) {
- outDir, err := ioutil.TempDir("test/files/input-dir", "out-temp-")
+ outDir, err := ioutil.TempDir(filepath.Join("test", "files", "input-dir"), "out-temp-")
assert.Nil(t, err)
defer (func() {
if cerr := os.RemoveAll(outDir); cerr != nil {
@@ -45,7 +47,7 @@ func TestInputDir(t *testing.T) {
Sources: map[string]*Source{"config": src},
}
gomplate := NewGomplate(data, "{{", "}}")
- err = processInputDir("test/files/input-dir/in", outDir, gomplate)
+ err = processInputDir(filepath.Join("test", "files", "input-dir", "in"), outDir, gomplate)
assert.Nil(t, err)
top, err := ioutil.ReadFile(filepath.Join(outDir, "top.txt"))