summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick McLean <chutzpah@gentoo.org>2015-11-19 18:15:50 -0800
committerPatrick McLean <chutzpah@gentoo.org>2015-11-19 18:15:50 -0800
commit87fb830be92a8af777ecd9cf27c95979281ddef2 (patch)
tree6fed9151bfd8ec9317182620b79658ef8081da0e /app-admin/salt
parentdev-python/PyQt5: version bump (diff)
downloadgentoo-87fb830be92a8af777ecd9cf27c95979281ddef2.tar.gz
gentoo-87fb830be92a8af777ecd9cf27c95979281ddef2.tar.bz2
gentoo-87fb830be92a8af777ecd9cf27c95979281ddef2.zip
app-admin/salt: fix unit tests with sandbox with 2015.8.2
Package-Manager: portage-2.2.25
Diffstat (limited to 'app-admin/salt')
-rw-r--r--app-admin/salt/files/salt-2015.8.2-tmpdir.patch56
-rw-r--r--app-admin/salt/salt-2015.8.2.ebuild22
2 files changed, 74 insertions, 4 deletions
diff --git a/app-admin/salt/files/salt-2015.8.2-tmpdir.patch b/app-admin/salt/files/salt-2015.8.2-tmpdir.patch
new file mode 100644
index 000000000000..871551e0e508
--- /dev/null
+++ b/app-admin/salt/files/salt-2015.8.2-tmpdir.patch
@@ -0,0 +1,56 @@
+diff --git a/tests/unit/modules/qemu_nbd_test.py b/tests/unit/modules/qemu_nbd_test.py
+index 615e6b5..fbd24aa 100644
+--- a/tests/unit/modules/qemu_nbd_test.py
++++ b/tests/unit/modules/qemu_nbd_test.py
+@@ -77,6 +77,7 @@ class QemuNbdTestCase(TestCase):
+ Test if it mount the named image via qemu-nbd
+ and return the mounted roots
+ '''
++ tmpdir = os.environ.get('TMPDIR', '/tmp')
+ mock = MagicMock(return_value=True)
+ with patch.dict(qemu_nbd.__salt__, {'cmd.run': mock}):
+ self.assertEqual(qemu_nbd.init('/srv/image.qcow2'), '')
+@@ -89,7 +90,7 @@ class QemuNbdTestCase(TestCase):
+ 'mount.mount': mock,
+ 'cmd.retcode': MagicMock(side_effect=[1, 0])}):
+ self.assertDictEqual(qemu_nbd.init('/srv/image.qcow2'),
+- {'/tmp/nbd/nbd0/nbd0': '/dev/nbd0'})
++ {os.path.join(tmpdir, 'nbd/nbd0/nbd0'): '/dev/nbd0'})
+
+ # 'clear' function tests: 1
+
+diff --git a/tests/unit/states/archive_test.py b/tests/unit/states/archive_test.py
+index 63e4a53..20b196f 100644
+--- a/tests/unit/states/archive_test.py
++++ b/tests/unit/states/archive_test.py
+@@ -26,7 +26,7 @@ from salt.ext.six.moves import zip # pylint: disable=import-error,redefined-bui
+
+ # Globals
+ archive.__salt__ = {}
+-archive.__opts__ = {"cachedir": "/tmp", "test": False}
++archive.__opts__ = {"cachedir": os.environ.get('TMPDIR', "/tmp"), "test": False}
+ archive.__env__ = 'test'
+
+
+@@ -75,7 +75,7 @@ class ArchiveTestCase(TestCase):
+ 'cmd.run_all': mock_run}):
+ filename = os.path.join(
+ tmp_dir,
+- 'files/test/_tmp_test_archive_.tar'
++ 'files/test/' + tempfile.gettempdir().replace('/', '_') + '_test_archive_.tar'
+ )
+ for test_opts, ret_opts in zip(test_tar_opts, ret_tar_opts):
+ ret = archive.extracted(tmp_dir,
+diff --git a/tests/unit/utils/context_test.py b/tests/unit/utils/context_test.py
+index 71e4330..d6f3f30 100644
+--- a/tests/unit/utils/context_test.py
++++ b/tests/unit/utils/context_test.py
+@@ -18,7 +18,7 @@ import salt.payload
+ import salt.utils
+
+ __context__ = {'a': 'b'}
+-__opts__ = {'cachedir': '/tmp'}
++__opts__ = {'cachedir': os.environ.get('TMPDIR', '/tmp')}
+
+
+ @skipIf(NO_MOCK, NO_MOCK_REASON)
diff --git a/app-admin/salt/salt-2015.8.2.ebuild b/app-admin/salt/salt-2015.8.2.ebuild
index 5a9a9886178b..64fd02a2307a 100644
--- a/app-admin/salt/salt-2015.8.2.ebuild
+++ b/app-admin/salt/salt-2015.8.2.ebuild
@@ -87,6 +87,7 @@ PATCHES=(
"${FILESDIR}/${PN}-2015.5.5-auth-tests.patch"
"${FILESDIR}/${PN}-2015.5.5-cron-tests.patch"
"${FILESDIR}/${PN}-2015.5.5-remove-buggy-tests.patch"
+ "${FILESDIR}/${PN}-2015.8.2-tmpdir.patch"
)
python_prepare() {
@@ -110,11 +111,24 @@ python_install_all() {
}
python_test() {
+ local tempdir
# testsuite likes lots of files
ulimit -n 3072
- # using ${T} for the TMPDIR makes some tests needs paths that exceed PATH_MAX
- USE_SETUPTOOLS=1 SHELL="/bin/bash" TMPDIR="/tmp" \
- ${EPYTHON} tests/runtests.py \
- --unit-tests --no-report --verbose || die "testing failed"
+ # ${T} is too long a path for the tests to work
+ tempdir="$(mktemp -dup /tmp salt-XXX)"
+ mkdir "${T}/$(basename "${tempdir}")"
+
+ (
+ cleanup() { rm -f "${tempdir}"; }
+ trap cleanup EXIT
+
+ addwrite "${tempdir}"
+ ln -s "$(realpath --relative-to=/tmp "${T}/$(basename "${tempdir}")")" "${tempdir}"
+
+ USE_SETUPTOOLS=1 SHELL="/bin/bash" TMPDIR="${tempdir}" \
+ ${EPYTHON} tests/runtests.py \
+ --unit-tests --no-report --verbose
+
+ ) || die "testing failed"
}