diff options
author | Håkon Hallingstad <hakon@yahooinc.com> | 2021-12-06 14:37:19 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@yahooinc.com> | 2021-12-06 14:37:19 +0100 |
commit | 258d3226cc0f9be1fa36c039fe922503632f7ed2 (patch) | |
tree | a625de9f033efe39d2844382c8adfd075f786bea /client | |
parent | 659e1966d01b196de9308bda8405d4af1a8e2c58 (diff) |
Fix URL and improve message on missing suite
Diffstat (limited to 'client')
-rw-r--r-- | client/go/cmd/prod.go | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/client/go/cmd/prod.go b/client/go/cmd/prod.go index 89dc4cb6094..4ca4d20d105 100644 --- a/client/go/cmd/prod.go +++ b/client/go/cmd/prod.go @@ -142,11 +142,10 @@ $ vespa prod submit`, if pkg.TestPath == "" { fatalErrHint(fmt.Errorf("No tests found"), "The application must be a Java maven project, or include basic HTTP tests under src/test/application/", - "See https://cloud.vespa.ai/en/reference/getting-to-production") + "See https://cloud.vespa.ai/en/getting-to-production") return - } else { - verifyTests(pkg.TestPath, target) } + verifyTests(pkg.TestPath, target) isCI := os.Getenv("CI") != "" if !isCI { fmt.Fprintln(stderr, color.Yellow("Warning:"), "We recommend doing this only from a CD job") @@ -352,10 +351,26 @@ func prompt(r *bufio.Reader, question, defaultAnswer string, validator func(inpu } func verifyTests(testsParent string, target vespa.Target) { - runTests(filepath.Join(testsParent, "tests", "system-test"), target, true) - runTests(filepath.Join(testsParent, "tests", "staging-setup"), target, true) - runTests(filepath.Join(testsParent, "tests", "staging-test"), target, true) - if util.PathExists(filepath.Join(testsParent, "tests", "production-test")) { - runTests(filepath.Join(testsParent, "tests", "production-test"), target, true) + verifyTest(testsParent, "system-test", target, true) + verifyTest(testsParent, "staging-setup", target, true) + verifyTest(testsParent, "staging-test", target, true) + verifyTest(testsParent, "production-test", target, false) +} + +func verifyTest(testsParent string, suite string, target vespa.Target, required bool) { + testDirectory := filepath.Join(testsParent, "tests", suite) + _, err := os.Stat(testDirectory) + if err != nil { + if required { + if errors.Is(err, os.ErrNotExist) { + fatalErrHint(fmt.Errorf("No %s tests found", suite), + fmt.Sprintf("No such directory: %s", testDirectory), + "See https://cloud.vespa.ai/en/reference/testing") + } + fatalErrHint(err, "See https://cloud.vespa.ai/en/reference/testing") + } + return } + + runTests(testDirectory, target, true) } |