@@ -40,7 +40,7 @@ func TestArgsSuppliesCommandLineArgumentsAsInputToPipeOnePerLine(t *testing.T) {
40
40
cmd .Env = append (os .Environ (), "SCRIPT_TEST=args" )
41
41
got , err := cmd .Output ()
42
42
if err != nil {
43
- t .Error (err )
43
+ t .Fatal (err )
44
44
}
45
45
want := "hello\n world\n "
46
46
if string (got ) != want {
@@ -69,7 +69,7 @@ func TestBasenameRemovesLeadingPathComponentsFromInputLines(t *testing.T) {
69
69
want := filepath .Clean (tc .want )
70
70
got , err := script .Echo (tc .path ).Basename ().String ()
71
71
if err != nil {
72
- t .Error (err )
72
+ t .Fatal (err )
73
73
}
74
74
if want != got {
75
75
t .Errorf ("%q: want %q, got %q" , tc .path , want , got )
@@ -237,7 +237,7 @@ func TestDirname_RemovesFilenameComponentFromInputLines(t *testing.T) {
237
237
want := filepath .Clean (tc .want )
238
238
got , err := script .Echo (tc .path ).Dirname ().String ()
239
239
if err != nil {
240
- t .Error (err )
240
+ t .Fatal (err )
241
241
}
242
242
if want != got {
243
243
t .Errorf ("%q: want %q, got %q" , tc .path , want , got )
@@ -254,7 +254,7 @@ func TestEachLine_FiltersInputThroughSuppliedFunction(t *testing.T) {
254
254
want := "Hello world\n Goodbye world\n "
255
255
got , err := q .String ()
256
256
if err != nil {
257
- t .Error (err )
257
+ t .Fatal (err )
258
258
}
259
259
if got != want {
260
260
t .Errorf ("want %q, got %q" , want , got )
@@ -267,7 +267,7 @@ func TestEchoProducesSuppliedString(t *testing.T) {
267
267
p := script .Echo (want )
268
268
got , err := p .String ()
269
269
if err != nil {
270
- t .Error (err )
270
+ t .Fatal (err )
271
271
}
272
272
if got != want {
273
273
t .Errorf ("want %q, got %q" , want , got )
@@ -280,7 +280,7 @@ func TestEchoReplacesInputWithSuppliedStringWhenUsedAsFilter(t *testing.T) {
280
280
p := script .Echo ("bogus" ).Echo (want )
281
281
got , err := p .String ()
282
282
if err != nil {
283
- t .Error (err )
283
+ t .Fatal (err )
284
284
}
285
285
if got != want {
286
286
t .Errorf ("want %q, got %q" , want , got )
@@ -524,7 +524,7 @@ func TestFreqProducesCorrectFrequencyTableForInput(t *testing.T) {
524
524
want := "10 apple\n 4 banana\n 4 orange\n 1 kumquat\n "
525
525
got , err := script .Echo (input ).Freq ().String ()
526
526
if err != nil {
527
- t .Error (err )
527
+ t .Fatal (err )
528
528
}
529
529
if want != got {
530
530
t .Error (cmp .Diff (want , got ))
@@ -537,7 +537,7 @@ func TestJoinJoinsInputLinesIntoSpaceSeparatedString(t *testing.T) {
537
537
want := "hello from the join test\n "
538
538
got , err := script .Echo (input ).Join ().String ()
539
539
if err != nil {
540
- t .Error (err )
540
+ t .Fatal (err )
541
541
}
542
542
if got != want {
543
543
t .Errorf ("want %q, got %q" , want , got )
@@ -909,7 +909,7 @@ func TestSHA256Sums_OutputsCorrectHashForEachSpecifiedFile(t *testing.T) {
909
909
for _ , tc := range tcs {
910
910
got , err := script .ListFiles (tc .testFileName ).SHA256Sums ().String ()
911
911
if err != nil {
912
- t .Error (err )
912
+ t .Fatal (err )
913
913
}
914
914
if got != tc .want {
915
915
t .Errorf ("%q: want %q, got %q" , tc .testFileName , tc .want , got )
@@ -937,7 +937,7 @@ func TestExecRunsGoWithNoArgsAndGetsUsageMessagePlusErrorExitStatus2(t *testing.
937
937
t .Error ("want error when command returns a non-zero exit status" )
938
938
}
939
939
if ! strings .Contains (output , "Usage" ) {
940
- t .Fatalf ("want output containing the word 'usage', got %q" , output )
940
+ t .Errorf ("want output containing the word 'usage', got %q" , output )
941
941
}
942
942
want := 2
943
943
got := p .ExitStatus ()
@@ -1030,7 +1030,7 @@ func TestIfExists_ProducesErrorPlusNoOutputForNonexistentFile(t *testing.T) {
1030
1030
want := ""
1031
1031
got , err := script .IfExists ("testdata/doesntexist" ).Echo ("hello" ).String ()
1032
1032
if err == nil {
1033
- t .Error ("want error" )
1033
+ t .Fatal ("want error" )
1034
1034
}
1035
1035
if want != got {
1036
1036
t .Error (cmp .Diff (want , got ))
@@ -1042,7 +1042,7 @@ func TestIfExists_ProducesOutputAndNoErrorWhenFileExists(t *testing.T) {
1042
1042
want := "hello"
1043
1043
got , err := script .IfExists ("testdata/empty.txt" ).Echo ("hello" ).String ()
1044
1044
if err != nil {
1045
- t .Error (err )
1045
+ t .Fatal (err )
1046
1046
}
1047
1047
if want != got {
1048
1048
t .Error (cmp .Diff (want , got ))
@@ -1103,7 +1103,7 @@ func TestReadAutoCloser_ReadsAllDataFromSourceAndClosesItAutomatically(t *testin
1103
1103
acr := script .NewReadAutoCloser (input )
1104
1104
got , err := io .ReadAll (acr )
1105
1105
if err != nil {
1106
- t .Error (err )
1106
+ t .Fatal (err )
1107
1107
}
1108
1108
if ! cmp .Equal (want , got ) {
1109
1109
t .Error (cmp .Diff (want , got ))
@@ -1137,7 +1137,7 @@ func TestStdinReadsFromProgramStandardInput(t *testing.T) {
1137
1137
cmd .Stdin = script .Echo (want )
1138
1138
got , err := cmd .Output ()
1139
1139
if err != nil {
1140
- t .Error (err )
1140
+ t .Fatal (err )
1141
1141
}
1142
1142
if string (got ) != want {
1143
1143
t .Errorf ("want %q, got %q" , want , string (got ))
@@ -1151,7 +1151,7 @@ func TestStdoutSendsPipeContentsToConfiguredStandardOutput(t *testing.T) {
1151
1151
p := script .File ("testdata/hello.txt" ).WithStdout (buf )
1152
1152
wrote , err := p .Stdout ()
1153
1153
if err != nil {
1154
- t .Error (err )
1154
+ t .Fatal (err )
1155
1155
}
1156
1156
if wrote != len (want ) {
1157
1157
t .Errorf ("want %d bytes written, got %d" , len (want ), wrote )
@@ -1177,15 +1177,15 @@ func TestAppendFile_AppendsAllItsInputToSpecifiedFile(t *testing.T) {
1177
1177
extra := " and goodbye"
1178
1178
wrote , err := script .Echo (extra ).AppendFile (path )
1179
1179
if err != nil {
1180
- t .Error (err )
1180
+ t .Fatal (err )
1181
1181
}
1182
1182
if int (wrote ) != len (extra ) {
1183
1183
t .Errorf ("want %d bytes written, got %d" , len (extra ), int (wrote ))
1184
1184
}
1185
1185
// check file contains both contents
1186
1186
got , err := script .File (path ).String ()
1187
1187
if err != nil {
1188
- t .Error (err )
1188
+ t .Fatal (err )
1189
1189
}
1190
1190
if got != orig + extra {
1191
1191
t .Errorf ("want %q, got %q" , orig + extra , got )
@@ -1255,7 +1255,7 @@ func TestSHA256Sum_OutputsCorrectHash(t *testing.T) {
1255
1255
t .Run (tc .name , func (t * testing.T ) {
1256
1256
got , err := script .Echo (tc .input ).SHA256Sum ()
1257
1257
if err != nil {
1258
- t .Error (err )
1258
+ t .Fatal (err )
1259
1259
}
1260
1260
if got != tc .want {
1261
1261
t .Errorf ("want %q, got %q" , tc .want , got )
@@ -1319,7 +1319,7 @@ func TestStringOutputsInputStringUnchanged(t *testing.T) {
1319
1319
want := "hello, world"
1320
1320
got , err := script .Echo (want ).String ()
1321
1321
if err != nil {
1322
- t .Error (err )
1322
+ t .Fatal (err )
1323
1323
}
1324
1324
if want != got {
1325
1325
t .Error (cmp .Diff (want , got ))
@@ -1341,14 +1341,14 @@ func TestWriteFile_WritesInputToFileCreatingItIfNecessary(t *testing.T) {
1341
1341
path := t .TempDir () + "/" + t .Name ()
1342
1342
wrote , err := script .Echo (want ).WriteFile (path )
1343
1343
if err != nil {
1344
- t .Error (err )
1344
+ t .Fatal (err )
1345
1345
}
1346
1346
if int (wrote ) != len (want ) {
1347
1347
t .Errorf ("want %d bytes written, got %d" , len (want ), int (wrote ))
1348
1348
}
1349
1349
got , err := script .File (path ).String ()
1350
1350
if err != nil {
1351
- t .Error (err )
1351
+ t .Fatal (err )
1352
1352
}
1353
1353
if got != want {
1354
1354
t .Errorf ("want %q, got %q" , want , got )
@@ -1367,17 +1367,17 @@ func TestWriteFile_TruncatesExistingFile(t *testing.T) {
1367
1367
}
1368
1368
wrote , err := script .Echo (want ).WriteFile (path )
1369
1369
if err != nil {
1370
- t .Error (err )
1370
+ t .Fatal (err )
1371
1371
}
1372
1372
if int (wrote ) != len (want ) {
1373
1373
t .Errorf ("want %d bytes written, got %d" , len (want ), int (wrote ))
1374
1374
}
1375
1375
got , err := script .File (path ).String ()
1376
1376
if err != nil {
1377
- t .Error (err )
1377
+ t .Fatal (err )
1378
1378
}
1379
1379
if got == want + "\x00 \x00 \x00 " {
1380
- t .Fatalf ("file not truncated on write" )
1380
+ t .Errorf ("file not truncated on write" )
1381
1381
}
1382
1382
if got != want {
1383
1383
t .Errorf ("want %q, got %q" , want , got )
@@ -1390,7 +1390,7 @@ func TestWithReader_SetsSuppliedReaderOnPipe(t *testing.T) {
1390
1390
p := script .NewPipe ().WithReader (strings .NewReader (want ))
1391
1391
got , err := p .String ()
1392
1392
if err != nil {
1393
- t .Error (err )
1393
+ t .Fatal (err )
1394
1394
}
1395
1395
if got != want {
1396
1396
t .Errorf ("want %q, got %q" , want , got )
0 commit comments