@@ -16,10 +16,9 @@ var out output.OutputWriter
1616
1717// TestCommand executes the test argument
1818// testPath is the path to the test suite config, it can be a dir or file
19- // titleFilterTitle is the title of test which should be executed, if empty it will execute all tests
2019// ctx holds the command flags. If directory scanning is enabled with --dir it is
2120// not supported to filter tests, therefore testFilterTitle is an empty string
22- func TestCommand (testPath string , testFilterTitle string , ctx AddCommandContext ) error {
21+ func TestCommand (testPath string , ctx AddCommandContext ) error {
2322 if ctx .Verbose {
2423 log .SetOutput (os .Stdout )
2524 }
@@ -34,16 +33,13 @@ func TestCommand(testPath string, testFilterTitle string, ctx AddCommandContext)
3433 var err error
3534 switch {
3635 case ctx .Dir :
37- if testFilterTitle != "" {
38- return fmt .Errorf ("Test may not be filtered when --dir is enabled" )
39- }
4036 fmt .Println ("Starting test against directory: " + testPath + "..." )
4137 fmt .Println ("" )
42- result , err = testDir (testPath )
38+ result , err = testDir (testPath , ctx . Filters )
4339 default :
4440 fmt .Println ("Starting test file " + testPath + "..." )
4541 fmt .Println ("" )
46- result , err = testFile (testPath , "" , testFilterTitle )
42+ result , err = testFile (testPath , ctx . Filters )
4743 }
4844
4945 if err != nil {
@@ -57,9 +53,8 @@ func TestCommand(testPath string, testFilterTitle string, ctx AddCommandContext)
5753 return nil
5854}
5955
60- func testDir (directory string ) (runtime.Result , error ) {
56+ func testDir (directory string , filters runtime. Filters ) (runtime.Result , error ) {
6157 result := runtime.Result {}
62-
6358 files , err := ioutil .ReadDir (directory )
6459 if err != nil {
6560 return result , fmt .Errorf (err .Error ())
@@ -71,7 +66,7 @@ func testDir(directory string) (runtime.Result, error) {
7166 }
7267
7368 path := path .Join (directory , f .Name ())
74- newResult , err := testFile (path , f .Name (), "" )
69+ newResult , err := testFile (path , f .Name (), filters )
7570 if err != nil {
7671 return result , err
7772 }
@@ -90,25 +85,29 @@ func convergeResults(result runtime.Result, new runtime.Result) runtime.Result {
9085 return result
9186}
9287
93- func testFile (filePath string , fileName string , title string ) (runtime.Result , error ) {
94- s , err := readFile (filePath , fileName )
88+ func testFile (filePath string , fileName string , filters runtime. Filters ) (<- chan runtime.TestResult , error ) {
89+ content , err := readFile (filePath , fileName )
9590 if err != nil {
9691 return runtime.Result {}, fmt .Errorf ("Error " + err .Error ())
9792 }
9893
99- return execute (s , title )
94+ return execute (content , filters )
10095}
10196
102- func execute (s suite.Suite , title string ) (runtime.Result , error ) {
97+ func execute (s suite.Suite , title string ) (runtime.Result , error )
98+ {
10399 tests := s .GetTests ()
100+ if len (filters ) != 0 {
101+ tests = []runtime.TestCase {}
102+ }
104103
105- // Filter tests if test title was given
106- if title != "" {
107- test , err := s .GetTestByTitle (title )
104+ // Filter tests if test filters was given
105+ for _ , f := range filters {
106+ t , err := s .GetTestByTitle (f )
108107 if err != nil {
109108 return runtime.Result {}, err
110109 }
111- tests = []runtime. TestCase { test }
110+ tests = append ( tests , t )
112111 }
113112
114113 r := runtime .NewRuntime (out .GetEventHandler (), s .Nodes ... )
0 commit comments