aboutsummaryrefslogtreecommitdiff
path: root/crosperf/crosperf.py
diff options
context:
space:
mode:
authorTiancong Wang <tcwang@google.com>2019-08-07 15:18:51 -0700
committerTiancong Wang <tcwang@google.com>2019-08-09 01:10:17 +0000
commiteb729be4771ebbbc520231e28efef32a5db7f8af (patch)
tree3a846dd34584fb9af9b703e9ab6fae66a749f393 /crosperf/crosperf.py
parente05c52149e50172f7011ad5c2194b6852f3e1e90 (diff)
downloadtoolchain-utils-eb729be4771ebbbc520231e28efef32a5db7f8af.tar.gz
crosperf: Print traceback instead of exception type.
I found that the error message of crosperf is sometimes frustrating that when you trigger an exception somewhere in the crosperf tool, it will always return the exception type. Sometimes it's really hard to find out where the exception/error happens in your code. I think it might make sense to handle all exceptions with a try...except block, to make the error message always appear at last, so raising the original exception prints whole traceback, instead of dropping it to general SystemExit. BUG=None TEST=Tested locally, and added unittest. Change-Id: Id772af444bf3788011c74504c71939d2514f1752 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1743146 Commit-Queue: Tiancong Wang <tcwang@google.com> Tested-by: Tiancong Wang <tcwang@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'crosperf/crosperf.py')
-rwxr-xr-xcrosperf/crosperf.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/crosperf/crosperf.py b/crosperf/crosperf.py
index af0a502f..fddd18b9 100755
--- a/crosperf/crosperf.py
+++ b/crosperf/crosperf.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+# Copyright 2011 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
-# Copyright 2011 Google Inc. All Rights Reserved.
"""The driver script for running performance benchmarks on ChromeOS."""
from __future__ import print_function
@@ -10,6 +13,7 @@ import atexit
import os
import signal
import sys
+
from experiment_runner import ExperimentRunner
from experiment_runner import MockExperimentRunner
from experiment_factory import ExperimentFactory
@@ -137,14 +141,11 @@ def RunCrosperf(argv):
def Main(argv):
try:
RunCrosperf(argv)
- except Exception as ex:
+ except Exception:
# Flush buffers before exiting to avoid out of order printing
sys.stdout.flush()
- sys.stderr.flush()
- print('Crosperf error: %s' % repr(ex))
- sys.stdout.flush()
- sys.stderr.flush()
- sys.exit(1)
+ # Raise exception prints out traceback
+ raise
if __name__ == '__main__':