From 20215d9190dc38ffc9459a88f2cb227128226784 Mon Sep 17 00:00:00 2001 From: YOANN AUDOUIN Date: Fri, 30 Oct 2020 17:03:54 +0100 Subject: [PATCH] [test] Corrections for hs first test --- .../examples/CTestTestfileInstall.cmake | 2 +- doc/salome/examples/hs_001_telemac_cata.py | 154 ++++++++++-------- 2 files changed, 91 insertions(+), 65 deletions(-) diff --git a/doc/salome/examples/CTestTestfileInstall.cmake b/doc/salome/examples/CTestTestfileInstall.cmake index 08f6195..c33b3fc 100644 --- a/doc/salome/examples/CTestTestfileInstall.cmake +++ b/doc/salome/examples/CTestTestfileInstall.cmake @@ -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}) diff --git a/doc/salome/examples/hs_001_telemac_cata.py b/doc/salome/examples/hs_001_telemac_cata.py index 90c79cf..5f866e5 100644 --- a/doc/salome/examples/hs_001_telemac_cata.py +++ b/doc/salome/examples/hs_001_telemac_cata.py @@ -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) -- 2.39.2