Salome HOME
Ajout d'un test de non régression pour blocFissure
[modules/smesh.git] / src / Tools / blocFissure / CasTests / execution_Cas.py
index 3ca435e59bd2dbb2203742bcfb149f62d9717c92..2213dbce75d8edcb75207a400cb018eb3263474b 100644 (file)
 #
 """Lancement des cas-tests de blocFissure"""
 
-import traceback
-
 import logging
+import os
+import tempfile
+import traceback
 
-from blocFissure import gmu
 from blocFissure.gmu import initLog
-from blocFissure.gmu import geomsmesh
 from blocFissure.gmu.casStandard import casStandard
 
 # -----------------------------------------------------------------------------------------------
-#initLog.setDebug()
-#initLog.setVerbose()
-#initLog.setRelease()
-#initLog.setPerfTests()
+LOGFILE = os.path.join(tempfile.gettempdir(),"blocFissure.log")
+#initLog.setDebug(LOGFILE)     # debug = 10
+#initLog.setVerbose(LOGFILE)   # info = 20
+#initLog.setRelease(LOGFILE)   # warning = 30
+#initLog.setPerfTests(LOGFILE) # critical = 50
+#initLog.setAlways(LOGFILE)    # critical = 50
 
 # ---tous les cas en séquence, ou les cas sélectionnés ...
-TORUNOK = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0] # OK
+TORUNOK = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ] # OK 19/04/2021
 #           0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28
 #RUNALL = False
 RUNALL = True
 if RUNALL:
-  TORUN =   [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
-#             0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28
+  TORUN = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
+#           0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28
+  TORUN = TORUNOK
 else:
   TORUNPB = list()
   for IAUX in TORUNOK:
@@ -59,7 +61,7 @@ else:
   TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # eprouvetteCourbe
   TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # eprouvetteDroite
   TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # fissureGauche
-  TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # fissureGauche2 fissureGauche2
+  TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # fissureGauche2
   TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0] # vis
   TORUN = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] # tube
 #           0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28
@@ -240,20 +242,23 @@ def calcul_cas (n_cas, cas, d_aux, ligne):
     nom = cas.nomProbleme
   texte_a = "\n=== Exécution du cas n° {}, '{}'".format(n_cas,nom)
   logging.critical(ligne+texte_a)
+
   try:
     ok_maillage = cas.executeProbleme()
   except:
     traceback.print_exc()
-    texte = "Problème avec le cas n° {}, '{}'\n".format(n_cas,nom)
     ok_maillage = False
+  if not ok_maillage:
+    texte = "Problème avec le cas n° {}, '{}'\n".format(n_cas,nom)
   print(ligne)
+
   return ok_maillage, texte
 #=============================================================
 def calcul_tout (l_problemes, d_aux):
   """Calcul de tous les cas"""
 
   ligne = "---------------------------------------------------------------------"
-  texte = ""
+  texte = "\n"
   nb_cas_ok = 0
   nb_cas_nook = 0
   for n_cas, cas in enumerate(l_problemes):
@@ -275,6 +280,7 @@ def calcul_tout (l_problemes, d_aux):
     else:
       texte += "Les {} tests se sont bien passés.\n".format(nb_cas)
   print (texte+ligne)
+  logging.critical(ligne+texte)
 
   return
 #=============================================================