Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically read test-case config files #100

Merged
merged 5 commits into from
Apr 30, 2021
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
3 changes: 0 additions & 3 deletions compass/landice/tests/enthalpy_benchmark/A/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ def configure(self):
"""
Modify the configuration options for this test case
"""
add_config(self.config, 'compass.landice.tests.enthalpy_benchmark.A',
'A.cfg', exception=True)

with path('compass.landice.tests.enthalpy_benchmark', 'README') as \
target:
symlink(str(target), '{}/README'.format(self.work_dir))
Expand Down
3 changes: 0 additions & 3 deletions compass/landice/tests/enthalpy_benchmark/B/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ def configure(self):
"""
Modify the configuration options for this test case
"""
add_config(self.config, 'compass.landice.tests.enthalpy_benchmark.B',
'B.cfg', exception=True)

with path('compass.landice.tests.enthalpy_benchmark', 'README') as \
target:
symlink(str(target), '{}/README'.format(self.work_dir))
Expand Down
3 changes: 0 additions & 3 deletions compass/ocean/tests/global_ocean/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ def configure_global_ocean(test_case, mesh, init=None):
config.set('global_ocean', 'prefix', '{}wISC'.format(
config.get('global_ocean', 'prefix')))

add_config(config, test_case.__module__, '{}.cfg'.format(test_case.name),
exception=False)

# add a description of the initial condition
if init is not None:
initial_condition = init.initial_condition
Expand Down
3 changes: 0 additions & 3 deletions compass/ocean/tests/ice_shelf_2d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,3 @@ def configure(name, resolution, config):
res_params = res_params[resolution]
for param in res_params:
config.set('ice_shelf_2d', param, '{}'.format(res_params[param]))

add_config(config, 'compass.ocean.tests.ice_shelf_2d.{}'.format(name),
'{}.cfg'.format(name), exception=False)
3 changes: 0 additions & 3 deletions compass/ocean/tests/ziso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,3 @@ def configure(name, resolution, config):
res_params = res_params[resolution]
for param in res_params:
config.set('ziso', param, '{}'.format(res_params[param]))

add_config(config, 'compass.ocean.tests.ziso.{}'.format(name),
'{}.cfg'.format(name), exception=False)
6 changes: 5 additions & 1 deletion compass/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@ def setup_case(path, test_case, config_file, machine, work_dir, baseline_dir,
add_config(config, 'compass.{}'.format(mpas_core),
'{}.cfg'.format(mpas_core))

# add the config options for the configuration (if defined)
# add the config options for the test group (if defined)
test_group = test_case.test_group.name
add_config(config, 'compass.{}.tests.{}'.format(mpas_core, test_group),
'{}.cfg'.format(test_group), exception=False)

# add the config options for the test case (if defined)
add_config(config, test_case.__module__,
'{}.cfg'.format(test_case.name), exception=False)

test_case_dir = os.path.join(work_dir, path)
try:
os.makedirs(test_case_dir)
Expand Down
4 changes: 3 additions & 1 deletion compass/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def configure(self):
Modify the configuration options for this test case. Test cases should
override this method if they want to add config options specific to
the test case, e.g. from a config file stored in the test case's python
package
package. If a test case overrides this method, it should assume that
the ``<self.name>.cfg`` file in its package has already been added
to the config options prior to calling ``configure()``.
"""
pass

Expand Down
14 changes: 10 additions & 4 deletions docs/developers_guide/organization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,16 @@ The :py:meth:`compass.TestCase.configure()` method can be overridden by a
child class to set config options or build them up from defaults stored in
config files within the test case or its test group. The ``self.config``
attribute that is modified in this function will be written to a config file
for the test case (see :ref:`config_files`). Since many test groups need
similar behavior in the ``configure()`` method for each test case, it is common
to have a shared function (sometimes also called ``configure()``) in the
test group, as we discussed in :ref:`dev_test_groups`.
for the test case (see :ref:`config_files`).

If you override this method in a test case, you should assume that the
``<test_case.name>.cfg`` file in its package has already been added to the
config options prior to calling ``configure()``. This happens automatically
during test-case setup.

Since many test groups need similar behavior in the ``configure()`` method for
each test case, it is common to have a shared function (sometimes also called
``configure()``) in the test group, as we discussed in :ref:`dev_test_groups`.

:py:meth:`compass.ocean.tests.baroclinic_channel.rpe_test.RpeTest.configure()`
simply calls the shared function in its test group,
Expand Down