Skip to content

Commit 050d1fe

Browse files
committed
check FMI export regressions
1 parent 3dc006c commit 050d1fe

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

.github/workflows/FMITest.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: FMITest
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "*/5 * * * *"
7+
8+
jobs:
9+
test:
10+
runs-on: ${{ matrix.os }}
11+
timeout-minutes: 30
12+
strategy:
13+
matrix:
14+
python-version: ['3.10']
15+
os: ['ubuntu-latest']
16+
omc-version: ['stable']
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: "Set up OpenModelica Compiler"
21+
uses: AnHeuermann/setup-openmodelica@v0.6
22+
with:
23+
version: ${{ matrix.omc-version }}
24+
packages: |
25+
omc
26+
libraries: |
27+
'Modelica 4.0.0'
28+
29+
- run: "omc --version"
30+
31+
- uses: actions/checkout@v4
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
architecture: 'x64'
37+
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install future pyparsing numpy psutil pyzmq pytest pytest-md pytest-emoji
42+
43+
- name: Set timezone
44+
uses: szenius/set-timezone@v1.2
45+
with:
46+
timezoneLinux: 'Europe/Berlin'
47+
48+
- name: Run FMI_EXPORT TEST
49+
uses: pavelzw/pytest-action@v2
50+
with:
51+
verbose: true
52+
emoji: true
53+
job-summary: true
54+
custom-arguments: 'tests/test_FMIRegression.py -v'
55+
click-to-expand: true
56+
report-title: 'FMI_Export TEST REPORT'

tests/test_FMIRegression.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import OMPython
2+
import tempfile, shutil, os
3+
import pytest
4+
5+
6+
"""
7+
do not change the prefix class name, the class name should have prefix "Test"
8+
according to the documenation of pytest
9+
"""
10+
class Test_FMIRegression:
11+
12+
def checkModel(self, modelName):
13+
mod = OMPython.ModelicaSystem(modelName=modelName)
14+
fileNamePrefix = modelName.split(".")[-1]
15+
fmu = mod.convertMo2Fmu(fileNamePrefix=fileNamePrefix)
16+
assert True == os.path.exists(fmu)
17+
shutil.rmtree(mod.getWorkDirectory(), ignore_errors=True)
18+
mod.__del__()
19+
20+
21+
def test_Modelica_Blocks_Examples_Filter(self):
22+
self.checkModel("Modelica.Blocks.Examples.Filter")
23+
24+
def test_Modelica_Blocks_Examples_RealNetwork1(self):
25+
self.checkModel("Modelica.Blocks.Examples.RealNetwork1")
26+
27+
def test_Modelica_Electrical_Analog_Examples_CauerLowPassAnalog(self):
28+
self.checkModel("Modelica.Electrical.Analog.Examples.CauerLowPassAnalog")
29+
30+
def test_Modelica_Electrical_Digital_Examples_FlipFlop(self):
31+
self.checkModel("Modelica.Electrical.Digital.Examples.FlipFlop")
32+
33+
def test_Modelica_Mechanics_Rotational_Examples_FirstGrounded(self):
34+
self.checkModel("Modelica.Mechanics.Rotational.Examples.FirstGrounded")
35+
36+
def test_Modelica_Mechanics_Rotational_Examples_CoupledClutches(self):
37+
self.checkModel("Modelica.Mechanics.Rotational.Examples.CoupledClutches")
38+
39+
def test_Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum(self):
40+
self.checkModel("Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum")
41+
42+
def test_Modelica_Mechanics_MultiBody_Examples_Elementary_FreeBody(self):
43+
self.checkModel("Modelica.Mechanics.MultiBody.Examples.Elementary.FreeBody")
44+
45+
def test_Modelica_Fluid_Examples_PumpingSystem(self):
46+
self.checkModel("Modelica.Fluid.Examples.PumpingSystem")
47+
48+
def test_Modelica_Fluid_Examples_TraceSubstances_RoomCO2WithControls(self):
49+
self.checkModel("Modelica.Fluid.Examples.TraceSubstances.RoomCO2WithControls")
50+
51+
def test_Modelica_Clocked_Examples_SimpleControlledDrive_ClockedWithDiscreteTextbookController(self):
52+
self.checkModel("Modelica.Clocked.Examples.SimpleControlledDrive.ClockedWithDiscreteTextbookController")
53+

0 commit comments

Comments
 (0)