Skip to content

Commit

Permalink
Merge pull request #23 from pstelzig/22-turn-mopyregtest-command-line…
Browse files Browse the repository at this point in the history
…-tool-into-a-full-cli

22 turn mopyregtest command line tool into a full cli
  • Loading branch information
pstelzig authored Oct 27, 2023
2 parents b89de92 + 405917f commit d7e4022
Show file tree
Hide file tree
Showing 8 changed files with 763 additions and 82 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/job-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:
run: |
cd examples
python3 -m unittest
- name: Run test generation examples with command line tool
- name: Run test generation examples with mopyregtest command line tool
run: |
cd examples/generate_tests
/github/home/.local/bin/mopyregtest ./gen_tests BlocksLpDist_from_cli \
/github/home/.local/bin/mopyregtest generate --metric=Lp_dist \
./gen_tests BlocksLpDist_from_cli \
~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" \
Modelica.Blocks.Sources.Sine,Modelica.Blocks.Sources.ExpSine,Modelica.Blocks.Sources.Step \
--metric=Lp_dist
Modelica.Blocks.Sources.Sine,Modelica.Blocks.Sources.ExpSine,Modelica.Blocks.Sources.Step
cd gen_tests
python3 test_blockslpdist_from_cli.py
- name: Run test generation examples with script
Expand All @@ -36,4 +36,13 @@ jobs:
python3 gentests_modelica_blocks_sources.py
cd gen_tests
python3 test_blockslpdist_from_script.py
python3 test_blocksuserdef_from_script.py
python3 test_blocksuserdef_from_script.py
- name: Run CSV file comparison with mopyregtest command line tool
run: |
/github/home/.local/bin/mopyregtest compare \
--metric=Lp_dist \
--tol=0.015 \
--vars=y \
--fill-in-method=interpolate \
./examples/test_user_defined_metrics/references/SineNoisy_res.csv \
./examples/test_user_defined_metrics/references/Sine_res.csv
4 changes: 4 additions & 0 deletions .github/workflows/job-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on: [workflow_dispatch]
jobs:
unit-test:
runs-on: ubuntu-latest
container: openmodelica/openmodelica:v1.21.0-minimal
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
Expand All @@ -18,6 +19,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install numpy pandas
- name: Install Modelica STL 4.0.0
run: |
echo "installPackage(Modelica, \"4.0.0+maint.om\", exactMatch=true);" > installModelicaStl.mos && omc installModelicaStl.mos
- name: Run unit tests
run: |
pip3 install --user .
Expand Down
39 changes: 29 additions & 10 deletions examples/generate_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,30 @@ mopyregtest --help
which will print

```bash
usage: mopyregtest [-h] [--metric {norm_p_dist,norm_infty_dist,Lp_dist,Linfty_dist}] [--references REFERENCES]
test_folder test_name package_folder models_in_package
usage: mopyregtest [-h] {generate} ...

options:
-h, --help show this help message and exit

subcommands:
{generate} mopyregtest CLI command overview
generate Generate test case definitions

Command line interface for MoPyRegtest, the CI friendly regression testing tool for Modelica models. This command line interface is a simplified version to
interact with MoPyRegtest. If you want to use all options, please consider creating a dedicated Python script.
```
and furthermore
```bash
mopyregtest generate --help
```
tells you
```bash
usage: mopyregtest generate [-h] [--metric {norm_p_dist,norm_infty_dist,Lp_dist,Linfty_dist}] [--references REFERENCES]
test_folder test_name package_folder models_in_package

positional arguments:
test_folder Path where test shall be generated. Advice: Should not exist yet
Expand All @@ -37,14 +59,11 @@ positional arguments:
options:
-h, --help show this help message and exit
--metric {norm_p_dist,norm_infty_dist,Lp_dist,Linfty_dist}
Metric to be used. Choose here from predefined values. For user-defined metrics please consider creating the tests with a
dedicated script.
Metric to be used. Choose here from predefined values. For user-defined metrics please consider creating the tests with a dedicated
script.
--references REFERENCES
Comma separated list like <model name1>:</path/to/ref1.csv>,<model name2>:</path/to/ref2.csv>. Missing references for models
here will be generated.

Command line interface for the experimental MoPyRegtest test case generator. This interface is a simplified version. If you want to use all options,
please consider creating a dedicated Python script.
Comma separated list like <model name1>:</path/to/ref1.csv>,<model name2>:</path/to/ref2.csv>. Missing references for models here will
be generated.
```
Just like in the
Expand All @@ -56,7 +75,7 @@ change to the folder [examples/generate_tests](/examples/generate_tests), and si
```bash
cd examples/generate_tests
mopyregtest ./gen_tests BlocksLpDist_from_cli ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" Modelica.Blocks.Sources.Sine,Modelica.Blocks.Sources.ExpSine,Modelica.Blocks.Sources.Step --metric=Lp_dist
mopyregtest generate --metric=Lp_dist ./gen_tests BlocksLpDist_from_cli ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" Modelica.Blocks.Sources.Sine,Modelica.Blocks.Sources.ExpSine,Modelica.Blocks.Sources.Step
```
and for Windows just adapt the path to the Modelica Standard library, e.g. to
Expand Down
Loading

0 comments on commit d7e4022

Please sign in to comment.