Remove the customized test-requirements script
The gate-test-requirements job is doing the same thing. We cannot use revert since it is breaking the gate-test-requiremnts job. Change-Id: Ie5f4304b0cb59fda9bcc87df518e4c2ad9915b60
This commit is contained in:
parent
8149d1714d
commit
a2f1d9cc96
|
@ -1,19 +0,0 @@
|
||||||
========================
|
|
||||||
Tools for tacker
|
|
||||||
========================
|
|
||||||
|
|
||||||
sync_test_requirements.py
|
|
||||||
========================
|
|
||||||
|
|
||||||
Sync the test-requirements.txt with openstack global requirements.
|
|
||||||
Assume requirements prject is cloned at /opt/stack/requirements, to run::
|
|
||||||
|
|
||||||
$ git clone https://git.openstack.org/openstack/requirements.git /opt/stack/requirements
|
|
||||||
$ ./sync_test_requirements.py -g /opt/stack/requirements/global-requirements.txt -t ../test-requirements.txt -o ../test-requirements.txt
|
|
||||||
|
|
||||||
If this tool shows us the "../test-requirements.txt" is changed,
|
|
||||||
please commit it.
|
|
||||||
|
|
||||||
This tool is also used in tox.ini to check if the test-requirements.txt is
|
|
||||||
synchroized with global-requirements.txt. please refer to tox.ini for the
|
|
||||||
usage.
|
|
|
@ -1,90 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
import getopt
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
import tempfile
|
|
||||||
|
|
||||||
|
|
||||||
def printusage():
|
|
||||||
print('sync_test_requirements.py -g <globalrequirements>'
|
|
||||||
' -t <testrequirements>'
|
|
||||||
' [-o <outputfile>]')
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
globareqfile = ''
|
|
||||||
testreqfile = ''
|
|
||||||
outputfile = ''
|
|
||||||
check = False
|
|
||||||
try:
|
|
||||||
opts, args = getopt.getopt(
|
|
||||||
argv,"hg:t:o:",
|
|
||||||
["globalrequirements=", "testrequirements=", "outputfile="])
|
|
||||||
except getopt.GetoptError:
|
|
||||||
printusage()
|
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
for opt, arg in opts:
|
|
||||||
if opt == '-h':
|
|
||||||
printusage()
|
|
||||||
sys.exit()
|
|
||||||
elif opt in ("-g", "--globalrequirements"):
|
|
||||||
globareqfile = arg
|
|
||||||
elif opt in ("-o", "--outputfile"):
|
|
||||||
outputfile = arg
|
|
||||||
elif opt in ("-t", "--testrequirements"):
|
|
||||||
testreqfile = arg
|
|
||||||
if not outputfile:
|
|
||||||
with tempfile.NamedTemporaryFile(delete=False) as tempf:
|
|
||||||
outputfile = tempf.name
|
|
||||||
check = True
|
|
||||||
if not (globareqfile and testreqfile and (outputfile or check)):
|
|
||||||
printusage()
|
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
lines = []
|
|
||||||
gmodules = {}
|
|
||||||
changed = 0
|
|
||||||
with open(testreqfile) as testfile:
|
|
||||||
lines = testfile.readlines()
|
|
||||||
with open(globareqfile) as globalfile:
|
|
||||||
globallines = globalfile.readlines()
|
|
||||||
for gline in globallines:
|
|
||||||
gline = gline.rstrip('\n')
|
|
||||||
gmodulename = re.split('[<>=]', gline)[0]
|
|
||||||
moduleparts = gline.split("#")
|
|
||||||
modulepart = moduleparts[0].rstrip(" ")
|
|
||||||
modulelicense = ("" if len(moduleparts) <= 1 else
|
|
||||||
moduleparts[1].strip(" "))
|
|
||||||
gmodules[gmodulename] =(modulepart, modulelicense)
|
|
||||||
with open(outputfile, 'w') as ofile:
|
|
||||||
for line in lines:
|
|
||||||
if line.startswith('#'):
|
|
||||||
ofile.write(line)
|
|
||||||
continue
|
|
||||||
line = line.rstrip('\n')
|
|
||||||
modulename = re.split('[<>=]', line)[0]
|
|
||||||
moduleparts = line.split("#")
|
|
||||||
modulepart = moduleparts[0].rstrip(" ")
|
|
||||||
modulelicense = ("" if len(moduleparts) <= 1 else
|
|
||||||
moduleparts[1].strip(" "))
|
|
||||||
if (gmodules.get(modulename) and
|
|
||||||
(modulepart, modulelicense) != gmodules.get(modulename)):
|
|
||||||
changed = 1
|
|
||||||
if gmodules.get(modulename)[1]:
|
|
||||||
ofile.write(" # ".join(gmodules.get(modulename)) + "\n")
|
|
||||||
else:
|
|
||||||
ofile.write(gmodules.get(modulename)[0] + "\n")
|
|
||||||
else:
|
|
||||||
ofile.write(line + "\n")
|
|
||||||
if changed:
|
|
||||||
if check:
|
|
||||||
print("%s is not synchronized with global requirements." %
|
|
||||||
testreqfile)
|
|
||||||
else:
|
|
||||||
print(testreqfile + " is changed.\n")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main(sys.argv[1:])
|
|
1
tox.ini
1
tox.ini
|
@ -26,7 +26,6 @@ setenv = {[testenv]setenv}
|
||||||
deps =
|
deps =
|
||||||
{[testenv:functional]deps}
|
{[testenv:functional]deps}
|
||||||
commands =
|
commands =
|
||||||
{toxinidir}/tools/sync_test_requirements.py -g {toxinidir}/../requirements/global-requirements.txt -t {toxinidir}/test-requirements.txt )
|
|
||||||
{toxinidir}/tools/ostestr_compat_shim.sh --concurrency 2 {posargs}
|
{toxinidir}/tools/ostestr_compat_shim.sh --concurrency 2 {posargs}
|
||||||
|
|
||||||
[tox:jenkins]
|
[tox:jenkins]
|
||||||
|
|
Loading…
Reference in New Issue