Skip to content

Commit

Permalink
Add --driver option to test suite for selecting minizinc executable
Browse files Browse the repository at this point in the history
  • Loading branch information
cyderize committed Oct 7, 2020
1 parent c206e74 commit f7561dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ Use the `--solvers` option to specify a subset of solvers to use in the tests. T
pytest --solvers gecode,chuffed
```

Use the `--driver` option to specify the directory containing the minizinc executable. Otherwise, default directories and PATH will be used to locate it.
```sh
pytest --driver=../build
```

## Multiple test suites

To facilitate running the test suite with different minizinc options, `specs/suites.yml` contains configurations for running tests, or a subset of tests using different options.
Expand Down
15 changes: 14 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@
import sys


def pytest_configure():
def pytest_configure(config):
pytest.solver_cache = {}
search = config.getoption("--driver")
if search is not None:
driver = mzn.find_driver([search])
if driver is None:
raise Exception("Failed to find MiniZinc driver in {}".format(search))
driver.make_default()


def pytest_addoption(parser):
parser.addoption(
Expand All @@ -33,6 +40,12 @@ def pytest_addoption(parser):
parser.addoption(
"--all-suites", action="store_true", dest="feature", help="Run all test suites"
)
parser.addoption(
"--driver",
action="store",
metavar="MINIZINC",
help="Directory containing MiniZinc executable",
)


def pytest_collect_file(parent, path):
Expand Down

0 comments on commit f7561dc

Please sign in to comment.