From 585bdaffd7644e7ffc610b62b9e633aea9a8682b Mon Sep 17 00:00:00 2001 From: seipan Date: Tue, 16 Jan 2024 01:07:00 +0900 Subject: [PATCH 1/2] feat(command) : test return non-zero exit code Signed-off-by: seipan --- cmd/test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/test.go b/cmd/test.go index ea423ce52..ad7854df4 100755 --- a/cmd/test.go +++ b/cmd/test.go @@ -270,7 +270,7 @@ func (t *Test) GetCmd() *cobra.Command { } t.logger.Debug("the configuration for mocking mongo connection", zap.Any("password", mongoPassword)) - t.tester.Test(path, testReportPath, appCmd, test.TestOptions{ + if !t.tester.Test(path, testReportPath, appCmd, test.TestOptions{ Tests: tests, AppContainer: appContainer, AppNetwork: networkName, @@ -284,7 +284,10 @@ func (t *Test) GetCmd() *cobra.Command { TestsetNoise: testsetNoise, WithCoverage: withCoverage, CoverageReportPath: coverageReportPath, - }, enableTele) + }, enableTele) { + t.logger.Error("failed to run the test") + return errors.New("failed to run the test") + } return nil }, From 8e6072d7b77af260ba6a7c31d08dcccbe39b7676 Mon Sep 17 00:00:00 2001 From: seipan Date: Wed, 17 Jan 2024 01:05:42 +0900 Subject: [PATCH 2/2] fix : remove log & use os.Exit() Signed-off-by: seipan --- cmd/test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/test.go b/cmd/test.go index ad7854df4..c6a7ac152 100755 --- a/cmd/test.go +++ b/cmd/test.go @@ -285,8 +285,7 @@ func (t *Test) GetCmd() *cobra.Command { WithCoverage: withCoverage, CoverageReportPath: coverageReportPath, }, enableTele) { - t.logger.Error("failed to run the test") - return errors.New("failed to run the test") + os.Exit(1) } return nil