Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1731)

Unified Diff: build/android/pylib/exit_code.py

Issue 18323020: Updates the test runner script exit codes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes exit_code tracking to a singleton paradigm Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/exit_code.py
diff --git a/build/android/pylib/exit_code.py b/build/android/pylib/exit_code.py
new file mode 100644
index 0000000000000000000000000000000000000000..d6afcbc5d9b88baef52c64ad6484b44ac930f50f
--- /dev/null
+++ b/build/android/pylib/exit_code.py
@@ -0,0 +1,50 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Effectively a singleton for maintaining exit code state of tests."""
+
+import constants
+
+_exit_code = constants.NORMAL_EXIT_CODE
+
+VALID_EXIT_CODES = [constants.ERROR_EXIT_CODE,
+ constants.WARNING_EXIT_CODE,
+ constants.NORMAL_EXIT_CODE]
+
+
+class InvalidExitCodeError(Exception):
+ """Invalid exit code observed."""
+
+
+def UpdateExitCode(new_exit_code):
+ """Updates the exit code with some checking and priority.
+
+ Args:
+ new_exit_code: The exit code to update to.
+
+ Raises:
+ InvalidExitCodeError: If |new_exit_code| is not in the set of
+ valid exit codes.
+ """
+
+ if new_exit_code not in VALID_EXIT_CODES:
+ raise InvalidExitCodeError('Observed exit code: %s' % new_exit_code)
+
+ # Only escalate exit codes
+ global _exit_code
+ if (_exit_code == constants.WARNING_EXIT_CODE and
+ new_exit_code == constants.ERROR_EXIT_CODE):
+ _exit_code = new_exit_code
+ elif _exit_code == constants.NORMAL_EXIT_CODE:
+ _exit_code = new_exit_code
+
+
+def ResetExitCode():
+ global _exit_code
+ _exit_code = constants.NORMAL_EXIT_CODE
+
+
+def GetExitCode():
+ global _exit_code
+ return _exit_code

Powered by Google App Engine
This is Rietveld 408576698