diff --git a/testmodel.py b/testmodel.py index 9305429..d2d2b35 100755 --- a/testmodel.py +++ b/testmodel.py @@ -734,6 +734,7 @@ def wasmJitAcceptsFlag(flagVal): commandLineOptionsRe = re.compile(r'__OpenModelica_commandLineOptions\s*=\s*\\?"([^"\\]*)') daeModeRe = re.compile(r'(?:^|[\s"])(?:--|\+)daeMode(?:=(\w*))?(?![\w=])', re.IGNORECASE) +allowNonStandardRe = re.compile(r'^(?:--|-|\+)allowNonStandardModelica(?:=|$)') def modelCommandLineOptions(): """The flags the model's __OpenModelica_commandLineOptions annotation sets. @@ -816,6 +817,18 @@ def simulateCmd(resimulate): if emit_protected and (conf.get("fmi") or useWasmFmu): sendExpressionOldOrNew('setCommandLineOptions("--fmiFilter=internal")') +# --warnNonStandardModelica reports non-standard Modelica unless the model +# allows it itself, so the annotation is applied here without that flag. +if any("--warnNonStandardModelica" in str(c) for c in conf["customCommands"]): + annotationFlags = modelCommandLineOptions().split(" ") + keptFlags = [f for f in annotationFlags if f and not allowNonStandardRe.match(f)] + if len(keptFlags) < len([f for f in annotationFlags if f]): + with open(errFile, 'a+') as fp: + fp.write("Ignoring --allowNonStandardModelica in the __OpenModelica_commandLineOptions annotation; using: %s\n" % (" ".join(keptFlags) or "no flags")) + sendExpressionOldOrNew('setCommandLineOptions("--ignoreCommandLineOptionsAnnotation=true")') + if keptFlags: + sendExpressionOldOrNew('setCommandLineOptions("%s")' % " ".join(keptFlags)) + start=monotonic() timeout = conf["ulimitOmc"] # If the command has to be killed there is no way to tell which phase it was in,