mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Try to overcome a failure to get cwd in Cent tests
This commit is contained in:
parent
d649252878
commit
e7681f7c75
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user