Merge pull request #104 from hashicorp/b-windows-scanner-tests
Fix scanner tests on Windows
This commit is contained in:
commit
32f2911ca2
19
appveyor.yml
19
appveyor.yml
@ -1,11 +1,16 @@
|
|||||||
os: Windows Server 2012 R2
|
version: "build-{branch}-{build}"
|
||||||
|
image: Visual Studio 2015
|
||||||
clone_folder: c:\gopath\src\hashicorp\hcl
|
clone_folder: c:\gopath\src\github.com\hashicorp\hcl
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
GOPATH: c:\gopath
|
GOPATH: c:\gopath
|
||||||
GO15VENDOREXPERIMENT: 1
|
init:
|
||||||
|
- git config --global core.autocrlf true
|
||||||
|
install:
|
||||||
|
- cmd: >-
|
||||||
|
echo %Path%
|
||||||
|
|
||||||
|
go version
|
||||||
|
|
||||||
|
go env
|
||||||
build_script:
|
build_script:
|
||||||
- go get
|
- cmd: go test -v ./...
|
||||||
- go test
|
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/hcl/hcl/ast"
|
"github.com/hashicorp/hcl/hcl/ast"
|
||||||
|
"github.com/hashicorp/hcl/testhelper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDecode_interface(t *testing.T) {
|
func TestDecode_interface(t *testing.T) {
|
||||||
@ -88,12 +89,12 @@ func TestDecode_interface(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"multiline.hcl",
|
"multiline.hcl",
|
||||||
false,
|
false,
|
||||||
map[string]interface{}{"foo": "bar\nbaz\n"},
|
map[string]interface{}{"foo": testhelper.Unix2dos("bar\nbaz\n")},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"multiline_no_eof.hcl",
|
"multiline_no_eof.hcl",
|
||||||
false,
|
false,
|
||||||
map[string]interface{}{"foo": "bar\nbaz\n", "key": "value"},
|
map[string]interface{}{"foo": testhelper.Unix2dos("bar\nbaz\n"), "key": "value"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"multiline.json",
|
"multiline.json",
|
||||||
|
@ -11,6 +11,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/hcl/testhelper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var fixtureExtensions = []string{"hcl"}
|
var fixtureExtensions = []string{"hcl"}
|
||||||
@ -324,6 +326,8 @@ func TestRunDiff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expectedOutString := testhelper.Unix2dos(expectedOut.String())
|
||||||
|
|
||||||
_, stdout := mockIO()
|
_, stdout := mockIO()
|
||||||
err = Run(
|
err = Run(
|
||||||
[]string{path},
|
[]string{path},
|
||||||
@ -337,8 +341,8 @@ func TestRunDiff(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %s", err)
|
t.Errorf("unexpected error: %s", err)
|
||||||
}
|
}
|
||||||
if !regexp.MustCompile(expectedOut.String()).Match(stdout.Bytes()) {
|
if !regexp.MustCompile(expectedOutString).Match(stdout.Bytes()) {
|
||||||
t.Errorf("stdout want match:\n%s\ngot:\n%q", expectedOut, stdout)
|
t.Errorf("stdout want match:\n%s\ngot:\n%q", expectedOutString, stdout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
testhelper/unix2dos.go
Normal file
15
testhelper/unix2dos.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package testhelper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Converts the line endings when on Windows
|
||||||
|
func Unix2dos(unix string) string {
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
|
return unix
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Replace(unix, "\n", "\r\n", -1)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user