From be17671c1b30cd08cf1bc90a0d65c3ce1d2a1911 Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Mon, 19 Oct 2020 15:58:13 -0700 Subject: [PATCH 1/2] Add some more printout and catch JSONDecodeError Signed-off-by: Stephen Brawner --- .../ament_cmake_google_benchmark/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ament_cmake_google_benchmark/ament_cmake_google_benchmark/__init__.py b/ament_cmake_google_benchmark/ament_cmake_google_benchmark/__init__.py index e80cea19..86f8a2a5 100644 --- a/ament_cmake_google_benchmark/ament_cmake_google_benchmark/__init__.py +++ b/ament_cmake_google_benchmark/ament_cmake_google_benchmark/__init__.py @@ -74,7 +74,9 @@ def main(argv=sys.argv[1:]): args = parser.parse_args(argv) args.command = command + print("Executing benchmark test command: %s\n\n" % ' '.join(args.command)) res = subprocess.run(args.command) + print("\n\nTest command returned result status {}".format(res.returncode)) try: with open(args.result_file_in, 'r') as in_file: @@ -94,7 +96,16 @@ def main(argv=sys.argv[1:]): open(args.result_file_out, 'w').close() return res.returncode - in_data = json.loads(in_text) + try: + in_data = json.loads(in_text) + except json.decoder.JSONDecodeError as e: + print( + 'Failure parsing performance results file at: %s' % args.result_file_in, + file=sys.stderr) + print(e) + res.returncode = 1 + return res.returncode + overlay_data = None if args.result_file_overlay: with open(args.result_file_overlay, 'r') as overlay_file: From 7ec7695664cf198a6402ceb55f9c96fa2505a85d Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Tue, 20 Oct 2020 10:27:26 -0700 Subject: [PATCH 2/2] Address PR review Signed-off-by: Stephen Brawner --- .../ament_cmake_google_benchmark/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ament_cmake_google_benchmark/ament_cmake_google_benchmark/__init__.py b/ament_cmake_google_benchmark/ament_cmake_google_benchmark/__init__.py index 86f8a2a5..207968e9 100644 --- a/ament_cmake_google_benchmark/ament_cmake_google_benchmark/__init__.py +++ b/ament_cmake_google_benchmark/ament_cmake_google_benchmark/__init__.py @@ -103,7 +103,8 @@ def main(argv=sys.argv[1:]): 'Failure parsing performance results file at: %s' % args.result_file_in, file=sys.stderr) print(e) - res.returncode = 1 + if res.returncode == 0: + res.returncode = 1 return res.returncode overlay_data = None