public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Patrick McLean" <chutzpah@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: app-admin/salt/, app-admin/salt/files/
Date: Fri, 20 Nov 2015 02:16:14 +0000 (UTC)	[thread overview]
Message-ID: <1447985750.87fb830be92a8af777ecd9cf27c95979281ddef2.chutzpah@gentoo> (raw)

commit:     87fb830be92a8af777ecd9cf27c95979281ddef2
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 20 02:15:50 2015 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Fri Nov 20 02:15:50 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=87fb830b

app-admin/salt: fix unit tests with sandbox with 2015.8.2

Package-Manager: portage-2.2.25

 app-admin/salt/files/salt-2015.8.2-tmpdir.patch | 56 +++++++++++++++++++++++++
 app-admin/salt/salt-2015.8.2.ebuild             | 22 ++++++++--
 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 0000000..871551e
--- /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 5a9a988..64fd02a 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"
 }


             reply	other threads:[~2015-11-20  2:16 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20  2:16 Patrick McLean [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-12-24  9:23 [gentoo-commits] repo/gentoo:master commit in: app-admin/salt/, app-admin/salt/files/ Sebastian Pipping
2023-09-08 22:56 Patrick McLean
2023-08-15 19:47 Patrick McLean
2023-04-20 19:19 Patrick McLean
2023-01-30  4:55 Sebastian Pipping
2023-01-10 14:15 Michał Górny
2022-08-31 17:21 Patrick McLean
2022-06-22 11:50 Michał Górny
2022-04-18 18:49 Patrick McLean
2022-04-18 17:34 Patrick McLean
2022-03-31 16:18 Patrick McLean
2022-03-31 16:07 Patrick McLean
2022-03-27  1:00 Sam James
2021-09-08  1:01 Patrick McLean
2021-06-09 22:27 Patrick McLean
2021-02-27  2:32 Patrick McLean
2021-02-27  2:32 Patrick McLean
2021-02-18  1:18 Patrick McLean
2021-02-09 17:00 Patrick McLean
2020-09-04  1:45 Patrick McLean
2020-04-30 17:58 Patrick McLean
2020-04-30  1:17 Patrick McLean
2019-02-27 21:40 Patrick McLean
2018-10-24 23:02 Patrick McLean
2017-12-05 21:44 Patrick McLean
2017-08-15 17:17 Manuel Rüger
2017-08-01  1:28 Patrick McLean
2016-12-01  1:16 Patrick McLean
2016-12-01  1:16 Patrick McLean
2016-06-16 23:43 Patrick McLean
2016-06-16 18:48 Patrick McLean
2016-02-01 22:57 Patrick McLean
2015-11-24  0:21 Patrick McLean
2015-11-06  7:58 Justin Lecher
2015-08-25 17:31 Patrick McLean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447985750.87fb830be92a8af777ecd9cf27c95979281ddef2.chutzpah@gentoo \
    --to=chutzpah@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox