diff --git a/test.py b/test.py index 1a7883d..ed7b041 100755 --- a/test.py +++ b/test.py @@ -75,6 +75,15 @@ librariespath = os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries')) else: librariespath = os.path.normpath(os.path.join(os.environ.get('HOME'), '.openmodelica', 'libraries')) + +# add openmodelica libraries path if the Modelica libraries are not found in the libraries path +modelicaLibpath = '' +if len(glob.glob('Modelica*', root_dir=librariespath)) == 0: + if isWin: + modelicaLibpath = ';' + os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries')).replace('\\','/') + else: + modelicaLibpath = ':' + os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries')).replace('\\','/') + overrideDefaults = [arg.split("=", 1) for arg in args.default] execAllTests = args.execAllTests msysEnvironment = args.msysEnvironment @@ -256,7 +265,7 @@ def timeSeconds(f): return html.escape("%.2f" % f) if not docker: - omc.sendExpression('setModelicaPath("%s")' % librariespath.replace('\\','/')) + omc.sendExpression('setModelicaPath("%s")' % (librariespath.replace('\\','/') + modelicaLibpath,)) omc_exe=os.path.normpath(os.path.join(omhome,"bin","omc")) dygraphs=os.path.normpath(os.path.join(ompython_omhome or omhome,"share","doc","omc","testmodels","dygraph-combined.js")) print(omc_exe,omc_version,dygraphs) diff --git a/testmodel.py b/testmodel.py index a09bc0c..8be64cc 100755 --- a/testmodel.py +++ b/testmodel.py @@ -6,7 +6,7 @@ import simplejson as json from monotonic import monotonic from OMPython import FindBestOMCSession, OMCSession, OMCSessionZMQ -import shared +import shared, glob parser = argparse.ArgumentParser(description='OpenModelica library testing tool helper (single model)') parser.add_argument('config') @@ -28,6 +28,14 @@ isWin = args.win msysEnvironment = args.msysEnvironment +# add openmodelica libraries path if the Modelica libraries are not found in the libraries path +modelicaLibpath = '' +if len(glob.glob('Modelica*', root_dir=libraries)) == 0: + if isWin: + modelicaLibpath = ';' + os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries')).replace('\\','/') + else: + modelicaLibpath = ':' + os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries')).replace('\\','/') + try: os.mkdir("files") except OSError: @@ -260,7 +268,7 @@ def createOmcSessionNew(): cflags += " " + conf["optlevel"] omc.sendExpression(str("setCFlags(\"%s\")" % cflags), parsed = False) -omc.sendExpression('setModelicaPath("%s")' % libraries, parsed = False) +omc.sendExpression('setModelicaPath("%s")' % (libraries+modelicaLibpath,), parsed = False) if conf.get("ulimitMemory"): # Use at most 80% of the vmem for the GC heap; some memory will be used for other purposes than the GC itself @@ -284,7 +292,7 @@ def loadLibraryInNewOM(): newOMLoaded = True # Broken/old getSimulationOptions; use new one (requires parsing again) assert(ompython_omhome!="") - assert(omc_new.sendExpression('setModelicaPath("%s")' % libraries)) + assert(omc_new.sendExpression('setModelicaPath("%s")' % (libraries+modelicaLibpath,))) loadModels(omc_new, conf) start=monotonic()