[conduit] Add non-fatal flag to tests



commit a94cd9a089613cee4c8ec28d0774938414fb7c63
Author: John Stowers <john stowers gmail com>
Date:   Fri Sep 10 12:02:58 2010 +1200

    Add non-fatal flag to tests

 scripts/run-tests.sh                          |    7 ++++++-
 test/python-tests/TestCoreSyncFolderFolder.py |   10 +++++-----
 test/python-tests/common.py                   |   14 +++++---------
 3 files changed, 16 insertions(+), 15 deletions(-)
---
diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh
index d71f56a..a360cb2 100755
--- a/scripts/run-tests.sh
+++ b/scripts/run-tests.sh
@@ -24,6 +24,7 @@ Options:\n\
     -o      Offline. Skip tests that require a net connection\n\
     -d      Debug. also print test ouput to console\n\
     -N      Non interactive. Skip tests that require interaction (web login)\n\
+    -x      Dont exit on test failure\n\
 The operation of the script is affected by two environment\n\
 variables. TEST_USERNAME and TEST_PASSWORD are used as\n\
 login information in the relevant dataproviders\n\
@@ -46,7 +47,8 @@ do_dataprovider_tests=0
 do_sync_tests=0
 do_interactive="TRUE"
 do_list=0
-while getopts "cus:odDSNl" options
+do_fatal="TRUE"
+while getopts "cus:odDSNlx" options
 do
     case $options in
         c )     do_coverage=1;;
@@ -58,6 +60,7 @@ do
         S )     do_sync_tests=1;;
         N )     do_interactive="FALSE";;
         l )     do_list=1;;
+        x )     do_fatal="FALSE";;
         \? )    echo -e $USAGE
                 exit 1;;
         * )     echo -e $USAGE
@@ -145,6 +148,7 @@ do
         CONDUIT_LOGFILE=$logfile \
         CONDUIT_ONLINE=$do_online \
         CONDUIT_INTERACTIVE=$do_interactive \
+        CONDUIT_TESTS_FATAL=$do_fatal \
         python $EXEC
     else
         #run the test
@@ -153,6 +157,7 @@ do
         CONDUIT_LOGFILE=$logfile \
         CONDUIT_ONLINE=$do_online \
         CONDUIT_INTERACTIVE=$do_interactive \
+        CONDUIT_TESTS_FATAL=$do_fatal \
         python $EXEC 2> /dev/null | \
         tee $tempfile
     fi
diff --git a/test/python-tests/TestCoreSyncFolderFolder.py b/test/python-tests/TestCoreSyncFolderFolder.py
index c31836f..671029b 100644
--- a/test/python-tests/TestCoreSyncFolderFolder.py
+++ b/test/python-tests/TestCoreSyncFolderFolder.py
@@ -15,7 +15,7 @@ SYNC_N_TIMES = 3
 #an even integer
 NUM_FILES = 10
 #Sleep time for file I/O
-SLEEP_TIME = 1
+SLEEP_TIME = 2
 #Print the mapping DB on the last sync?
 PRINT_MAPPING_DB = False
 
@@ -74,7 +74,7 @@ for i in range(1,SYNC_N_TIMES+1):
     nmaps = len(FILES)/2
 
     abort,error,conflict = test.get_sync_result()
-    ok("Oneway Sync: Sync #%s completed" % i, abort == False and error == False and conflict == False)
+    ok("Oneway Sync: Sync #%s completed (a:%d e:%d c:%d)" % (i,abort,error,conflict), abort == False and error == False and conflict == False)
 
     a = test.get_source_count()
     b = test.get_sink_count()
@@ -93,7 +93,7 @@ for i in range(1,SYNC_N_TIMES+1):
     nmaps = len(FILES)
 
     abort,error,conflict = test.get_sync_result()
-    ok("Sync: Sync #%s completed" % i, abort == False and error == False and conflict == False)
+    ok("Sync: Sync #%s completed (a:%d e:%d c:%d)" % (i,abort,error,conflict), abort == False and error == False and conflict == False)
 
     a = test.get_source_count()
     b = test.get_sink_count()
@@ -137,7 +137,7 @@ for i in range(1,SYNC_N_TIMES+1):
     abort,error,conflict = test.get_sync_result()
     #There will only be a conflict (delete) the first sync, because the two way policy
     #is to replace the deleted items
-    ok("Delete: Sync #%s completed" % i, abort == False and error == False and conflict == (i == 1))
+    ok("Delete: Sync #%s completed (a:%d e:%d c:%d)" % (i,abort,error,conflict), abort == False and error == False and conflict == (i == 1))
 
     a = test.get_source_count()
     b = test.get_sink_count()
@@ -188,7 +188,7 @@ for i in range(1,SYNC_N_TIMES+1):
     nmaps = len(FILES)
     
     abort,error,conflict = test.get_sync_result()
-    ok("Hidden: Sync #%s completed" % i, abort == False and error == False and conflict == False)
+    ok("Hidden: Sync #%s completed (a:%d e:%d c:%d)" % (i,abort,error,conflict), abort == False and error == False and conflict == False)
 
     a = test.get_source_count()
     b = test.get_sink_count()
diff --git a/test/python-tests/common.py b/test/python-tests/common.py
index 8fb0c1b..d21987a 100644
--- a/test/python-tests/common.py
+++ b/test/python-tests/common.py
@@ -66,18 +66,14 @@ def cleanup_threads():
         conduit.GLOBALS.mappingDB.close()
 
 def is_online():
-    try:    
-        return os.environ["CONDUIT_ONLINE"] == "TRUE"
-    except KeyError:
-        return False
+    return os.environ.get("CONDUIT_ONLINE") == "TRUE"
         
 def is_interactive():
-    try:    
-        return os.environ["CONDUIT_INTERACTIVE"] == "TRUE"
-    except KeyError:
-        return False
+    return os.environ.get("CONDUIT_INTERACTIVE") == "TRUE"
 
-def ok(message, code, die=True):
+def ok(message, code, die=None):
+    if die == None:
+        die = os.environ.get("CONDUIT_TESTS_FATAL") == "TRUE"
     if type(code) == int:
         if code == -1:
             print "[FAIL] %s" % message



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]