Merge pull request #47348 from dwoz/no_symlinks

Ignore gitfs tests when symlinks not enabled
This commit is contained in:
Daniel Wallace 2018-04-27 08:08:27 -05:00 committed by GitHub
commit 1667375a80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 28 deletions

View file

@ -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

View file

@ -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):

View file

@ -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: