Index: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py |
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py |
index 1f802d822743f20e9ff6b5f18b5b65922e8ba8cd..c14803152a39946d9a83aa289ea79159dfe6c843 100644 |
--- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py |
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py |
@@ -26,13 +26,13 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+import os |
from webkitpy.common.system import executive_mock |
from webkitpy.common.system.systemhost_mock import MockSystemHost |
-from webkitpy.tool.mock_tool import MockOptions |
- |
from webkitpy.layout_tests.port import linux |
from webkitpy.layout_tests.port import port_testcase |
+from webkitpy.tool.mock_tool import MockOptions |
class LinuxPortTest(port_testcase.PortTestCase): |
@@ -42,6 +42,13 @@ class LinuxPortTest(port_testcase.PortTestCase): |
full_port_name = 'linux-trusty' |
port_maker = linux.LinuxPort |
+ def setUp(self): |
+ # TODO(qyearsley): Remove this when crbug.com/627887 is fixed. |
+ self.original_environ = os.environ.copy() |
+ |
+ def tearDown(self): |
+ os.environ = self.original_environ |
+ |
def assert_version_properties(self, port_name, os_version, expected_name, |
expected_version, |
driver_file_output=None): |
@@ -101,3 +108,21 @@ class LinuxPortTest(port_testcase.PortTestCase): |
def test_path_to_image_diff(self): |
self.assertEqual(self.make_port()._path_to_image_diff(), '/mock-checkout/out/Release/image_diff') |
+ |
+ def test_dummy_home_dir_is_created_and_cleaned_up(self): |
+ original_home = '/home/user' |
+ os.environ['HOME'] = original_home |
+ port = self.make_port() |
+ port._filesystem.files['/home/user/.Xauthority'] = '' |
+ |
+ # Set up the test run; the temporary home directory should be set up. |
+ port.setup_test_run() |
+ temp_home_dir = os.environ['HOME'] |
+ self.assertNotEqual(temp_home_dir, original_home) |
+ self.assertTrue(port._filesystem.isdir(temp_home_dir)) |
+ self.assertTrue(port._filesystem.isfile(port._filesystem.join(temp_home_dir, '.Xauthority'))) |
+ |
+ # Clean up; HOME should be reset and the temp dir should be cleaned up. |
+ port.clean_up_test_run() |
+ self.assertEqual(os.environ.get('HOME'), original_home) |
+ self.assertFalse(port._filesystem.exists(temp_home_dir)) |