@@ -40,7 +40,7 @@ func TestArgsSuppliesCommandLineArgumentsAsInputToPipeOnePerLine(t *testing.T) {
4040 cmd .Env = append (os .Environ (), "SCRIPT_TEST=args" )
4141 got , err := cmd .Output ()
4242 if err != nil {
43- t .Error (err )
43+ t .Fatal (err )
4444 }
4545 want := "hello\n world\n "
4646 if string (got ) != want {
@@ -69,7 +69,7 @@ func TestBasenameRemovesLeadingPathComponentsFromInputLines(t *testing.T) {
6969 want := filepath .Clean (tc .want )
7070 got , err := script .Echo (tc .path ).Basename ().String ()
7171 if err != nil {
72- t .Error (err )
72+ t .Fatal (err )
7373 }
7474 if want != got {
7575 t .Errorf ("%q: want %q, got %q" , tc .path , want , got )
@@ -237,7 +237,7 @@ func TestDirname_RemovesFilenameComponentFromInputLines(t *testing.T) {
237237 want := filepath .Clean (tc .want )
238238 got , err := script .Echo (tc .path ).Dirname ().String ()
239239 if err != nil {
240- t .Error (err )
240+ t .Fatal (err )
241241 }
242242 if want != got {
243243 t .Errorf ("%q: want %q, got %q" , tc .path , want , got )
@@ -254,7 +254,7 @@ func TestEachLine_FiltersInputThroughSuppliedFunction(t *testing.T) {
254254 want := "Hello world\n Goodbye world\n "
255255 got , err := q .String ()
256256 if err != nil {
257- t .Error (err )
257+ t .Fatal (err )
258258 }
259259 if got != want {
260260 t .Errorf ("want %q, got %q" , want , got )
@@ -267,7 +267,7 @@ func TestEchoProducesSuppliedString(t *testing.T) {
267267 p := script .Echo (want )
268268 got , err := p .String ()
269269 if err != nil {
270- t .Error (err )
270+ t .Fatal (err )
271271 }
272272 if got != want {
273273 t .Errorf ("want %q, got %q" , want , got )
@@ -280,7 +280,7 @@ func TestEchoReplacesInputWithSuppliedStringWhenUsedAsFilter(t *testing.T) {
280280 p := script .Echo ("bogus" ).Echo (want )
281281 got , err := p .String ()
282282 if err != nil {
283- t .Error (err )
283+ t .Fatal (err )
284284 }
285285 if got != want {
286286 t .Errorf ("want %q, got %q" , want , got )
@@ -524,7 +524,7 @@ func TestFreqProducesCorrectFrequencyTableForInput(t *testing.T) {
524524 want := "10 apple\n 4 banana\n 4 orange\n 1 kumquat\n "
525525 got , err := script .Echo (input ).Freq ().String ()
526526 if err != nil {
527- t .Error (err )
527+ t .Fatal (err )
528528 }
529529 if want != got {
530530 t .Error (cmp .Diff (want , got ))
@@ -537,7 +537,7 @@ func TestJoinJoinsInputLinesIntoSpaceSeparatedString(t *testing.T) {
537537 want := "hello from the join test\n "
538538 got , err := script .Echo (input ).Join ().String ()
539539 if err != nil {
540- t .Error (err )
540+ t .Fatal (err )
541541 }
542542 if got != want {
543543 t .Errorf ("want %q, got %q" , want , got )
@@ -909,7 +909,7 @@ func TestSHA256Sums_OutputsCorrectHashForEachSpecifiedFile(t *testing.T) {
909909 for _ , tc := range tcs {
910910 got , err := script .ListFiles (tc .testFileName ).SHA256Sums ().String ()
911911 if err != nil {
912- t .Error (err )
912+ t .Fatal (err )
913913 }
914914 if got != tc .want {
915915 t .Errorf ("%q: want %q, got %q" , tc .testFileName , tc .want , got )
@@ -937,7 +937,7 @@ func TestExecRunsGoWithNoArgsAndGetsUsageMessagePlusErrorExitStatus2(t *testing.
937937 t .Error ("want error when command returns a non-zero exit status" )
938938 }
939939 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 )
941941 }
942942 want := 2
943943 got := p .ExitStatus ()
@@ -1030,7 +1030,7 @@ func TestIfExists_ProducesErrorPlusNoOutputForNonexistentFile(t *testing.T) {
10301030 want := ""
10311031 got , err := script .IfExists ("testdata/doesntexist" ).Echo ("hello" ).String ()
10321032 if err == nil {
1033- t .Error ("want error" )
1033+ t .Fatal ("want error" )
10341034 }
10351035 if want != got {
10361036 t .Error (cmp .Diff (want , got ))
@@ -1042,7 +1042,7 @@ func TestIfExists_ProducesOutputAndNoErrorWhenFileExists(t *testing.T) {
10421042 want := "hello"
10431043 got , err := script .IfExists ("testdata/empty.txt" ).Echo ("hello" ).String ()
10441044 if err != nil {
1045- t .Error (err )
1045+ t .Fatal (err )
10461046 }
10471047 if want != got {
10481048 t .Error (cmp .Diff (want , got ))
@@ -1103,7 +1103,7 @@ func TestReadAutoCloser_ReadsAllDataFromSourceAndClosesItAutomatically(t *testin
11031103 acr := script .NewReadAutoCloser (input )
11041104 got , err := io .ReadAll (acr )
11051105 if err != nil {
1106- t .Error (err )
1106+ t .Fatal (err )
11071107 }
11081108 if ! cmp .Equal (want , got ) {
11091109 t .Error (cmp .Diff (want , got ))
@@ -1137,7 +1137,7 @@ func TestStdinReadsFromProgramStandardInput(t *testing.T) {
11371137 cmd .Stdin = script .Echo (want )
11381138 got , err := cmd .Output ()
11391139 if err != nil {
1140- t .Error (err )
1140+ t .Fatal (err )
11411141 }
11421142 if string (got ) != want {
11431143 t .Errorf ("want %q, got %q" , want , string (got ))
@@ -1151,7 +1151,7 @@ func TestStdoutSendsPipeContentsToConfiguredStandardOutput(t *testing.T) {
11511151 p := script .File ("testdata/hello.txt" ).WithStdout (buf )
11521152 wrote , err := p .Stdout ()
11531153 if err != nil {
1154- t .Error (err )
1154+ t .Fatal (err )
11551155 }
11561156 if wrote != len (want ) {
11571157 t .Errorf ("want %d bytes written, got %d" , len (want ), wrote )
@@ -1177,15 +1177,15 @@ func TestAppendFile_AppendsAllItsInputToSpecifiedFile(t *testing.T) {
11771177 extra := " and goodbye"
11781178 wrote , err := script .Echo (extra ).AppendFile (path )
11791179 if err != nil {
1180- t .Error (err )
1180+ t .Fatal (err )
11811181 }
11821182 if int (wrote ) != len (extra ) {
11831183 t .Errorf ("want %d bytes written, got %d" , len (extra ), int (wrote ))
11841184 }
11851185 // check file contains both contents
11861186 got , err := script .File (path ).String ()
11871187 if err != nil {
1188- t .Error (err )
1188+ t .Fatal (err )
11891189 }
11901190 if got != orig + extra {
11911191 t .Errorf ("want %q, got %q" , orig + extra , got )
@@ -1255,7 +1255,7 @@ func TestSHA256Sum_OutputsCorrectHash(t *testing.T) {
12551255 t .Run (tc .name , func (t * testing.T ) {
12561256 got , err := script .Echo (tc .input ).SHA256Sum ()
12571257 if err != nil {
1258- t .Error (err )
1258+ t .Fatal (err )
12591259 }
12601260 if got != tc .want {
12611261 t .Errorf ("want %q, got %q" , tc .want , got )
@@ -1319,7 +1319,7 @@ func TestStringOutputsInputStringUnchanged(t *testing.T) {
13191319 want := "hello, world"
13201320 got , err := script .Echo (want ).String ()
13211321 if err != nil {
1322- t .Error (err )
1322+ t .Fatal (err )
13231323 }
13241324 if want != got {
13251325 t .Error (cmp .Diff (want , got ))
@@ -1341,14 +1341,14 @@ func TestWriteFile_WritesInputToFileCreatingItIfNecessary(t *testing.T) {
13411341 path := t .TempDir () + "/" + t .Name ()
13421342 wrote , err := script .Echo (want ).WriteFile (path )
13431343 if err != nil {
1344- t .Error (err )
1344+ t .Fatal (err )
13451345 }
13461346 if int (wrote ) != len (want ) {
13471347 t .Errorf ("want %d bytes written, got %d" , len (want ), int (wrote ))
13481348 }
13491349 got , err := script .File (path ).String ()
13501350 if err != nil {
1351- t .Error (err )
1351+ t .Fatal (err )
13521352 }
13531353 if got != want {
13541354 t .Errorf ("want %q, got %q" , want , got )
@@ -1367,17 +1367,17 @@ func TestWriteFile_TruncatesExistingFile(t *testing.T) {
13671367 }
13681368 wrote , err := script .Echo (want ).WriteFile (path )
13691369 if err != nil {
1370- t .Error (err )
1370+ t .Fatal (err )
13711371 }
13721372 if int (wrote ) != len (want ) {
13731373 t .Errorf ("want %d bytes written, got %d" , len (want ), int (wrote ))
13741374 }
13751375 got , err := script .File (path ).String ()
13761376 if err != nil {
1377- t .Error (err )
1377+ t .Fatal (err )
13781378 }
13791379 if got == want + "\x00 \x00 \x00 " {
1380- t .Fatalf ("file not truncated on write" )
1380+ t .Errorf ("file not truncated on write" )
13811381 }
13821382 if got != want {
13831383 t .Errorf ("want %q, got %q" , want , got )
@@ -1390,7 +1390,7 @@ func TestWithReader_SetsSuppliedReaderOnPipe(t *testing.T) {
13901390 p := script .NewPipe ().WithReader (strings .NewReader (want ))
13911391 got , err := p .String ()
13921392 if err != nil {
1393- t .Error (err )
1393+ t .Fatal (err )
13941394 }
13951395 if got != want {
13961396 t .Errorf ("want %q, got %q" , want , got )
0 commit comments