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.
This commit is contained in:
Clement Michaud 2019-12-08 13:41:29 +01:00 committed by Clément Michaud
parent e0d4ed2a07
commit da2b3b8370

View File

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