Add a way to run multiple suites with authelia-scripts.

Providing a list of suites test to authelia-scripts will run the
tests of each of them sequentially.

For instance, authelia-scripts suites test Standalone,BypassAll.
pull/487/head^2
Clement Michaud 2019-12-08 13:41:29 +01:00 committed by Clément Michaud
parent e0d4ed2a07
commit da2b3b8370
1 changed files with 15 additions and 4 deletions

View File

@ -183,14 +183,16 @@ func testSuite(cmd *cobra.Command, args []string) {
log.Fatal(err) log.Fatal(err)
} }
// If suite(s) are provided as argument
if len(args) == 1 { if len(args) == 1 {
suite := args[0] suiteArg := args[0]
if runningSuite != "" && suite != runningSuite { if runningSuite != "" && suiteArg != runningSuite {
log.Fatal(errors.New("Running suite (" + runningSuite + ") is different than suite to be tested (" + suite + "). Shutdown running suite and retry")) log.Fatal(errors.New("Running suite (" + runningSuite + ") is different than suite(s) to be tested (" + suiteArg + "). Shutdown running suite and retry"))
} }
if err := runSuiteTests(suite, runningSuite == ""); err != nil { suiteNames := strings.Split(suiteArg, ",")
if err := runMultipleSuitesTests(suiteNames, runningSuite == ""); err != nil {
log.Fatal(err) log.Fatal(err)
} }
} else { } else {
@ -263,6 +265,15 @@ func runSuiteTests(suiteName string, withEnv bool) error {
return testErr return testErr
} }
func runMultipleSuitesTests(suiteNames []string, withEnv bool) error {
for _, suiteName := range suiteNames {
if err := runSuiteTests(suiteName, withEnv); err != nil {
return err
}
}
return nil
}
func runAllSuites() error { func runAllSuites() error {
log.Info("Start running all suites") log.Info("Start running all suites")
for _, s := range listSuites() { for _, s := range listSuites() {