Skip to content

Commit 6d6bfe5

Browse files
authored
Add new json field to force library version exact match - to be used for MSL (#213)
1 parent a7fcaa5 commit 6d6bfe5

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ The scripts from this repository can be used to run regression tests for public,
5252
{
5353
"library":"MyModelicaLibrary",
5454
"libraryVersion":"main",
55+
"libraryVersionExactMatch":true, // to be sure that the exact version is loaded, not the latest compatible
56+
"libraryVersionLatestInPackageManager":true, // load the latest from the package manager
5557
"referenceFileExtension":"mat",
5658
"referenceFileNameDelimiter":"/",
5759
"referenceFileNameExtraName":"$ClassName",

configs/conf.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{
1212
"library":"Modelica",
1313
"libraryVersion":"4.1.0",
14+
"libraryVersionExactMatch":true,
1415
"referenceFileExtension":"csv",
1516
"referenceFileNameDelimiter":"/",
1617
"referenceFileNameExtraName":"$ClassName",
@@ -20,6 +21,7 @@
2021
{
2122
"library":"Modelica",
2223
"libraryVersion":"4.0.0",
24+
"libraryVersionExactMatch":true,
2325
"referenceFileExtension":"csv",
2426
"referenceFileNameDelimiter":"/",
2527
"referenceFileNameExtraName":"$ClassName",

shared.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def fixData(data,abortSimulationFlag,alarmFlag,overrideDefaults,defaultCustomCom
4343
data["environmentTranslation"] = environmentTranslation
4444
data["libraryVersion"] = data.get("libraryVersion") or "default"
4545
data["libraryVersionLatestInPackageManager"] = data.get("libraryVersionLatestInPackageManager") or False
46+
data["libraryVersionExactMatch"] = data.get("libraryVersionExactMatch") or False
4647
data["alarmFlag"] = data.get("alarmFlag") or (alarmFlag if data["simCodeTarget"]=="C" else "")
4748
data["abortSlowSimulation"] = data.get("abortSlowSimulation") or (abortSimulationFlag if data["simCodeTarget"]=="C" else "")
4849
if "changeHash" in data: # Force rebuilding the library due to change in the testing script

test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,14 @@ def hashReferenceFiles(s):
630630
versions = "{" + ",".join(['"'+v+'"' for v in availableVersions]) + "}"
631631
else:
632632
versions = '{"%s"}' % version
633-
if not omc.sendExpression('loadModel(%s,%s)' % (lib,versions)):
633+
634+
exactMatch=''
635+
if conf["libraryVersionExactMatch"]:
636+
if conf["libraryVersionLatestInPackageManager"]:
637+
raise Exception("Library %s has both libraryVersionLatestInPackageManager:true and libraryVersionExactMatch:true! Make up your mind." % libName)
638+
exactMatch=', requireExactVersion=true'
639+
640+
if not omc.sendExpression('loadModel(%s,%s%s)' % (lib,versions,exactMatch)):
634641
try:
635642
print("Failed to load library %s %s: %s" % (library,versions,omc.sendExpression('OpenModelica.Scripting.getErrorString()')))
636643
except:

0 commit comments

Comments
 (0)