Try to overcome a failure to get cwd in Cent tests

This commit is contained in:
Pedro Algarvio 2015-07-28 12:07:04 +01:00
parent d649252878
commit e7681f7c75
10 changed files with 17 additions and 11 deletions

View File

@ -1200,6 +1200,12 @@ class ShellCase(AdaptedConfigurationTestCaseMixIn, ShellTestCase):
_script_dir_ = SCRIPT_DIR _script_dir_ = SCRIPT_DIR
_python_executable_ = PYEXEC _python_executable_ = PYEXEC
def chdir(self, dirname):
try:
os.chdir(dirname)
except OSError:
os.chdir(INTEGRATION_TEST_DIR)
def run_salt(self, arg_str, with_retcode=False, catch_stderr=False): def run_salt(self, arg_str, with_retcode=False, catch_stderr=False):
''' '''
Execute salt Execute salt

View File

@ -297,7 +297,7 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
) )
self.assertEqual(ret[2], 2) self.assertEqual(ret[2], 2)
finally: finally:
os.chdir(old_cwd) self.chdir(old_cwd)
if os.path.isdir(config_dir): if os.path.isdir(config_dir):
shutil.rmtree(config_dir) shutil.rmtree(config_dir)

View File

@ -159,7 +159,7 @@ class CopyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
self.assertEqual(ret[2], 2) self.assertEqual(ret[2], 2)
finally: finally:
if old_cwd is not None: if old_cwd is not None:
os.chdir(old_cwd) self.chdir(old_cwd)
if os.path.isdir(config_dir): if os.path.isdir(config_dir):
shutil.rmtree(config_dir) shutil.rmtree(config_dir)

View File

@ -254,7 +254,7 @@ class KeyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
self.assertIn('minion', '\n'.join(ret)) self.assertIn('minion', '\n'.join(ret))
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:'))) self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
finally: finally:
os.chdir(old_cwd) self.chdir(old_cwd)
if os.path.isdir(config_dir): if os.path.isdir(config_dir):
shutil.rmtree(config_dir) shutil.rmtree(config_dir)

View File

@ -74,7 +74,7 @@ class MasterTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
) )
self.assertEqual(ret[2], 2) self.assertEqual(ret[2], 2)
finally: finally:
os.chdir(old_cwd) self.chdir(old_cwd)
if os.path.isdir(config_dir): if os.path.isdir(config_dir):
shutil.rmtree(config_dir) shutil.rmtree(config_dir)

View File

@ -345,7 +345,7 @@ class MatchTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
) )
self.assertEqual(ret[2], 2) self.assertEqual(ret[2], 2)
finally: finally:
os.chdir(old_cwd) self.chdir(old_cwd)
if os.path.isdir(config_dir): if os.path.isdir(config_dir):
shutil.rmtree(config_dir) shutil.rmtree(config_dir)

View File

@ -71,7 +71,7 @@ class MinionTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
) )
self.assertEqual(ret[2], 2) self.assertEqual(ret[2], 2)
finally: finally:
os.chdir(old_cwd) self.chdir(old_cwd)
if os.path.isdir(config_dir): if os.path.isdir(config_dir):
shutil.rmtree(config_dir) shutil.rmtree(config_dir)

View File

@ -94,7 +94,7 @@ class RunTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
) )
self.assertEqual(ret[2], 2) self.assertEqual(ret[2], 2)
finally: finally:
os.chdir(old_cwd) self.chdir(old_cwd)
if os.path.isdir(config_dir): if os.path.isdir(config_dir):
shutil.rmtree(config_dir) shutil.rmtree(config_dir)

View File

@ -75,7 +75,7 @@ class SyndicTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
) )
self.assertEqual(ret[2], 2) self.assertEqual(ret[2], 2)
finally: finally:
os.chdir(old_cwd) self.chdir(old_cwd)
if os.path.isdir(config_dir): if os.path.isdir(config_dir):
shutil.rmtree(config_dir) shutil.rmtree(config_dir)

View File

@ -14,13 +14,13 @@ import time
# Import salt libs # Import salt libs
from integration import TestDaemon, TMP # pylint: disable=W0403 from integration import TestDaemon, TMP # pylint: disable=W0403
from integration import INTEGRATION_TEST_DIR
from integration import CODE_DIR as SALT_ROOT
# Import Salt Testing libs # Import Salt Testing libs
from salttesting.parser import PNUM, print_header from salttesting.parser import PNUM, print_header
from salttesting.parser.cover import SaltCoverageTestingParser from salttesting.parser.cover import SaltCoverageTestingParser
TEST_DIR = os.path.dirname(os.path.normpath(os.path.abspath(__file__)))
SALT_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
XML_OUTPUT_DIR = os.environ.get( XML_OUTPUT_DIR = os.environ.get(
'SALT_XML_TEST_REPORTS_DIR', 'SALT_XML_TEST_REPORTS_DIR',
os.path.join(TMP, 'xml-test-reports') os.path.join(TMP, 'xml-test-reports')
@ -30,7 +30,7 @@ HTML_OUTPUT_DIR = os.environ.get(
os.path.join(TMP, 'html-test-reports') os.path.join(TMP, 'html-test-reports')
) )
TEST_DIR = os.path.dirname(INTEGRATION_TEST_DIR)
try: try:
if SALT_ROOT: if SALT_ROOT:
os.chdir(SALT_ROOT) os.chdir(SALT_ROOT)