]> SALOME platform Git repositories - modules/hydrosolver.git/commitdiff
Salome HOME
[test] Corrections for hs first test
authorYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:03:54 +0000 (17:03 +0100)
committerYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:04:19 +0000 (17:04 +0100)
doc/salome/examples/CTestTestfileInstall.cmake
doc/salome/examples/hs_001_telemac_cata.py

index 08f61954b61184db198f25a649bcbee5a12ccee7..c33b3fc3f749ce366c5f80768194e1da2d3cdd35 100644 (file)
@@ -20,7 +20,7 @@ SET(COMPONENT_NAME HYDROSOLVER)
 SET(TIMEOUT        300)
 
 SET(EXAMPLES_TESTS
-  hs_001_telemac_cata.py
+  hs_001_telemac_cata
 )
 
 FOREACH(tfile ${EXAMPLES_TESTS})
index 90c79cf0ade5f0480fd636c15140f871143a8952..5f866e5dcc3810338f0a4fba913544274caaeee4 100644 (file)
@@ -34,12 +34,18 @@ ENDC = '\033[0m'
 BOLD = '\033[1m'
 UNDERLINE = '\033[4m'
 
-PREFIX = {'telemac2d':'t2d',
-          'telemac3d':'t3d',
-          'tomawac':'tom',
-          'sisyphe':'sis',
-          'artemis':'art',
-          'waqtel':'waq'}
+PREFIX = {
+         't2d':'telemac2d',
+         #'t3d':'telemac3d',
+         #'tom':'tomawac',
+         #'art':'artemis',
+         #'sis':'sisyphe',
+         #'waq':'waqtel',
+         #'stb':'stbtel',
+          'gai':'gaia',
+         #'p3d':'postel3d',
+         #'ice':'khione',
+         }
 
 def diff_cas(cas1, cas2):
     """
@@ -82,7 +88,6 @@ def read_write_eficas(module, steering_file, eficas_steering):
     @param eficas_file Name of the steering file written by Eficas
     """
     from InterfaceQT4.eficas_go import getEficasSsIhm
-    code = 'TELEMAC'
     my_eficas = getEficasSsIhm(code='TELEMAC',labelCode=module)
 
     handler = my_eficas.fileOpen(steering_file)
@@ -102,71 +107,92 @@ def validate_catalog(module, root_dir):
     @param root_dir Telemac root path
     """
     print(" "*2, "~> For module", module)
-    examples_dir = path.join(root_dir, 'examples', module)
+    examples_dirs = path.join(root_dir, 'examples')
     output_dir = path.join(root_dir, 'examples', 'eficas')
 
-    telemac_dico = path.join(root_dir, 'sources', module, module+'.dico')
 
     crashed = []
     different = []
-    for example in sorted(listdir(examples_dir)):
-        example_dir = path.join(examples_dir, example)
-        chdir(example_dir)
-        print("  "*3, "~> In example folder ", example_dir)
-        for case in sorted(listdir(example_dir)):
-            if case.endswith('.cas') and \
-               "_reecrit" not in case and \
-               case[0:3] == PREFIX[module] and \
-               "_reecrit" not in case and \
-               "_ori" not in case:
-                # Adding lang extension (.fr for translated french case)
-                print("  "*4, "~> For test case ", case)
-                root, _ = path.splitext(case)
-
-                lang = ''
-                eficas_case = root + "_reecrit.cas"
-
-                # Import and export in eficas
-                try:
-                    read_write_eficas(module, case, eficas_case)
-                except Exception as e:
-                    print(e)
-                    crashed.append(case)
-                    print(" "*8+FAIL+"FAILED"+ENDC)
-                    print(" "*8+"Crashed in eficas")
-                    continue
-
-                ori_cas = TelemacCas(case, telemac_dico)
-                eficas_cas = TelemacCas(eficas_case, telemac_dico)
-
-                isdiff = diff_cas(ori_cas, eficas_cas)
-
-                if not isdiff:
-                    different.append(case)
-                    print(" "*8+FAIL+"FAILED"+ENDC)
-                    print(" "*8+"Diff in steering case")
-                    continue
-
-                # Clean up of files
-                remove(eficas_case)
-
-                # Passed the test case
-                print(" "*8+OKGREEN+"PASSED"+ENDC)
-
-    if crashed != []:
-        print("The following test in", module,
-              " crashed in eficas:", crashed)
-    if different != []:
-        print("The following test in", module,
-              " have a difference with normal run:", different)
-
-salome.salome_init()
+    for folder in sorted(listdir(examples_dirs)):
+        if folder in ['python3']:
+            continue
+        for example in sorted(listdir(path.join(examples_dirs, folder))):
+            example_dir = path.join(examples_dirs, folder, example)
+            # Skipping files
+            if not path.isdir(example_dir):
+                continue
+            chdir(example_dir)
+            print("  "*3, "~> In example folder ", example_dir)
+            for case in sorted(listdir(example_dir)):
+                if case.endswith('.cas') and \
+                   "_reecrit" not in case and \
+                   "_reecrit" not in case:
+
+                    module = PREFIX.get(case[:3], None)
+                    if module is None:
+                        print("Skipping (prefix not handled): ", case)
+                        continue
+
+                    # Adding lang extension (.fr for translated french case)
+                    print("  "*4, "~> For test case ", case)
+                    root, _ = path.splitext(case)
+
+                    lang = ''
+                    eficas_case = root + "_reecrit.cas"
+
+
+                    # Import and export in eficas
+                    try:
+                        read_write_eficas(module, case, eficas_case)
+                    except Exception as e:
+                        print(e)
+                        crashed.append(folder+'/'+example_dir+'/'+case)
+                        print(" "*8+FAIL+"FAILED"+ENDC)
+                        print(" "*8+"Crashed in eficas")
+                        continue
+
+                    telemac_dico = path.join(root_dir, 'sources', module, module+'.dico')
+                    ori_cas = TelemacCas(case, telemac_dico)
+                    eficas_cas = TelemacCas(eficas_case, telemac_dico)
+
+                    isdiff = diff_cas(ori_cas, eficas_cas)
+
+                    if not isdiff:
+                        different.append(folder+'/'+example_dir+'/'+case)
+                        print(" "*8+FAIL+"FAILED"+ENDC)
+                        print(" "*8+"Diff in steering case")
+                        continue
+
+                    # Clean up of files
+                    remove(eficas_case)
+
+                    # Passed the test case
+                    print(" "*8+OKGREEN+"PASSED"+ENDC)
+
+    return crashed, different
+
 
 #-----------------
 #-- Eficas
 #-----------------
+crasheds = []
+differents = []
 
-for module in ['telemac2d', 'telemac3d']:
+#for module in ['telemac2d', 'telemac3d']:
+for module in ['telemac3d']:
     # Testing loading of catalog
-    validate_catalog(module, environ["HOMETEL"])
-
+    crasheds = []
+    differents = []
+    crashed, different = validate_catalog(module, environ["HOMETEL"])
+    crasheds.extend(crashed)
+    differents.extend(different)
+
+if crasheds != []:
+    print("The following tests "
+          " crashed in eficas:", crashed)
+if differents != []:
+    print("The following tests",
+          " have a difference with normal run:", different)
+
+if crasheds != [] or differents != []:
+    sys.exit(1)