Repository navigation
Add check for missing test modules in pom.xml- #1864 #1887
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9f073b8
Add check for missing test modules in pom.xml
AmyW-RAL d474597
Merge branch 'master' into Ticket4483tests
jackbdoughty e9f7576
Merge branch 'master' of https://github.com/ISISComputingGroup/ibex_g…
jackbdoughty 6c73cac
make ruff/pyright happy
jackbdoughty 8131bd8
consistent variable name scheme
jackbdoughty a750c27
Update build/check_tests.py
jackbdoughty 2b76c40
Update build/check_tests.py
jackbdoughty a94b54e
Update build/check_tests.py
jackbdoughty f632659
Update build/check_tests.py
jackbdoughty 304d0f0
Update build/check_tests.py
jackbdoughty 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
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 |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import os | ||
| import sys | ||
| import xml.etree.ElementTree as ET | ||
|
|
||
| # Error level returned by script | ||
| SUCCESS = 0 | ||
| INCORRECT_ARGS = 1 | ||
| TESTS_NOT_IN_POM = 2 | ||
| FILE_TYPE = ".tests" | ||
|
|
||
|
|
||
| def check_tests_in_pom(ibex_gui_base): | ||
| pathsxml = ibex_gui_base + r"uk.ac.stfc.isis.ibex.client.tycho.parent\pom.xml" | ||
|
|
||
| folderfiles = os.listdir(ibex_gui_base) | ||
| testfiles = [name for name in folderfiles if name.endswith(FILE_TYPE)] | ||
|
|
||
| tree = ET.parse(pathsxml) | ||
| root = tree.getroot() | ||
| xmlmodulenames = [] | ||
| for module in root.iter(): | ||
| if module.tag.endswith("module"): | ||
| wholename = module.text | ||
|
|
||
| if wholename: | ||
| name = wholename[3:] | ||
| else: | ||
| name = "" | ||
|
|
||
| if name.endswith(FILE_TYPE): | ||
| xmlmodulenames.append(name) | ||
| missingtests = [file for file in testfiles if file not in xmlmodulenames] | ||
|
|
||
| if missingtests: | ||
| print(".test files in base/ not found in pom.xml") | ||
| print(f"Missing files: {missingtests}") | ||
| print("To fix this: add missing files to the list in client.tycho.parent/pom.xml") | ||
| return False | ||
| else: | ||
| return True | ||
|
|
||
|
|
||
| def main(ibex_gui_base): | ||
| try: | ||
| os.chdir(ibex_gui_base) | ||
| except (FileNotFoundError, NotADirectoryError, PermissionError): | ||
| return INCORRECT_ARGS | ||
| if not check_tests_in_pom(ibex_gui_base): | ||
| return TESTS_NOT_IN_POM | ||
| print("check_tests: all test modules in pom.xml") | ||
| return SUCCESS | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| result = SUCCESS | ||
| if len(sys.argv) != 2: | ||
| print("Incorrect arguments, expected path to build base directory") | ||
| result = INCORRECT_ARGS | ||
| else: | ||
| result = main(sys.argv[1]) | ||
| sys.exit(result) | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.