Windows: Fix dockerfile\parser unit test

Signed-off-by: John Howard <jhoward@microsoft.com>

rewritten from github.com/moby/moby 864e892e2a310c5b67dfd842e39634dd0d99da73
docker-18.09
John Howard 2015-11-01 20:08:37 -08:00 committed by Tonis Tiigi
parent a32ceafce2
commit 4b2990c545
1 changed files with 7 additions and 0 deletions

View File

@ -1,10 +1,12 @@
package parser package parser
import ( import (
"bytes"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"testing" "testing"
) )
@ -66,6 +68,11 @@ func TestTestData(t *testing.T) {
t.Fatalf("Error reading %s's result file: %v", dir, err) t.Fatalf("Error reading %s's result file: %v", dir, err)
} }
if runtime.GOOS == "windows" {
// CRLF --> CR to match Unix behaviour
content = bytes.Replace(content, []byte{'\x0d', '\x0a'}, []byte{'\x0a'}, -1)
}
if ast.Dump()+"\n" != string(content) { if ast.Dump()+"\n" != string(content) {
fmt.Fprintln(os.Stderr, "Result:\n"+ast.Dump()) fmt.Fprintln(os.Stderr, "Result:\n"+ast.Dump())
fmt.Fprintln(os.Stderr, "Expected:\n"+string(content)) fmt.Fprintln(os.Stderr, "Expected:\n"+string(content))