krb5 commit: Add k5test mark() function

Greg Hudson ghudson at mit.edu
Sun Apr 22 13:11:01 EDT 2018


https://github.com/krb5/krb5/commit/4e813204ac3dace93297f47d64dfc0aaecc370f8
commit 4e813204ac3dace93297f47d64dfc0aaecc370f8
Author: Greg Hudson <ghudson at mit.edu>
Date:   Wed Apr 18 19:21:40 2018 -0400

    Add k5test mark() function
    
    Make it easier to locate a failing command in long Python test scripts
    by allowing the script to output marks, and displaying the most recent
    mark with command failures.

 src/util/k5test.py |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/util/k5test.py b/src/util/k5test.py
index 4d30baf..bc32877 100644
--- a/src/util/k5test.py
+++ b/src/util/k5test.py
@@ -141,6 +141,11 @@ Scripts may use the following functions and variables:
   added newline) in testlog, and write it to stdout if running
   verbosely.
 
+* mark(message): Place a divider message in the test output, to make
+  it easier to determine what part of the test script a command
+  invocation belongs to.  The last mark message will also be displayed
+  if a command invocation fails.  Do not include a newline in message.
+
 * which(progname): Return the location of progname in the executable
   path, or None if it is not found.
 
@@ -376,6 +381,8 @@ def fail(msg):
     """Print a message and exit with failure."""
     global _current_pass
     print "*** Failure:", msg
+    if _last_mark:
+        print "*** Last mark: %s" % _last_mark
     if _last_cmd:
         print "*** Last command (#%d): %s" % (_cmd_index - 1, _last_cmd)
     if _last_cmd_output:
@@ -392,6 +399,12 @@ def success(msg):
     _success = True
 
 
+def mark(msg):
+    global _last_mark
+    output('\n====== %s ======\n' % msg)
+    _last_mark = msg
+
+
 def skipped(whatmsg, whymsg):
     output('*** Skipping: %s: %s\n' % (whatmsg, whymsg), force_verbose=True)
     f = open(os.path.join(buildtop, 'skiptests'), 'a')
@@ -1275,6 +1288,7 @@ atexit.register(_onexit)
 signal.signal(signal.SIGINT, _onsigint)
 _outfile = open('testlog', 'w')
 _cmd_index = 1
+_last_mark = None
 _last_cmd = None
 _last_cmd_output = None
 buildtop = _find_buildtop()


More information about the cvs-krb5 mailing list