mirror of https://github.com/fail2ban/fail2ban
Merge pull request #879 from sebres/broken-test-setup_install_root
testSetupInstallRoot will be always skipped, ...pull/887/head
commit
fb2b52af14
|
@ -55,6 +55,35 @@ class HelpersTest(unittest.TestCase):
|
||||||
# might be fragile due to ' vs "
|
# might be fragile due to ' vs "
|
||||||
self.assertEqual(args, "('Very bad', None)")
|
self.assertEqual(args, "('Very bad', None)")
|
||||||
|
|
||||||
|
class SetupTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
setup = os.path.join(os.path.dirname(__file__), '..', '..', 'setup.py')
|
||||||
|
self.setup = os.path.exists(setup) and setup or None
|
||||||
|
if not self.setup and sys.version_info >= (2,7): # pragma: no cover - running not out of the source
|
||||||
|
raise unittest.SkipTest(
|
||||||
|
"Seems to be running not out of source distribution"
|
||||||
|
" -- cannot locate setup.py")
|
||||||
|
|
||||||
|
def testSetupInstallRoot(self):
|
||||||
|
if not self.setup: return # if verbose skip didn't work out
|
||||||
|
tmp = tempfile.mkdtemp()
|
||||||
|
try:
|
||||||
|
os.system("%s %s install --root=%s >/dev/null"
|
||||||
|
% (sys.executable, self.setup, tmp))
|
||||||
|
|
||||||
|
def strippath(l):
|
||||||
|
return [x[len(tmp)+1:] for x in l]
|
||||||
|
|
||||||
|
got = strippath(sorted(glob('%s/*' % tmp)))
|
||||||
|
need = ['etc', 'usr', 'var']
|
||||||
|
|
||||||
|
# if anything is missing
|
||||||
|
if set(need).difference(got): # pragma: no cover
|
||||||
|
# below code was actually to print out not missing but
|
||||||
|
# rather files in 'excess'. Left in place in case we
|
||||||
|
# decide to revert to such more strict test
|
||||||
|
|
||||||
# based on
|
# based on
|
||||||
# http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python
|
# http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python
|
||||||
def recursive_glob(treeroot, pattern):
|
def recursive_glob(treeroot, pattern):
|
||||||
|
@ -64,36 +93,6 @@ def recursive_glob(treeroot, pattern):
|
||||||
results.extend(os.path.join(base, f) for f in goodfiles)
|
results.extend(os.path.join(base, f) for f in goodfiles)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
class SetupTest(unittest.TestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
setup = os.path.join(os.path.dirname(__file__), '..', 'setup.py')
|
|
||||||
self.setup = os.path.exists(setup) and setup or None
|
|
||||||
if not self.setup and sys.version_info >= (2,7): # running not out of the source
|
|
||||||
raise unittest.SkipTest(
|
|
||||||
"Seems to be running not out of source distribution"
|
|
||||||
" -- cannot locate setup.py")
|
|
||||||
|
|
||||||
def testSetupInstallRoot(self):
|
|
||||||
if not self.setup: return # if verbose skip didn't work out
|
|
||||||
tmp = tempfile.mkdtemp()
|
|
||||||
os.system("%s %s install --root=%s >/dev/null"
|
|
||||||
% (sys.executable, self.setup, tmp))
|
|
||||||
|
|
||||||
def addpath(l):
|
|
||||||
return [os.path.join(tmp, x) for x in l]
|
|
||||||
|
|
||||||
def strippath(l):
|
|
||||||
return [x[len(tmp)+1:] for x in l]
|
|
||||||
|
|
||||||
got = strippath(sorted(glob('%s/*' % tmp)))
|
|
||||||
need = ['etc', 'usr', 'var']
|
|
||||||
|
|
||||||
# if anything is missing
|
|
||||||
if set(need).difference(got):
|
|
||||||
# below code was actually to print out not missing but
|
|
||||||
# rather files in 'excess'. Left in place in case we
|
|
||||||
# decide to revert to such more strict test
|
|
||||||
files = {}
|
files = {}
|
||||||
for missing in set(got).difference(need):
|
for missing in set(got).difference(need):
|
||||||
missing_full = os.path.join(tmp, missing)
|
missing_full = os.path.join(tmp, missing)
|
||||||
|
@ -110,9 +109,12 @@ class SetupTest(unittest.TestCase):
|
||||||
'etc/fail2ban/jail.conf'):
|
'etc/fail2ban/jail.conf'):
|
||||||
self.assertTrue(os.path.exists(os.path.join(tmp, f)),
|
self.assertTrue(os.path.exists(os.path.join(tmp, f)),
|
||||||
msg="Can't find %s" % f)
|
msg="Can't find %s" % f)
|
||||||
|
finally:
|
||||||
# clean up
|
# clean up
|
||||||
shutil.rmtree(tmp)
|
shutil.rmtree(tmp)
|
||||||
|
# remove build directory
|
||||||
|
os.system("%s %s clean --all >/dev/null"
|
||||||
|
% (sys.executable, self.setup))
|
||||||
|
|
||||||
class TestsUtilsTest(unittest.TestCase):
|
class TestsUtilsTest(unittest.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue