Skip to content
Open
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
40 changes: 40 additions & 0 deletions build/4473.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import xml.etree.ElementTree as ET
import sys

fail=False
filetype=".tests"

pathsxml = r"C:\Instrument\dev\ibex_gui\base\uk.ac.stfc.isis.ibex.client.tycho.parent\pom.xml"
pathsfolder = r"C:\Instrument\dev\ibex_gui\base"

folderFiles = os.listdir(pathsfolder)
testFiles = []
for file in folderFiles:
if file[-(len(filetype)):] == filetype:
testFiles.append(file)

tree = ET.parse(pathsxml)
root = tree.getroot()
xmlmodules=[]
for module in root.iter("{http://maven.apache.org/POM/4.0.0}module"):
xmlmodules.append(module.text)

xmlmodulenames = []
for name in xmlmodules:
if name[-(len(filetype)):] == filetype:
xmlmodulenames.append(name[3:])

missingtests=[]
for testfile in testFiles:
if testfile not in xmlmodulenames:
fail = True
missingtests.append(testfile)

if fail == True:
print(f".test files in base/ not found in pom.xml")
print(f"Missing files: {missingtests}")
print(f"To fix this: add missing files to the list in client.tycho.parent/pom.xml")
sys.exit(1)
else:
sys.exit(0)
3 changes: 3 additions & 0 deletions build/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ if %errorlevel% neq 0 exit /b %errorlevel%
%PYTHON3% .\check_build.py ..\base\
if %errorlevel% neq 0 exit /b %errorlevel%

%PYTHON3% .\check_tests.py ..\base\
if %errorlevel% neq 0 exit /b %errorlevel%

if "%BUILD_NUMBER%" == "" SET BUILD_NUMBER=SNAPSHOT

set mvnErr=
Expand Down
51 changes: 51 additions & 0 deletions build/check_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import os
import xml.etree.ElementTree as ET
import sys

SUCCESS = 0
INCORRECT_ARGS = 1
TESTS_NOT_IN_POM = 2
fileType=".tests"

def check_tests_in_pom(build_root_path):
pathsxml = build_root_path + r"uk.ac.stfc.isis.ibex.client.tycho.parent\pom.xml"

folderFiles = os.listdir(build_root_path)
testFiles = [name for name in folderFiles if name.endswith(fileType)]

tree = ET.parse(pathsxml)
root = tree.getroot()
xmlmodulenames = []
for module in root.iter():
if module.tag.endswith("module"):
name = module.text[3:]
if name.endswith(fileType):
xmlmodulenames.append(name)
missingtests = [file for file in testFiles if file not in xmlmodulenames]

if missingtests:
print(f".test files in base/ not found in pom.xml")
print(f"Missing files: {missingtests}")
print(f"To fix this: add missing files to the list in client.tycho.parent/pom.xml")
return False
else:
return True

def main(build_root_path):
try:
os.chdir(build_root_path)
except Exception as e:
return INCORRECT_ARGS
if not check_tests_in_pom(build_root_path):
return TESTS_NOT_IN_POM
print("check_tests: all test modules in pom.xml")
return SUCCESS

if __name__ == '__main__':
success = SUCCESS
if len(sys.argv) != 2:
print("Incorrect arguments, expected path to build base directory")
success = INCORRECT_ARGS
else:
success = main(sys.argv[1])
sys.exit(success)