test-suite: update Travis consistency checks: (1) ensure PROJ_DELIM
is not defined (it should come from macros file) and add checks to
verify certain key elements are included in .spec file (URL and proper
Group designation).
-#!/usr/bin/python3
+#!/usr/bin/env python3
# this script needs at least python 3.5 for
# subprocess.run()
@@ -20,6 +20,15 @@ regex_wrong = [
'^BuildRoot.*',
# make sure there is no %defattr(-,root,root)
'^%defattr\(-,root,root\).*',
+ # make sure there is no global definition of PROJ_DELIM
+ '^.*%global.*PROJ_DELIM.*$',
+ ]
+
+regex_required = [
+ # Group designation should include %{PROJ_NAME} delimiter and known component area
+ '^Group:.*%{PROJ_NAME}/(admin|compiler-families|dev-tools|distro-packages|io-libs|lustre|mpi-families|parallel-libs|perf-tols|provisioning|rms|runtimes|serial-libs)$',
+ # Need a URL
+ '^URL:.*$',
]
if len(sys.argv) != 2:
@@ -41,25 +50,38 @@ pattern = re.compile(regex_wrong_string)
if result.returncode != 0:
sys.exit(1)
-found = False
+error = False
spec_found = False
for spec in result.stdout.decode('utf-8').split('\n'):
if not spec.endswith('.spec'):
continue
spec_found = True
- with open(spec) as infile:
- for line in infile:
+ print("\n--> Scanning spec file %s" % spec)
+
+ # cache spec file contents
+ infile = open(spec)
+ contents = infile.read()
+ infile.close()
+
+ # first, verify patterns which should *not* be present
+ for line in contents.split('\n'):
if pattern.match(line):
- print("Found %s in %s" % (line.rstrip(), spec))
- found = True
+ print(" [+] Found %s" % (line.rstrip()))
+ error = True
+
+ # next, verify items which should be present
+ for requirement in regex_required:
+ if not re.findall(requirement,contents,re.MULTILINE):
+ print(" [-] Missing %s" % requirement)
+ error = True
if not spec_found:
- print("SKIP. Commit without changes to a SPEC file.")
+ print("\nSKIP. Commit without changes to a SPEC file.")
-if found:
- print("ERROR:Found an error in one of the SPEC files.")
+if error:
+ print("\nERROR: Found an inconsistency in one or more SPEC files.")
sys.exit(1)
-print("No errors found. Exiting.")
+print("\nNo consistency errors found. Exiting.")
sys.exit(0)
