Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/FMITest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: FMITest

on:
workflow_dispatch:
schedule:
- cron: "*/5 * * * *"

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
python-version: ['3.10']
os: ['ubuntu-latest']
omc-version: ['stable']

steps:
- uses: actions/checkout@v4
- name: "Set up OpenModelica Compiler"
uses: AnHeuermann/setup-openmodelica@v0.6
with:
version: ${{ matrix.omc-version }}
packages: |
omc
libraries: |
'Modelica 4.0.0'

- run: "omc --version"

- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install future pyparsing numpy psutil pyzmq pytest pytest-md pytest-emoji

- name: Set timezone
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: 'Europe/Berlin'

- name: Run FMI_EXPORT TEST
uses: pavelzw/pytest-action@v2
with:
verbose: true
emoji: true
job-summary: true
custom-arguments: 'tests/test_FMIRegression.py -v'
click-to-expand: true
report-title: 'FMI_Export TEST REPORT'
2 changes: 1 addition & 1 deletion .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
verbose: true
emoji: true
job-summary: true
custom-arguments: '-v'
custom-arguments: '-v --ignore=tests/test_FMIRegression.py '
click-to-expand: true
report-title: 'Test Report'
53 changes: 53 additions & 0 deletions tests/test_FMIRegression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import OMPython
import tempfile, shutil, os
import pytest


"""
do not change the prefix class name, the class name should have prefix "Test"
according to the documenation of pytest
"""
class Test_FMIRegression:

def checkModel(self, modelName):
mod = OMPython.ModelicaSystem(modelName=modelName)
fileNamePrefix = modelName.split(".")[-1]
fmu = mod.convertMo2Fmu(fileNamePrefix=fileNamePrefix)
assert True == os.path.exists(fmu)
shutil.rmtree(mod.getWorkDirectory(), ignore_errors=True)
mod.__del__()


def test_Modelica_Blocks_Examples_Filter(self):
self.checkModel("Modelica.Blocks.Examples.Filter")

def test_Modelica_Blocks_Examples_RealNetwork1(self):
self.checkModel("Modelica.Blocks.Examples.RealNetwork1")

def test_Modelica_Electrical_Analog_Examples_CauerLowPassAnalog(self):
self.checkModel("Modelica.Electrical.Analog.Examples.CauerLowPassAnalog")

def test_Modelica_Electrical_Digital_Examples_FlipFlop(self):
self.checkModel("Modelica.Electrical.Digital.Examples.FlipFlop")

def test_Modelica_Mechanics_Rotational_Examples_FirstGrounded(self):
self.checkModel("Modelica.Mechanics.Rotational.Examples.FirstGrounded")

def test_Modelica_Mechanics_Rotational_Examples_CoupledClutches(self):
self.checkModel("Modelica.Mechanics.Rotational.Examples.CoupledClutches")

def test_Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum(self):
self.checkModel("Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum")

def test_Modelica_Mechanics_MultiBody_Examples_Elementary_FreeBody(self):
self.checkModel("Modelica.Mechanics.MultiBody.Examples.Elementary.FreeBody")

def test_Modelica_Fluid_Examples_PumpingSystem(self):
self.checkModel("Modelica.Fluid.Examples.PumpingSystem")

def test_Modelica_Fluid_Examples_TraceSubstances_RoomCO2WithControls(self):
self.checkModel("Modelica.Fluid.Examples.TraceSubstances.RoomCO2WithControls")

def test_Modelica_Clocked_Examples_SimpleControlledDrive_ClockedWithDiscreteTextbookController(self):
self.checkModel("Modelica.Clocked.Examples.SimpleControlledDrive.ClockedWithDiscreteTextbookController")