From 4164cd2f08378a02a7c930e6d2a1d3282ad89947 Mon Sep 17 00:00:00 2001 From: Naoto Ono Date: Wed, 28 Feb 2024 13:20:17 +0900 Subject: [PATCH] Do not stop pipeline in record test command --- launchable/test_runners/launchable.py | 3 +++ tests/commands/test_api_error.py | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/launchable/test_runners/launchable.py b/launchable/test_runners/launchable.py index f7404f17c..7a17769c5 100644 --- a/launchable/test_runners/launchable.py +++ b/launchable/test_runners/launchable.py @@ -4,6 +4,7 @@ import types import click +from launchable.app import Application from launchable.commands.record.tests import tests as record_tests_cmd from launchable.commands.split_subset import split_subset as split_subset_cmd @@ -104,6 +105,8 @@ def report_files(self, file_mask="*.xml"): @click.argument('source_roots', required=True, nargs=-1) def record_tests(client, source_roots): + if isinstance(client, Application): + return # client type: RecordTests in def launchable.commands.record.tests.tests # Accept both file names and GLOB patterns # Simple globs like '*.xml' can be dealt with by shell, but diff --git a/tests/commands/test_api_error.py b/tests/commands/test_api_error.py index 3219a4c19..489c9d60a 100644 --- a/tests/commands/test_api_error.py +++ b/tests/commands/test_api_error.py @@ -300,6 +300,24 @@ def test_subset(self): @responses.activate @mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token}) def test_record_tests(self): + responses.replace( + responses.GET, + "{base}/intake/organizations/{org}/workspaces/{ws}/builds/{build}".format( + base=get_base_url(), + org=self.organization, + ws=self.workspace, + build=self.build_name), + body=ReadTimeout("error")) + tracking = responses.add( + responses.POST, + CLI_TRACKING_URL.format( + base=get_base_url()), + body=ReadTimeout("error")) + + result = self.cli("record", "tests", "--session", self.session, "minitest", str(self.test_files_dir) + "/") + self.assert_success(result) + # Since Timeout error is caught inside of LaunchableClient, the tracking event is sent twice. + self.assert_tracking_count(tracking=tracking, count=2) responses.replace( responses.POST, "{base}/intake/organizations/{org}/workspaces/{ws}/builds/{build}/test_sessions/{session_id}/events".format( @@ -318,7 +336,7 @@ def test_record_tests(self): result = self.cli("record", "tests", "--session", self.session, "minitest", str(self.test_files_dir) + "/") self.assert_success(result) # Since HTTPError is occurred outside of LaunchableClient, the count is 1. - self.assert_tracking_count(tracking=tracking, count=1) + self.assert_tracking_count(tracking=tracking, count=2) responses.replace( responses.POST, @@ -338,7 +356,7 @@ def test_record_tests(self): result = self.cli("record", "tests", "--session", self.session, "minitest", str(self.test_files_dir) + "/") self.assert_success(result) - self.assert_tracking_count(tracking=tracking, count=1) + self.assert_tracking_count(tracking=tracking, count=2) @responses.activate @mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token})