From 20cd0e135a6a0460b8af93aaffbe5f82bdf44584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Samin?= Date: Mon, 15 Nov 2021 14:21:37 +0100 Subject: [PATCH] fix(worker): warn for invalid junit file (#6011) Signed-off-by: francois samin --- engine/worker/internal/action/builtin_junit.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/engine/worker/internal/action/builtin_junit.go b/engine/worker/internal/action/builtin_junit.go index b88a80a140..aa8683a746 100644 --- a/engine/worker/internal/action/builtin_junit.go +++ b/engine/worker/internal/action/builtin_junit.go @@ -75,8 +75,21 @@ func RunParseJunitTestResultAction(ctx context.Context, wk workerruntime.Runtime ftests.TestSuites = append(ftests.TestSuites, s) } tests.TestSuites = append(tests.TestSuites, ftests.TestSuites...) + if len(ftests.TestSuites) == 0 { + log.Error(ctx, "unable to find testsuites in %q", f) + wk.SendLog(ctx, workerruntime.LevelInfo, fmt.Sprintf("WARNING: unable to parse %q as valid xUnit report file", filepath.Base(f))) + continue + } + log.Info(ctx, "found %d testsuites in %q", len(ftests.TestSuites), f) } else { tests.TestSuites = append(tests.TestSuites, vf.TestSuites...) + + if len(ftests.TestSuites) == 0 { + log.Error(ctx, "unable to find testsuites in %q", f) + wk.SendLog(ctx, workerruntime.LevelInfo, fmt.Sprintf("WARNING: unable to parse %q as valid xUnit report file", filepath.Base(f))) + continue + } + log.Info(ctx, "found %d testsuites in %q", len(vf.TestSuites), f) } }