-
Notifications
You must be signed in to change notification settings - Fork 67
Cleanup, adding unit tests for ccpp_track_variables.py, activate "chunked data" CI test, add missing MPI target in src/CMakeLists.txt
#555
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df36dd2
Activate chunked data CI test
mkavulich 0e0bfb3
Fix error of mismatched return values in prebuild
mkavulich 5ec9f95
Convert main program of ccpp_track_variables to be importable
mkavulich 67dd0b6
Remove duplicate and misleading log messages
mkavulich 68b9003
First attempt at pytest unit testing for ccpp_track_variables.py. Can…
mkavulich 1a0a354
add rest of the tests...debug still failing though...
mkavulich e382e6b
Giving up on debug test for now
mkavulich 830f796
Remove "push" rule in prep for opening PR
mkavulich c615827
Include proper docstrings for new test file, as well as each individu…
mkavulich 55972ff
Have script exit with error code 1 if invoked without pytest
mkavulich 0c65498
Adopt reviewer suggestions
mkavulich 9b94679
Add missing MPI target in src/CMakeLists.txt
climbfuji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,11 +3,12 @@ | |||||
| ----------------------------------------------------------------------- | ||||||
| Description: Contains unit tests for ccpp_track_variables.py script | ||||||
|
|
||||||
| Assumptions: | ||||||
| Assumptions: Assumes user has correct environment for running ccpp_track_variables.py script. | ||||||
| This script should not be run directly, but rather invoked with pytest. | ||||||
|
|
||||||
| Command line arguments: none | ||||||
|
|
||||||
| Usage: python test_var_transforms.py # run the unit tests | ||||||
| Usage: pytest test_track_variables.py # run the unit tests | ||||||
| ----------------------------------------------------------------------- | ||||||
| """ | ||||||
| import sys | ||||||
|
|
@@ -28,6 +29,9 @@ | |||||
| from ccpp_track_variables import track_variables | ||||||
|
|
||||||
| def test_successful_match(capsys): | ||||||
| """Tests whether test_track_variables.py produces expected output from sample suite and | ||||||
| metadata files for a case with a successful match (user provided a variable that exists | ||||||
| within the schemes specified by the test suite)""" | ||||||
| expected_output = """For suite test_track_variables/suite_small_suite.xml, the following schemes (in order for each group) use the variable air_pressure: | ||||||
| In group group1 | ||||||
| scheme_1_run (intent in) | ||||||
|
|
@@ -43,6 +47,11 @@ def test_successful_match(capsys): | |||||
| i+=1 | ||||||
|
|
||||||
| def test_successful_match_with_subcycles(capsys): | ||||||
| """Tests whether test_track_variables.py produces expected output from sample suite and | ||||||
| metadata files for a case with a successful match(user provided a variable that exists | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| within the schemes specified by the test suite). In this case, the test suite file | ||||||
| contains subcycles, so the output should reflect this.""" | ||||||
|
|
||||||
| expected_output = """For suite test_track_variables/suite_TEST_SUITE.xml, the following schemes (in order for each group) use the variable surface_air_pressure: | ||||||
| In group group1 | ||||||
| scheme_3_run (intent inout) | ||||||
|
|
@@ -69,6 +78,11 @@ def test_successful_match_with_subcycles(capsys): | |||||
|
|
||||||
|
|
||||||
| def test_partial_match(capsys): | ||||||
| """Tests whether test_track_variables.py produces expected output from sample suite and | ||||||
| metadata files for a case with a partial match: user provided a variable that does not | ||||||
| exist in the test suite, but is a substring of one or more other variables that do | ||||||
| exist.""" | ||||||
|
|
||||||
| expected_output = """Variable surface not found in any suites for sdf test_track_variables/suite_TEST_SUITE.xml | ||||||
|
|
||||||
| ERROR:ccpp_track_variables:Variable surface not found in any suites for sdf test_track_variables/suite_TEST_SUITE.xml | ||||||
|
|
@@ -96,6 +110,10 @@ def test_partial_match(capsys): | |||||
|
|
||||||
|
|
||||||
| def test_no_match(capsys): | ||||||
| """Tests whether test_track_variables.py produces expected output from sample suite and | ||||||
| metadata files for a case with no match (user provided a variable that does not exist | ||||||
| within the schemes specified by the test suite)""" | ||||||
|
|
||||||
| expected_output = """Variable abc not found in any suites for sdf test_track_variables/suite_TEST_SUITE.xml | ||||||
|
|
||||||
| ERROR:ccpp_track_variables:Variable abc not found in any suites for sdf test_track_variables/suite_TEST_SUITE.xml""" | ||||||
|
|
@@ -111,12 +129,14 @@ def test_no_match(capsys): | |||||
|
|
||||||
|
|
||||||
| def test_bad_config(capsys): | ||||||
| """Tests whether test_track_variables.py fails gracefully when provided a config file that does | ||||||
| not exist.""" | ||||||
| with pytest.raises(Exception) as excinfo: | ||||||
| track_variables(SUITE_FILE,SAMPLE_FILES_DIR,f'{SAMPLE_FILES_DIR}/nofile','abc',False) | ||||||
| assert str(excinfo.value) == "Call to import_config failed." | ||||||
|
|
||||||
|
|
||||||
| if __name__ == "__main__": | ||||||
| print("This test file is designed to be run with pytest; can not be run directly") | ||||||
|
|
||||||
| sys.exit(1) | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A doc string explaining the purpose of the test (what is being tested, test limits, etc.) would be helpful here and for all the test functions below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed