Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Tests read these files byte for byte and compare them to generated output,
# so check them out with LF line endings on all platforms.
**/testdata/** text eol=lf
4 changes: 1 addition & 3 deletions cgo/cgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ var flagUpdate = flag.Bool("update", false, "Update images based on test output.
// normalizeResult normalizes Go source code that comes out of tests across
// platforms and Go versions.
func normalizeResult(t *testing.T, result string) string {
result = strings.ReplaceAll(result, "\r\n", "\n")

// This changed to 'undefined:', in Go 1.20.
result = strings.ReplaceAll(result, ": undeclared name:", ": undefined:")
// Go 1.20 added a bit more detail
Expand Down Expand Up @@ -103,7 +101,7 @@ func TestCGo(t *testing.T) {
if err != nil {
t.Fatalf("could not read expected output: %v", err)
}
expected := strings.ReplaceAll(string(expectedBytes), "\r\n", "\n")
expected := string(expectedBytes)

// Check whether the output is as expected.
if expected != actual {
Expand Down
9 changes: 4 additions & 5 deletions compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func TestDarwinCgoImportDynamicErrors(t *testing.T) {
if err != nil {
t.Fatal(err)
}
for line := range strings.SplitSeq(strings.ReplaceAll(string(data), "\r\n", "\n"), "\n") {
for line := range strings.SplitSeq(string(data), "\n") {
if after, ok := strings.CutPrefix(line, "// ERROR: "); ok {
expected = append(expected, after)
}
Expand Down Expand Up @@ -639,8 +639,8 @@ func filterIrrelevantIRLines(lines []string) []string {
panic(err)
}
for _, line := range lines {
line = strings.Split(line, ";")[0] // strip out comments/info
line = strings.TrimRight(line, "\r ") // drop '\r' on Windows and remove trailing spaces from comments
line = strings.Split(line, ";")[0] // strip out comments/info
line = strings.TrimRight(line, " ") // remove trailing spaces from comments
if line == "" {
continue
}
Expand Down Expand Up @@ -669,8 +669,7 @@ func TestCompilerErrors(t *testing.T) {
if err != nil {
t.Error(err)
}
errorsFileString := strings.ReplaceAll(string(errorsFile), "\r\n", "\n")
for line := range strings.SplitSeq(errorsFileString, "\n") {
for line := range strings.SplitSeq(string(errorsFile), "\n") {
if after, ok := strings.CutPrefix(line, "// ERROR: "); ok {
expectedErrors = append(expectedErrors, after)
}
Expand Down
2 changes: 1 addition & 1 deletion errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func readErrorMessages(t *testing.T, file string) string {
var errors []string
for line := range strings.SplitSeq(string(data), "\n") {
if strings.HasPrefix(line, "// ERROR: ") {
errors = append(errors, strings.TrimRight(line[len("// ERROR: "):], "\r\n"))
errors = append(errors, line[len("// ERROR: "):])
}
}
return strings.Join(errors, "\n")
Expand Down
2 changes: 1 addition & 1 deletion interp/interp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func normalizeCapturesAttr(s string) string {
func filterIrrelevantIRLines(lines []string) []string {
var out []string
for _, line := range lines {
line = strings.TrimSpace(line) // drop '\r' on Windows
line = strings.TrimSpace(line)
if line == "" || line[0] == ';' {
continue
}
Expand Down
1 change: 0 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,6 @@ func checkOutput(t *testing.T, filename string, actual []byte) {

func checkOutputData(t *testing.T, expectedOutput, actual []byte) {
t.Helper()
expectedOutput = bytes.ReplaceAll(expectedOutput, []byte("\r\n"), []byte("\n"))
actual = bytes.ReplaceAll(actual, []byte("\r\n"), []byte("\n"))

if !bytes.Equal(actual, expectedOutput) {
Expand Down
2 changes: 1 addition & 1 deletion transform/allocs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func TestAllocs2(t *testing.T) {
t.Fatal("could not read test input:", err)
}
var expectedTestOutput strings.Builder
for i, line := range strings.Split(strings.ReplaceAll(string(testInput), "\r\n", "\n"), "\n") {
for i, line := range strings.Split(string(testInput), "\n") {
const prefix = " // OUT: "
if idx := strings.Index(line, prefix); idx > 0 {
msg := line[idx+len(prefix):]
Expand Down
4 changes: 2 additions & 2 deletions transform/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func normalizeCapturesAttr(s string) string {
func filterIrrelevantIRLines(lines []string) []string {
var out []string
for _, line := range lines {
line = strings.Split(line, ";")[0] // strip out comments/info
line = strings.TrimRight(line, "\r ") // drop '\r' on Windows and remove trailing spaces from comments
line = strings.Split(line, ";")[0] // strip out comments/info
line = strings.TrimRight(line, " ") // remove trailing spaces from comments
if line == "" {
continue
}
Expand Down
Loading