Skip to content

Commit

Permalink
- fix testsuite on windows, checking if first char is '/' is obviousl…
Browse files Browse the repository at this point in the history
…y not Windows friendly
  • Loading branch information
adrpo authored and sjoelund committed May 26, 2015
1 parent f8df9d6 commit 2af70e2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
30 changes: 11 additions & 19 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -2847,9 +2847,7 @@ algorithm
case (cache,_,"readSimulationResult",{Values.STRING(filename),Values.ARRAY(valueLst=cvars),Values.INTEGER(size)},st,_)
equation
vars_1 = List.map(cvars, ValuesUtil.printCodeVariableName);
pwd = System.pwd();
pd = System.pathDelimiter();
filename_1 = if System.strncmp("/",filename,1)==0 then filename else stringAppendList({pwd,pd,filename});
filename_1 = Util.absoluteOrRelative(filename);
value = ValuesUtil.readDataset(filename_1, vars_1, size);
then
(cache,value,st);
Expand All @@ -2863,16 +2861,14 @@ algorithm
equation
pwd = System.pwd();
pd = System.pathDelimiter();
filename_1 = if System.strncmp("/",filename,1)==0 then filename else stringAppendList({pwd,pd,filename});
filename_1 = Util.absoluteOrRelative(filename);
i = SimulationResults.readSimulationResultSize(filename_1);
then
(cache,Values.INTEGER(i),st);

case (cache,_,"readSimulationResultVars",{Values.STRING(filename),Values.BOOL(b1),Values.BOOL(b2)},st,_)
equation
pwd = System.pwd();
pd = System.pathDelimiter();
filename_1 = if System.strncmp("/",filename,1)==0 then filename else stringAppendList({pwd,pd,filename});
filename_1 = Util.absoluteOrRelative(filename);
args = SimulationResults.readVariables(filename_1, b1, b2);
vals = List.map(args, ValuesUtil.makeString);
v = ValuesUtil.makeArray(vals);
Expand All @@ -2881,12 +2877,10 @@ algorithm

case (cache,_,"compareSimulationResults",{Values.STRING(filename),Values.STRING(filename_1),Values.STRING(filename2),Values.REAL(x1),Values.REAL(x2),Values.ARRAY(valueLst=cvars)},st,_)
equation
pwd = System.pwd();
pd = System.pathDelimiter();
filename = if System.substring(filename,1,1) == "/" then filename else stringAppendList({pwd,pd,filename});
filename = Util.absoluteOrRelative(filename);
filename_1 = Util.testsuiteFriendlyPath(filename_1);
filename_1 = if System.substring(filename_1,1,1) == "/" then filename_1 else stringAppendList({pwd,pd,filename_1});
filename2 = if System.substring(filename2,1,1) == "/" then filename2 else stringAppendList({pwd,pd,filename2});
filename_1 = Util.absoluteOrRelative(filename_1);
filename2 = Util.absoluteOrRelative(filename2);
vars_1 = List.map(cvars, ValuesUtil.extractValueString);
strings = SimulationResults.cmpSimulationResults(Config.getRunningTestsuite(),filename,filename_1,filename2,x1,x2,vars_1);
cvars = List.map(strings,ValuesUtil.makeString);
Expand All @@ -2911,10 +2905,10 @@ algorithm
equation
pwd = System.pwd();
pd = System.pathDelimiter();
filename = if System.substring(filename,1,1) == "/" then filename else stringAppendList({pwd,pd,filename});
filename = Util.absoluteOrRelative(filename);
filename_1 = Util.testsuiteFriendlyPath(filename_1);
filename_1 = if System.substring(filename_1,1,1) == "/" then filename_1 else stringAppendList({pwd,pd,filename_1});
filename2 = if System.substring(filename2,1,1) == "/" then filename2 else stringAppendList({pwd,pd,filename2});
filename_1 = Util.absoluteOrRelative(filename_1);
filename2 = Util.absoluteOrRelative(filename2);
vars_1 = List.map(cvars, ValuesUtil.extractValueString);
(b,strings) = SimulationResults.diffSimulationResults(Config.getRunningTestsuite(),filename,filename_1,filename2,reltol,reltolDiffMinMax,rangeDelta,vars_1,b);
cvars = List.map(strings,ValuesUtil.makeString);
Expand All @@ -2929,11 +2923,9 @@ algorithm

case (cache,_,"diffSimulationResultsHtml",{Values.STRING(str),Values.STRING(filename),Values.STRING(filename_1),Values.REAL(reltol),Values.REAL(reltolDiffMinMax),Values.REAL(rangeDelta)},st,_)
equation
pwd = System.pwd();
pd = System.pathDelimiter();
filename = if System.substring(filename,1,1) == "/" then filename else stringAppendList({pwd,pd,filename});
filename = Util.absoluteOrRelative(filename);
filename_1 = Util.testsuiteFriendlyPath(filename_1);
filename_1 = if System.substring(filename_1,1,1) == "/" then filename_1 else stringAppendList({pwd,pd,filename_1});
filename_1 = Util.absoluteOrRelative(filename_1);
str = SimulationResults.diffSimulationResultsHtml(Config.getRunningTestsuite(),filename,filename_1,reltol,reltolDiffMinMax,rangeDelta,str);
then
(cache,Values.STRING(str),st);
Expand Down
15 changes: 15 additions & 0 deletions Compiler/Util/Util.mo
Expand Up @@ -1751,5 +1751,20 @@ public function anyReturnTrue<T>
output Boolean b = true;
end anyReturnTrue;

public function absoluteOrRelative
"@author: adrpo
returns the given path if it exists if not it considers it relative and returns that"
input String inFileName;
output String outFileName;
protected
String pwd, pd;
algorithm
pwd := System.pwd();
pd := System.pathDelimiter();
outFileName := if System.regularFileExists(inFileName)
then inFileName
else stringAppendList({pwd,pd,inFileName});
end absoluteOrRelative;

annotation(__OpenModelica_Interface="util");
end Util;

0 comments on commit 2af70e2

Please sign in to comment.