main: replace crlf on windows in fmt test

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-05-10 22:23:32 +02:00
parent 4e9e5dad09
commit 9844c74f67

View File

@ -10,6 +10,7 @@ import (
"io/fs" "io/fs"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"sync" "sync"
"testing" "testing"
) )
@ -32,6 +33,9 @@ func TestFormatting(t *testing.T) {
t.Errorf("unable to read %s: %v", path, err) t.Errorf("unable to read %s: %v", path, err)
return return
} }
if runtime.GOOS == "windows" {
src = bytes.ReplaceAll(src, []byte{'\r', '\n'}, []byte{'\n'})
}
formatted, err := format.Source(src) formatted, err := format.Source(src)
if err != nil { if err != nil {
t.Errorf("unable to format %s: %v", path, err) t.Errorf("unable to format %s: %v", path, err)