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

Merge 'generate_reference_path' and 'reference_path' in integration tests (bug #672) #715

Merged
merged 4 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 3 additions & 5 deletions docs/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ report:
reportpath: "~/projects/tardis/integration"


# Path to directory containing reference HDF files.
reference: "~/projects/tardis/integration/"

# Path to directory where reference HDF files will be generated and
# saved during the test run. Use "--generate-reference" flag in command
# line args for the purpose, for other cases this will be simply ignored.
generate_reference: "~/projects/tardis/integration/"
# line args for the purpose, for other cases this will denote path
# to the directory containing reference HDF files.
reference: "~/projects/tardis/integration/"


# Speeds up test execution by reducing amount of packets per iteration,
Expand Down
21 changes: 12 additions & 9 deletions tardis/tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def pytest_terminal_summary(terminalreporter):
terminalreporter.config.getvalue("integration-tests")):
# TODO: Add a check whether generation was successful or not.
terminalreporter.write_sep("-", "Generated reference data: {0}".format(os.path.join(
terminalreporter.config.integration_tests_config['generate_reference'],
terminalreporter.config.integration_tests_config['reference'],
tardis_githash[:7]
)))

Expand Down Expand Up @@ -77,15 +77,18 @@ def plot_object(request):
def data_path(request):
integration_tests_config = request.config.integration_tests_config
hdf_filename = "{0}.h5".format(os.path.basename(request.param))
if (request.config.getoption("--generate-reference") ):
ref_path = os.path.join(os.path.expandvars(os.path.expanduser(
integration_tests_config['reference'])), tardis_githash[:7]
)
else:
ref_path = os.path.join(os.path.expandvars(
os.path.expanduser(integration_tests_config['reference'])), hdf_filename
)

path = {
'config_dirpath': request.param,
'reference_filepath': os.path.join(os.path.expandvars(
os.path.expanduser(integration_tests_config['reference'])), hdf_filename
),
'gen_ref_path': os.path.join(os.path.expandvars(os.path.expanduser(
integration_tests_config['generate_reference'])), tardis_githash[:7]
),
'reference_filepath': ref_path,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to think of another name here, because when you generate references, it would be like:
path/as/mentioned/in/yml/githash which is not "filepath" per se.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ping: @yeganer. Rest all of it looks logically correct to me. Please verify it once 🚀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I'll make the necessary changes.

'setup_name': hdf_filename[:-3],
# Temporary hack for providing atom data per individual setup.
# This url has all the atom data files hosted, for downloading.
Expand All @@ -99,8 +102,8 @@ def data_path(request):
))

if (request.config.getoption("--generate-reference") and not
os.path.exists(path['gen_ref_path'])):
os.makedirs(path['gen_ref_path'])
os.path.exists(path['reference_filepath'])):
os.makedirs(path['reference_filepath'])
return path


Expand Down
4 changes: 2 additions & 2 deletions tardis/tests/integration_tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def setup(self, request, reference, data_path, pytestconfig):
self.result.run()
if request.config.getoption("--generate-reference"):
ref_data_path = os.path.join(
data_path['gen_ref_path'], "{0}.h5".format(self.name)
data_path['reference_filepath'], "{0}.h5".format(self.name)
)
if os.path.exists(ref_data_path):
pytest.skip(
Expand All @@ -138,7 +138,7 @@ def setup(self, request, reference, data_path, pytestconfig):
self.result.to_hdf(path_or_buf=ref_data_path,
suffix_count=False)
pytest.skip("Reference data saved at {0}".format(
data_path['gen_ref_path']
data_path['reference_filepath']
))
capmanager.resumecapture()

Expand Down