@@ -4,12 +4,12 @@ import (
44 "bytes"
55 "context"
66 "encoding/json"
7+ "errors"
78 "os"
89 "path/filepath"
910 "testing"
1011
1112 "github.com/stretchr/testify/require"
12- "golang.org/x/xerrors"
1313)
1414
1515func TestRunValidationErrors (t * testing.T ) {
@@ -18,22 +18,22 @@ func TestRunValidationErrors(t *testing.T) {
1818 var stdout bytes.Buffer
1919 var stderr bytes.Buffer
2020 neverGit := func (_ context.Context , _ string , _ ... string ) (gitResult , error ) {
21- return gitResult {}, xerrors .New ("git should not be called" )
21+ return gitResult {}, errors .New ("git should not be called" )
2222 }
2323
24- err := run (t .Context (), config {OutMatrix : "matrix.json" }, & stdout , & stderr , neverGit )
24+ err := runCommand (t .Context (), commandConfig { config : config {OutMatrix : "matrix.json" }} , & stdout , & stderr , neverGit , nil )
2525 require .EqualError (t , err , "--base-sha is required" )
2626
27- err = run (t .Context (), config {BaseSHA : "base" }, & stdout , & stderr , neverGit )
27+ err = runCommand (t .Context (), commandConfig { config : config {BaseSHA : "base" }} , & stdout , & stderr , neverGit , nil )
2828 require .EqualError (t , err , "--out-matrix is required" )
2929
30- err = run (t .Context (), config {BaseSHA : "-bad" , OutMatrix : "matrix.json" }, & stdout , & stderr , neverGit )
30+ err = runCommand (t .Context (), commandConfig { config : config {BaseSHA : "-bad" , OutMatrix : "matrix.json" }} , & stdout , & stderr , neverGit , nil )
3131 require .ErrorContains (t , err , "must not start with '-'" )
3232
33- err = run (t .Context (), config {BaseSHA : "base:bad" , OutMatrix : "matrix.json" }, & stdout , & stderr , neverGit )
33+ err = runCommand (t .Context (), commandConfig { config : config {BaseSHA : "base:bad" , OutMatrix : "matrix.json" }} , & stdout , & stderr , neverGit , nil )
3434 require .ErrorContains (t , err , "must not contain ':'" )
3535
36- err = run (t .Context (), config {BaseSHA : "base\x00 bad" , OutMatrix : "matrix.json" }, & stdout , & stderr , neverGit )
36+ err = runCommand (t .Context (), commandConfig { config : config {BaseSHA : "base\x00 bad" , OutMatrix : "matrix.json" }} , & stdout , & stderr , neverGit , nil )
3737 require .ErrorContains (t , err , "must not contain NUL bytes" )
3838}
3939
@@ -99,7 +99,7 @@ func TestShared(t *testing.T) {
9999 summaryPath := filepath .Join (repoRoot , "summary.md" )
100100 var stdout bytes.Buffer
101101 var stderr bytes.Buffer
102- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }, & stdout , & stderr , repo .runner (t ))
102+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }} , & stdout , & stderr , repo .runner (t ), nil )
103103 require .NoError (t , err )
104104 require .Empty (t , stdout .String ())
105105 require .Contains (t , stderr .String (), "selected 2 package targets" )
@@ -159,7 +159,7 @@ func TestAlpha(t *testing.T) {
159159 matrixPath := filepath .Join (repoRoot , "matrix.json" )
160160 var stdout bytes.Buffer
161161 var stderr bytes.Buffer
162- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : "-" }, & stdout , & stderr , repo .runner (t ))
162+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : "-" }} , & stdout , & stderr , repo .runner (t ), nil )
163163 require .NoError (t , err )
164164 require .Contains (t , stdout .String (), "## Go test flake detector selection" )
165165 require .Contains (t , stdout .String (), "### `./pkg`" )
@@ -231,7 +231,7 @@ func TestMain(m *testing.M) {
231231 summaryPath := filepath .Join (repoRoot , "summary.md" )
232232 var stdout bytes.Buffer
233233 var stderr bytes.Buffer
234- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }, & stdout , & stderr , repo .runner (t ))
234+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }} , & stdout , & stderr , repo .runner (t ), nil )
235235 require .NoError (t , err )
236236
237237 var matrix matrixOutput
@@ -289,7 +289,7 @@ func TestRenamed(t *testing.T) {
289289 summaryPath := filepath .Join (repoRoot , "summary.md" )
290290 var stdout bytes.Buffer
291291 var stderr bytes.Buffer
292- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }, & stdout , & stderr , repo .runner (t ))
292+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }} , & stdout , & stderr , repo .runner (t ), nil )
293293 require .NoError (t , err )
294294
295295 var matrix matrixOutput
@@ -352,7 +352,7 @@ func TestHead(t *testing.T) {
352352 matrixPath := filepath .Join (repoRoot , "matrix.json" )
353353 var stdout bytes.Buffer
354354 var stderr bytes.Buffer
355- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }, & stdout , & stderr , repo .runner (t ))
355+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }} , & stdout , & stderr , repo .runner (t ), nil )
356356 require .NoError (t , err )
357357
358358 var matrix matrixOutput
@@ -408,7 +408,7 @@ func TestHiddenIgnored(t *testing.T) {
408408 summaryPath := filepath .Join (repoRoot , "summary.md" )
409409 var stdout bytes.Buffer
410410 var stderr bytes.Buffer
411- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }, & stdout , & stderr , repo .runner (t ))
411+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }} , & stdout , & stderr , repo .runner (t ), nil )
412412 require .NoError (t , err )
413413
414414 var matrix matrixOutput
@@ -477,7 +477,7 @@ func TestPlatform(t *testing.T) {
477477 matrixPath := filepath .Join (repoRoot , "matrix.json" )
478478 var stdout bytes.Buffer
479479 var stderr bytes.Buffer
480- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }, & stdout , & stderr , repo .runner (t ))
480+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }} , & stdout , & stderr , repo .runner (t ), nil )
481481 require .NoError (t , err )
482482
483483 var matrix matrixOutput
@@ -531,7 +531,7 @@ func TestAlpha(t *testing.T) {
531531 summaryPath := filepath .Join (repoRoot , "summary.md" )
532532 var stdout bytes.Buffer
533533 var stderr bytes.Buffer
534- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }, & stdout , & stderr , repo .runner (t ))
534+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath , OutSummary : summaryPath }} , & stdout , & stderr , repo .runner (t ), nil )
535535 require .NoError (t , err )
536536
537537 var matrix matrixOutput
@@ -600,7 +600,7 @@ func init() {
600600 matrixPath := filepath .Join (repoRoot , "matrix.json" )
601601 var stdout bytes.Buffer
602602 var stderr bytes.Buffer
603- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }, & stdout , & stderr , repo .runner (t ))
603+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }} , & stdout , & stderr , repo .runner (t ), nil )
604604 require .NoError (t , err )
605605
606606 var matrix matrixOutput
@@ -660,7 +660,7 @@ func TestMoved(t *testing.T) {
660660 matrixPath := filepath .Join (repoRoot , "matrix.json" )
661661 var stdout bytes.Buffer
662662 var stderr bytes.Buffer
663- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }, & stdout , & stderr , repo .runner (t ))
663+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }} , & stdout , & stderr , repo .runner (t ), nil )
664664 require .NoError (t , err )
665665
666666 var matrix matrixOutput
@@ -731,7 +731,7 @@ func TestNewStable(t *testing.T) {
731731 matrixPath := filepath .Join (repoRoot , "matrix.json" )
732732 var stdout bytes.Buffer
733733 var stderr bytes.Buffer
734- err := run (t .Context (), config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }, & stdout , & stderr , repo .runner (t ))
734+ err := runCommand (t .Context (), commandConfig { config : config {RepoRoot : repoRoot , BaseSHA : "base" , HeadSHA : "head" , OutMatrix : matrixPath }} , & stdout , & stderr , repo .runner (t ), nil )
735735 require .NoError (t , err )
736736
737737 var matrix matrixOutput
0 commit comments