@@ -34,14 +34,15 @@ var (
3434 oldListFlag = flag .Bool ("gocheck.list" , false , "List the names of all tests that will be run" )
3535 oldWorkFlag = flag .Bool ("gocheck.work" , false , "Display and do not remove the test working directory" )
3636
37- newFilterFlag = flag .String ("check.f" , "" , "Regular expression selecting which tests and/or suites to run" )
38- newVerboseFlag = flag .Bool ("check.v" , false , "Verbose mode" )
39- newStreamFlag = flag .Bool ("check.vv" , false , "Super verbose mode (disables output caching)" )
40- newBenchFlag = flag .Bool ("check.b" , false , "Run benchmarks" )
41- newBenchTime = flag .Duration ("check.btime" , 1 * time .Second , "approximate run time for each benchmark" )
42- newBenchMem = flag .Bool ("check.bmem" , false , "Report memory benchmarks" )
43- newListFlag = flag .Bool ("check.list" , false , "List the names of all tests that will be run" )
44- newWorkFlag = flag .Bool ("check.work" , false , "Display and do not remove the test working directory" )
37+ newFilterFlag = flag .String ("check.f" , "" , "Regular expression selecting which tests and/or suites to run" )
38+ newVerboseFlag = flag .Bool ("check.v" , false , "Verbose mode" )
39+ newStreamFlag = flag .Bool ("check.vv" , false , "Super verbose mode (disables output caching)" )
40+ newBenchFlag = flag .Bool ("check.b" , false , "Run benchmarks" )
41+ newBenchTime = flag .Duration ("check.btime" , 1 * time .Second , "approximate run time for each benchmark" )
42+ newBenchMem = flag .Bool ("check.bmem" , false , "Report memory benchmarks" )
43+ newListFlag = flag .Bool ("check.list" , false , "List the names of all tests that will be run" )
44+ newWorkFlag = flag .Bool ("check.work" , false , "Display and do not remove the test working directory" )
45+ suiteParallelismFlag = flag .Int ("check.suitep" , 1 , "Run different test suites in parallel" )
4546)
4647
4748// TestingT runs all test suites registered with the Suite function,
@@ -55,7 +56,7 @@ func TestingT(testingT *testing.T) {
5556 conf := & RunConf {
5657 Filter : * oldFilterFlag + * newFilterFlag ,
5758 Verbose : * oldVerboseFlag || * newVerboseFlag ,
58- Stream : * oldStreamFlag || * newStreamFlag ,
59+ Stream : ( * oldStreamFlag || * newStreamFlag ) && ( * suiteParallelismFlag <= 1 ) ,
5960 Benchmark : * oldBenchFlag || * newBenchFlag ,
6061 BenchmarkTime : benchTime ,
6162 BenchmarkMem : * newBenchMem ,
@@ -80,8 +81,27 @@ func TestingT(testingT *testing.T) {
8081// provided run configuration.
8182func RunAll (runConf * RunConf ) * Result {
8283 result := Result {}
83- for _ , suite := range allSuites {
84- result .Add (Run (suite , runConf ))
84+ queueCh := make (chan interface {})
85+ go func () {
86+ for _ , s := range allSuites {
87+ queueCh <- s
88+ }
89+ close (queueCh )
90+ }()
91+ p := * suiteParallelismFlag
92+ if p <= 0 {
93+ p = 1
94+ }
95+ resCh := make (chan * Result )
96+ for i := 0 ; i < p ; i ++ {
97+ go func () {
98+ for s := range queueCh {
99+ resCh <- Run (s , runConf )
100+ }
101+ }()
102+ }
103+ for i := 0 ; i < len (allSuites ); i ++ {
104+ result .Add (<- resCh )
85105 }
86106 return & result
87107}
0 commit comments