From da2b3b8370921417e33cfec9e99ccffc7a04b442 Mon Sep 17 00:00:00 2001 From: Clement Michaud Date: Sun, 8 Dec 2019 13:41:29 +0100 Subject: [PATCH] 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. --- cmd/authelia-scripts/cmd_suites.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cmd/authelia-scripts/cmd_suites.go b/cmd/authelia-scripts/cmd_suites.go index cba27645..f8dfe682 100644 --- a/cmd/authelia-scripts/cmd_suites.go +++ b/cmd/authelia-scripts/cmd_suites.go @@ -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() {