Skip to content

Commit b55d452

Browse files
committed
testing: Simplify line ending handling in tests
1 parent ea7eac6 commit b55d452

10 files changed

Lines changed: 1 addition & 37 deletions

main_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,6 @@ var commonTestScriptsParam = testscript.Params{
8787
"log": func(ts *testscript.TestScript, neg bool, args []string) {
8888
log.Println(args)
8989
},
90-
// dostounix converts \r\n to \n.
91-
"dostounix": func(ts *testscript.TestScript, neg bool, args []string) {
92-
filename := ts.MkAbs(args[0])
93-
b, err := os.ReadFile(filename)
94-
if err != nil {
95-
ts.Fatalf("%v", err)
96-
}
97-
b = bytes.Replace(b, []byte("\r\n"), []byte{'\n'}, -1)
98-
if err := os.WriteFile(filename, b, 0o666); err != nil {
99-
ts.Fatalf("%v", err)
100-
}
101-
},
10290
// cat prints a file to stdout.
10391
"cat": func(ts *testscript.TestScript, neg bool, args []string) {
10492
filename := ts.MkAbs(args[0])

testscripts/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

testscripts/commands/mod.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Test the hugo mod commands.
22

3-
dostounix golden/vendor.txt
4-
dostounix golden/go.mod.testsubmod
5-
63
hugo mod graph
74
stdout 'empty-hugo'
85
hugo mod verify

testscripts/commands/mod_init.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Test the hugo init command.
2-
dostounix golden/go.mod.testsubmod
32

43
hugo mod init testsubmod
54
cmpenv go.mod $WORK/golden/go.mod.testsubmod

testscripts/commands/mod_npm.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# Test mod npm pack.
22

3-
dostounix golden1/package.json
4-
dostounix golden1/packages/hugoautogen/package.json
5-
dostounix golden1/packages/hugoautogen/hugo_packagemeta.json
6-
dostounix golden2/packages/hugoautogen/package.json
7-
dostounix golden3/packages/hugoautogen/package.json
8-
dostounix golden4/packages/hugoautogen/package.json
9-
dostounix golden5/packages/hugoautogen/package.json
10-
113
hugo mod npm pack
124
cmp packages/hugoautogen/package.json golden1/packages/hugoautogen/package.json
135
cmp package.json golden1/package.json

testscripts/commands/mod_npm__moduleorder.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Test mod npm pack with shuffled modules.
22

3-
dostounix golden1/package.json
4-
dostounix golden1/packages/hugoautogen/package.json
5-
dostounix golden1/packages/hugoautogen/hugo_packagemeta.json
6-
73
hugo mod npm pack
84
cmp packages/hugoautogen/package.json golden1/packages/hugoautogen/package.json
95
cmp package.json golden1/package.json

testscripts/commands/mod_npm_withexisting.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# See https://github.com/gohugoio/hugo/issues/13465
44
[windows] skip
55

6-
dostounix golden/packages/hugoautogen/package.json
7-
dostounix golden/package.json
8-
96
hugo mod npm pack
107
cmp packages/hugoautogen/package.json golden/packages/hugoautogen/package.json
118
cmp package.json golden/package.json

testscripts/commands/mod_tidy.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Test hugo mod tidy.
22

3-
dostounix golden/go.mod.cleaned
4-
53
hugo mod tidy
64

75
cmp go.mod golden/go.mod.cleaned

testscripts/commands/mod_vendor.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
dostounix golden/vendor.txt
2-
31
hugo mod vendor
42
cmp _vendor/modules.txt golden/vendor.txt
53
ls _vendor/github.com/gohugoio/hugo-mod-integrationtests/withconfigtoml

testscripts/commands/mod_vendor__versions.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
dostounix golden/vendor.txt
2-
31
hugo mod vendor
42
cmp _vendor/modules.txt golden/vendor.txt
53
lsr _vendor

0 commit comments

Comments
 (0)