diff --git a/.github/workflows/FMITest.yml b/.github/workflows/FMITest.yml new file mode 100644 index 000000000..22b259cd1 --- /dev/null +++ b/.github/workflows/FMITest.yml @@ -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' \ No newline at end of file diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index dd2a81096..4d4c32bd5 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -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' \ No newline at end of file diff --git a/tests/test_FMIRegression.py b/tests/test_FMIRegression.py new file mode 100644 index 000000000..a9ace7931 --- /dev/null +++ b/tests/test_FMIRegression.py @@ -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") +