Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 18752c9

Browse files
adrpoOpenModelica-Hudson
authored andcommitted
fix for ticket:5129
Belonging to [master]: - #2657 - OpenModelica/OpenModelica-testsuite#1034
1 parent 358f0dc commit 18752c9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

Compiler/Script/CevalScriptBackend.mo

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,8 @@ algorithm
15041504
(cache,simSettings) := calculateSimulationSettings(cache,env,vals,msg);
15051505
SimCode.SIMULATION_SETTINGS(outputFormat = outputFormat_str) := simSettings;
15061506
result_file := stringAppendList(List.consOnTrue(not Config.getRunningTestsuite(),compileDir,{executable,"_res.",outputFormat_str}));
1507+
// result file might have been set by simflags (-r ...)
1508+
result_file := selectResultFile(result_file, simflags);
15071509
executableSuffixedExe := stringAppend(executable, getSimulationExtension(Config.simCodeTarget(),System.platform()));
15081510
logFile := stringAppend(executable,".log");
15091511
// adrpo: log file is deleted by buildModel! do NOT DELETE IT AGAIN!
@@ -8114,6 +8116,54 @@ algorithm
81148116
end match;
81158117
end makeLoadLibrariesEntryAbsyn;
81168118

8119+
function selectResultFile
8120+
input output String resultFile;
8121+
input String simflags;
8122+
protected
8123+
Integer nm;
8124+
String f = "";
8125+
algorithm
8126+
// if there is no -r in the simflags, return
8127+
if System.stringFind(simflags, "-r") < 0 then
8128+
return;
8129+
end if;
8130+
// never fail!
8131+
try
8132+
// match -r="file"
8133+
(nm, {_, f}) := System.regex(simflags, "-r=\"(.*?)\"", 2, true);
8134+
if nm == 2 then
8135+
resultFile := f; return;
8136+
end if;
8137+
// match -r='file'
8138+
(nm, {_, f}) := System.regex(simflags, "-r=\'(.*?)\'", 2, true);
8139+
if nm == 2 then
8140+
resultFile := f; return;
8141+
end if;
8142+
// match -r 'file'
8143+
(nm, {_, f}) := System.regex(simflags, "-r[ ]*\"(.*?)\"", 2, true);
8144+
if nm == 2 then
8145+
resultFile := f; return;
8146+
end if;
8147+
// match -r "file"
8148+
(nm, {_, f}) := System.regex(simflags, "-r[ ]*\'(.*?)\'", 2, true);
8149+
if nm == 2 then
8150+
resultFile := f; return;
8151+
end if;
8152+
// match -r=file
8153+
(nm, {_, f}) := System.regex(simflags, "-r=([^ ]*)", 2, true);
8154+
if nm == 2 then
8155+
resultFile := f; return;
8156+
end if;
8157+
// match -r file
8158+
(nm, {_, f}) := System.regex(simflags, "-r[ ]*([^ ]*)", 2, true);
8159+
if nm == 2 then
8160+
resultFile := f; return;
8161+
end if;
8162+
else
8163+
// do nothing
8164+
end try;
8165+
end selectResultFile;
8166+
81178167
annotation(__OpenModelica_Interface="backend");
81188168

81198169
end CevalScriptBackend;

0 commit comments

Comments
 (0)