Sfoglia il codice sorgente

try stdout.flush to print from python in jenkins

olivier.massot 9 anni fa
parent
commit
b435908e04
1 ha cambiato i file con 24 aggiunte e 20 eliminazioni
  1. 24 20
      tests/test.py

+ 24 - 20
tests/test.py

@@ -5,35 +5,39 @@ import sys
 import file
 import utilities
 
+def _print_(*args):
+    print(*args)
+    sys.stdout.flush()
 
-print("\n** PREPARATION **")
+
+_print_("\n** PREPARATION **")
 
 if not file.fexists("..\\OpenAccess.accda"):
-    print("unzip OpenAccess.zip in .\\work")
+    _print_("unzip OpenAccess.zip in .\\work")
     os.system("unzip -q ..\\OpenAccess.zip -d .\\work")
 
 for subdir in (".\\work", ".\\results"):
     if file.fexists(subdir):
-        print("clean "+subdir)
+        _print_("clean "+subdir)
         file.frmdir(os.path.abspath(subdir))
     else:
-        print("make dir "+subdir)
+        _print_("make dir "+subdir)
         file.fmkdir(os.path.abspath(subdir))
 
 for zipped_file in ("project0.zip", "db.zip", "empty_project.zip"):
-    print("unzip .\\initial\\{} to .\\work".format(zipped_file))
+    _print_("unzip .\\initial\\{} to .\\work".format(zipped_file))
     os.system("unzip  -q .\\initial\\{} -d .\\work".format(zipped_file))
 
 utilities.clean_sources(".\\reference\\source")
 
-print("\n** TEST EXPORT **")
+_print_("\n** TEST EXPORT **")
 
 accdb_path = ".\\work\\project0.accdb"
 
-print("Export the sources from " + accdb_path)
+_print_("Export the sources from " + accdb_path)
 os.system( accdb_path + " /X test_export" )
 
-print("Verify the log file")
+_print_("Verify the log file")
 result = utilities.verify_log(".\\work\\project0_1.log")
 if result != 0:
     sys.exit(result)
@@ -41,42 +45,42 @@ if result != 0:
 utilities.clean_sources( ".\\work\\source\\" )
 
 zipped_project0 = ".\\work\\project0.zip"
-print("control existence of " + zipped_project0)
+_print_("control existence of " + zipped_project0)
 if not file.fexists( zipped_project0 ):
-    print( zipped_project0 +" does not exist" )
+    _print_( zipped_project0 +" does not exist" )
     sys.exit(1)
 
 source = ".\\work\\source"
 target = ".\\results\\source1"
-print("Copy {} to {}".format(source, target))
+_print_("Copy {} to {}".format(source, target))
 copy_tree(source, target)
 
-print("control the result")
+_print_("control the result")
 result = utilities.compare_dirs( ".\\results\\source1",  ".\\reference\\source" )
 if result != 0:
     sys.exit(result)
-print(".\\results\\source1 and .\\reference\\source are identical")
+_print_(".\\results\\source1 and .\\reference\\source are identical")
 
-print("\n** TEST IMPORTS **")
+_print_("\n** TEST IMPORTS **")
 
 import_project = ".\\work\\empty_project.accdb"
 
-print("Import .\\work\\sources in " + import_project)
+_print_("Import .\\work\\sources in " + import_project)
 os.system(import_project + " /X test_import")
 
-print("Verify the log file")
+_print_("Verify the log file")
 result = utilities.verify_log(".\\work\\empty_project_1.log")
 if result != 0:
     sys.exit(result)
 
-print("copy {} to {}".format(import_project, ".\\results\\empty_project_updated.accdb"))
+_print_("copy {} to {}".format(import_project, ".\\results\\empty_project_updated.accdb"))
 file.fcopy(import_project, ".\\results\\empty_project_updated.accdb")
 
-print("control existence of backup")
+_print_("control existence of backup")
 if not file.fexists(import_project + ".old"):
-    print(import_project + ".old do not exist")
+    _print_(import_project + ".old do not exist")
     sys.exit(1)
 
 
-print("** end **")
+_print_("** end **")
 sys.exit(0)