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
_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):
'''
Execute salt

View File

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

View File

@ -159,7 +159,7 @@ class CopyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
self.assertEqual(ret[2], 2)
finally:
if old_cwd is not None:
os.chdir(old_cwd)
self.chdir(old_cwd)
if os.path.isdir(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.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
finally:
os.chdir(old_cwd)
self.chdir(old_cwd)
if os.path.isdir(config_dir):
shutil.rmtree(config_dir)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,13 +14,13 @@ import time
# Import salt libs
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
from salttesting.parser import PNUM, print_header
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(
'SALT_XML_TEST_REPORTS_DIR',
os.path.join(TMP, 'xml-test-reports')
@ -30,7 +30,7 @@ HTML_OUTPUT_DIR = os.environ.get(
os.path.join(TMP, 'html-test-reports')
)
TEST_DIR = os.path.dirname(INTEGRATION_TEST_DIR)
try:
if SALT_ROOT:
os.chdir(SALT_ROOT)