Skip to content

Commit

Permalink
Added script to run the compliance suite (to be added to hudson?)
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16319 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jun 12, 2013
1 parent e312435 commit 96594a6
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Examples/ComplianceSuite.mos
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Runs the ModelicaCompliance suite
// Output is the files "openmodelica.xml" and "openmodelica.html", which is a valid jUnit testcase and possible to generate html reports from (the generated file is one example, using the default xsl)

loadModel(ModelicaCompliance);getErrorString();
writeFile("version","omc "+getVersion()+" compliance suite "+getVersion(ModelicaCompliance));getErrorString();

loadString("
function last
input String str[:];
output String ostr := str[end];
end last;
");getErrorString();

deleteClass(ModelicaCompliance.Components.Declarations.DoubleDeclarationComps);getErrorString();
deleteClass(ModelicaCompliance.Components.Declarations.DoubleDeclarationMixed);getErrorString();
deleteClass(ModelicaCompliance.Components.Declarations.TypeNameAsComponentName);getErrorString();
// system("rm -f ModelicaCompliance.*.res");getErrorString();

allClasses:={cl for cl guard classAnnotationExists(cl,__ModelicaAssociation.TestCase.shouldPass) in getClassNames(recursive=true)};getErrorString();
min(writeFile(typeNameString(cl)+".mos","
writeFile(\""+typeNameString(cl)+".res\",\"<testcase name=\\\""+last(OpenModelica.Scripting.typeNameStrings(cl))+"\\\"><error type=\\\"killed\\\"/></testcase>\");
loadModel(ModelicaCompliance);getErrorString();
deleteClass(ModelicaCompliance.Components.Declarations.DoubleDeclarationComps);getErrorString();
deleteClass(ModelicaCompliance.Components.Declarations.DoubleDeclarationMixed);getErrorString();
deleteClass(ModelicaCompliance.Components.Declarations.TypeNameAsComponentName);getErrorString();
rec:=simulate("+OpenModelica.Scripting.typeNameString(cl)+");getErrorString();
resultFile := rec.resultFile;
success := resultFile "+(if OpenModelica.Scripting.getBooleanClassAnnotation(cl,__ModelicaAssociation.TestCase.shouldPass) then"<>"else"==")+" \"\";
writeFile(\""+typeNameString(cl)+".res\",\"<testcase name=\\\""+last(OpenModelica.Scripting.typeNameStrings(cl))+"\\\">\"+(if not success then \"<error type=\\\""+(if OpenModelica.Scripting.getBooleanClassAnnotation(cl,__ModelicaAssociation.TestCase.shouldPass) then "expected failure" else "failed")+"\\\" message=\\\"\\\"/>\" else \"\")+\"</testcase>\");
") for cl in allClasses);
getErrorString();
commands:={"ulimit -t 120 && omc " + OpenModelica.Scripting.typeNameString(cl) + ".mos" for cl in allClasses};
// system_parallel(commands);getErrorString();

writeFile("ComplianceSuite.sh","#!/bin/bash
OMCRESULT=openmodelica.xml
echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?>' > \"$OMCRESULT\"
echo '<testsuites name=\"'`cat version`'\">' >> \"$OMCRESULT\"
for f in `ls ModelicaCompliance.*.res | sed 's/[.][^.]*[.]res$//' | sort -u`; do
echo \"<testsuite name=\\\"$f\\\">\" >> \"$OMCRESULT\"
for t in `ls $f.*.res | grep \"$f[.][^.]*[.]res\"`; do
echo `cat $t` >> \"$OMCRESULT\"
done
echo \"</testsuite>\" >> \"$OMCRESULT\"
done
echo '</testsuites>' >> \"$OMCRESULT\"
echo \"$OMCRESULT\"
");getErrorString();
system("bash ComplianceSuite.sh");
(filename,error) := OpenModelica.Scripting.uriToFilename("modelica://ModelicaCompliance/Resources/tools/xml-report/report.xsl");getErrorString();
system("xsltproc -o openmodelica.html '" + filename + "' openmodelica.xml");getErrorString();

0 comments on commit 96594a6

Please sign in to comment.