public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/locks/
Date: Wed, 14 Dec 2011 09:18:13 +0000 (UTC)	[thread overview]
Message-ID: <b898440e35aa96cd50c74b13d26d5924d2d708ed.zmedico@gentoo> (raw)

commit:     b898440e35aa96cd50c74b13d26d5924d2d708ed
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 09:17:16 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 09:17:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b898440e

tests/locks: save/restore global env state

This ensures that global __PORTAGE_TEST_HARDLINK_LOCKS overrides work
correctly for all tests.

---
 pym/portage/tests/locks/test_asynchronous_lock.py |   12 ++++++++++++
 pym/portage/tests/locks/test_lock_nonblock.py     |    3 +++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py
index c896cb4..49dd10e 100644
--- a/pym/portage/tests/locks/test_asynchronous_lock.py
+++ b/pym/portage/tests/locks/test_asynchronous_lock.py
@@ -43,11 +43,14 @@ class AsynchronousLockTestCase(TestCase):
 		self._testAsynchronousLock()
 
 	def testAsynchronousLockHardlink(self):
+		prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
 		os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
 		try:
 			self._testAsynchronousLock()
 		finally:
 			os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+			if prev_state is not None:
+				os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state
 
 	def _testAsynchronousLockWait(self):
 		scheduler = PollScheduler().sched_iface
@@ -81,11 +84,14 @@ class AsynchronousLockTestCase(TestCase):
 		self._testAsynchronousLockWait()
 
 	def testAsynchronousLockWaitHardlink(self):
+		prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
 		os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
 		try:
 			self._testAsynchronousLockWait()
 		finally:
 			os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+			if prev_state is not None:
+				os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state
 
 	def _testAsynchronousLockWaitCancel(self):
 		scheduler = PollScheduler().sched_iface
@@ -116,11 +122,14 @@ class AsynchronousLockTestCase(TestCase):
 		self._testAsynchronousLockWaitCancel()
 
 	def testAsynchronousLockWaitCancelHardlink(self):
+		prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
 		os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
 		try:
 			self._testAsynchronousLockWaitCancel()
 		finally:
 			os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+			if prev_state is not None:
+				os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state
 
 	def _testAsynchronousLockWaitKill(self):
 		scheduler = PollScheduler().sched_iface
@@ -157,8 +166,11 @@ class AsynchronousLockTestCase(TestCase):
 		self._testAsynchronousLockWaitKill()
 
 	def testAsynchronousLockWaitKillHardlink(self):
+		prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
 		os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
 		try:
 			self._testAsynchronousLockWaitKill()
 		finally:
 			os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+			if prev_state is not None:
+				os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state

diff --git a/pym/portage/tests/locks/test_lock_nonblock.py b/pym/portage/tests/locks/test_lock_nonblock.py
index 914084c..17f854d 100644
--- a/pym/portage/tests/locks/test_lock_nonblock.py
+++ b/pym/portage/tests/locks/test_lock_nonblock.py
@@ -48,9 +48,12 @@ class LockNonblockTestCase(TestCase):
 		self._testLockNonblock()
 
 	def testLockNonblockHardlink(self):
+		prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
 		os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
 		try:
 			self._testLockNonblock()
 		finally:
 			os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+			if prev_state is not None:
+				os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state
 



             reply	other threads:[~2011-12-14  9:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-14  9:18 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-03-28  0:26 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/locks/ Zac Medico
2011-06-09  0:33 Zac Medico
2011-05-18 19:46 Arfrever Frehtes Taifersar Arahesis
2011-05-17 21:14 Zac Medico
2011-05-17 21:03 Zac Medico
2011-05-17 20:56 Zac Medico

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=b898440e35aa96cd50c74b13d26d5924d2d708ed.zmedico@gentoo \
    --to=zmedico@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