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

Side by Side 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, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Effectively a singleton for maintaining exit code state of tests."""
6
7 import constants
8
9 _exit_code = constants.NORMAL_EXIT_CODE
10
11 VALID_EXIT_CODES = [constants.ERROR_EXIT_CODE,
12 constants.WARNING_EXIT_CODE,
13 constants.NORMAL_EXIT_CODE]
14
15
16 class InvalidExitCodeError(Exception):
17 """Invalid exit code observed."""
18
19
20 def UpdateExitCode(new_exit_code):
21 """Updates the exit code with some checking and priority.
22
23 Args:
24 new_exit_code: The exit code to update to.
25
26 Raises:
27 InvalidExitCodeError: If |new_exit_code| is not in the set of
28 valid exit codes.
29 """
30
31 if new_exit_code not in VALID_EXIT_CODES:
32 raise InvalidExitCodeError('Observed exit code: %s' % new_exit_code)
33
34 # Only escalate exit codes
35 global _exit_code
36 if (_exit_code == constants.WARNING_EXIT_CODE and
37 new_exit_code == constants.ERROR_EXIT_CODE):
38 _exit_code = new_exit_code
39 elif _exit_code == constants.NORMAL_EXIT_CODE:
40 _exit_code = new_exit_code
41
42
43 def ResetExitCode():
44 global _exit_code
45 _exit_code = constants.NORMAL_EXIT_CODE
46
47
48 def GetExitCode():
49 global _exit_code
50 return _exit_code
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698