mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Ignore gitfs tests when symlinks not enabled
This commit is contained in:
parent
dac04261b5
commit
94a70e847a
3 changed files with 30 additions and 28 deletions
|
@ -21,6 +21,7 @@ import logging
|
|||
import os
|
||||
import signal
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
|
@ -54,6 +55,31 @@ from tests.support.paths import FILES, TMP
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
HAS_SYMLINKS = None
|
||||
|
||||
|
||||
def no_symlinks():
|
||||
'''
|
||||
Check if git is installed and has symlinks enabled in the configuration.
|
||||
'''
|
||||
global HAS_SYMLINKS
|
||||
if HAS_SYMLINKS is not None:
|
||||
return not HAS_SYMLINKS
|
||||
output = ''
|
||||
try:
|
||||
output = subprocess.check_output('git config --get core.symlinks', shell=True)
|
||||
except OSError as exc:
|
||||
if exc.errno != errno.ENOENT:
|
||||
raise
|
||||
except subprocess.CalledProcessError:
|
||||
# git returned non-zero status
|
||||
pass
|
||||
HAS_SYMLINKS = False
|
||||
if output.strip() == 'true':
|
||||
HAS_SYMLINKS = True
|
||||
return not HAS_SYMLINKS
|
||||
|
||||
|
||||
def destructiveTest(caller):
|
||||
'''
|
||||
Mark a test case as a destructive test for example adding or removing users
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import errno
|
||||
import subprocess
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.helpers import no_symlinks
|
||||
from tests.support.mock import (
|
||||
MagicMock,
|
||||
patch,
|
||||
|
@ -35,31 +34,6 @@ from tests.support.mock import (
|
|||
from salt.modules.inspectlib.collector import Inspector
|
||||
|
||||
|
||||
HAS_SYMLINKS = None
|
||||
|
||||
|
||||
def no_symlinks():
|
||||
'''
|
||||
Check if git is installed and has symlinks enabled in the configuration.
|
||||
'''
|
||||
global HAS_SYMLINKS
|
||||
if HAS_SYMLINKS is not None:
|
||||
return not HAS_SYMLINKS
|
||||
output = ''
|
||||
try:
|
||||
output = subprocess.check_output('git config --get core.symlinks', shell=True)
|
||||
except OSError as exc:
|
||||
if exc.errno != errno.ENOENT:
|
||||
raise
|
||||
except subprocess.CalledProcessError:
|
||||
# git returned non-zero status
|
||||
pass
|
||||
HAS_SYMLINKS = False
|
||||
if output.strip() == 'true':
|
||||
HAS_SYMLINKS = True
|
||||
return not HAS_SYMLINKS
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
@skipIf(no_symlinks(), "Git missing 'core.symlinks=true' config")
|
||||
class InspectorCollectorTestCase(TestCase):
|
||||
|
|
|
@ -8,8 +8,9 @@ from shutil import rmtree
|
|||
from tempfile import mkdtemp
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.unit import TestCase
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.paths import TMP
|
||||
from tests.support.helpers import no_symlinks
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
@ -18,6 +19,7 @@ import salt.utils.find
|
|||
|
||||
class TestUtils(TestCase):
|
||||
|
||||
@skipIf(no_symlinks(), "Git missing 'core.symlinks=true' config")
|
||||
def test_safe_walk_symlink_recursion(self):
|
||||
tmp = mkdtemp(dir=TMP)
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue