Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: tests/trace_inputs_test.py

Issue 24813003: Move file path functions into utils/file_path.py. (Closed) Base URL: https://chromium.googlesource.com/a/chromium/tools/swarm_client@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/isolate_test.py ('k') | trace_inputs.py » ('j') | utils/file_path.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/trace_inputs_test.py
diff --git a/tests/trace_inputs_test.py b/tests/trace_inputs_test.py
index 43542eeae9306c066aee342fc7982f0fbb1edf3d..46c6f6b14d0405536aebc8ca6c64da18c3f8c200 100755
--- a/tests/trace_inputs_test.py
+++ b/tests/trace_inputs_test.py
@@ -7,10 +7,8 @@
import StringIO
import logging
import os
-import tempfile
-import unittest
-import shutil
import sys
+import unittest
BASE_DIR = unicode(os.path.dirname(os.path.abspath(__file__)))
ROOT_DIR = os.path.dirname(BASE_DIR)
@@ -80,25 +78,6 @@ class TraceInputs(unittest.TestCase):
self.assertEqual(os.path.join('/usr', '$FOO/bar'), actual.full_path)
self.assertEqual(True, actual.tainted)
- def test_native_case_end_with_os_path_sep(self):
- # Make sure the trailing os.path.sep is kept.
- path = trace_inputs.get_native_path_case(ROOT_DIR) + os.path.sep
- self.assertEqual(trace_inputs.get_native_path_case(path), path)
-
- def test_native_case_end_with_dot_os_path_sep(self):
- path = trace_inputs.get_native_path_case(ROOT_DIR + os.path.sep)
- self.assertEqual(
- trace_inputs.get_native_path_case(path + '.' + os.path.sep),
- path)
-
- def test_native_case_non_existing(self):
- # Make sure it doesn't throw on non-existing files.
- non_existing = 'trace_input_test_this_file_should_not_exist'
- path = os.path.expanduser('~/' + non_existing)
- self.assertFalse(os.path.exists(path))
- path = trace_inputs.get_native_path_case(ROOT_DIR) + os.path.sep
- self.assertEqual(trace_inputs.get_native_path_case(path), path)
-
def test_strace_filename(self):
filename = u'foo, bar, ~p#o,,ué^t%t.txt'
data = 'foo, bar, ~p#o,,u\\303\\251^t%t.txt'
@@ -137,130 +116,6 @@ class TraceInputs(unittest.TestCase):
self.assertEqual(1, len(actual))
self.assertEqual(expected, actual[0])
- if sys.platform in ('darwin', 'win32'):
- def test_native_case_not_sensitive(self):
- # The home directory is almost guaranteed to have mixed upper/lower case
- # letters on both Windows and OSX.
- # This test also ensures that the output is independent on the input
- # string case.
- path = os.path.expanduser(u'~')
- self.assertTrue(os.path.isdir(path))
- path = path.replace('/', os.path.sep)
- if sys.platform == 'win32':
- # Make sure the drive letter is upper case for consistency.
- path = path[0].upper() + path[1:]
- # This test assumes the variable is in the native path case on disk, this
- # should be the case. Verify this assumption:
- self.assertEqual(path, trace_inputs.get_native_path_case(path))
- self.assertEqual(
- trace_inputs.get_native_path_case(path.lower()),
- trace_inputs.get_native_path_case(path.upper()))
-
- def test_native_case_not_sensitive_non_existent(self):
- # This test also ensures that the output is independent on the input
- # string case.
- non_existing = os.path.join(
- 'trace_input_test_this_dir_should_not_exist', 'really not', '')
- path = os.path.expanduser(os.path.join(u'~', non_existing))
- path = path.replace('/', os.path.sep)
- self.assertFalse(os.path.exists(path))
- lower = trace_inputs.get_native_path_case(path.lower())
- upper = trace_inputs.get_native_path_case(path.upper())
- # Make sure non-existing element is not modified:
- self.assertTrue(lower.endswith(non_existing.lower()))
- self.assertTrue(upper.endswith(non_existing.upper()))
- self.assertEqual(lower[:-len(non_existing)], upper[:-len(non_existing)])
-
- if sys.platform != 'win32':
- def test_symlink(self):
- # This test will fail if the checkout is in a symlink.
- actual = trace_inputs.split_at_symlink(None, ROOT_DIR)
- expected = (ROOT_DIR, None, None)
- self.assertEqual(expected, actual)
-
- actual = trace_inputs.split_at_symlink(
- None, os.path.join(BASE_DIR, 'trace_inputs'))
- expected = (
- os.path.join(BASE_DIR, 'trace_inputs'), None, None)
- self.assertEqual(expected, actual)
-
- actual = trace_inputs.split_at_symlink(
- None, os.path.join(BASE_DIR, 'trace_inputs', 'files2'))
- expected = (
- os.path.join(BASE_DIR, 'trace_inputs'), 'files2', '')
- self.assertEqual(expected, actual)
-
- actual = trace_inputs.split_at_symlink(
- ROOT_DIR, os.path.join('tests', 'trace_inputs', 'files2'))
- expected = (
- os.path.join('tests', 'trace_inputs'), 'files2', '')
- self.assertEqual(expected, actual)
- actual = trace_inputs.split_at_symlink(
- ROOT_DIR, os.path.join('tests', 'trace_inputs', 'files2', 'bar'))
- expected = (
- os.path.join('tests', 'trace_inputs'), 'files2', '/bar')
- self.assertEqual(expected, actual)
-
- def test_native_case_symlink_right_case(self):
- actual = trace_inputs.get_native_path_case(
- os.path.join(BASE_DIR, 'trace_inputs'))
- self.assertEqual('trace_inputs', os.path.basename(actual))
-
- # Make sure the symlink is not resolved.
- actual = trace_inputs.get_native_path_case(
- os.path.join(BASE_DIR, 'trace_inputs', 'files2'))
- self.assertEqual('files2', os.path.basename(actual))
-
- if sys.platform == 'darwin':
- def test_native_case_symlink_wrong_case(self):
- base_dir = trace_inputs.get_native_path_case(BASE_DIR)
- trace_inputs_dir = os.path.join(base_dir, 'trace_inputs')
- actual = trace_inputs.get_native_path_case(trace_inputs_dir)
- self.assertEqual(trace_inputs_dir, actual)
-
- # Make sure the symlink is not resolved.
- data = os.path.join(trace_inputs_dir, 'Files2')
- actual = trace_inputs.get_native_path_case(data)
- self.assertEqual(
- os.path.join(trace_inputs_dir, 'files2'), actual)
-
- data = os.path.join(trace_inputs_dir, 'Files2', '')
- actual = trace_inputs.get_native_path_case(data)
- self.assertEqual(
- os.path.join(trace_inputs_dir, 'files2', ''), actual)
-
- data = os.path.join(trace_inputs_dir, 'Files2', 'Child1.py')
- actual = trace_inputs.get_native_path_case(data)
- # TODO(maruel): Should be child1.py.
- self.assertEqual(
- os.path.join(trace_inputs_dir, 'files2', 'Child1.py'), actual)
-
- if sys.platform == 'win32':
- def test_native_case_alternate_datastream(self):
- # Create the file manually, since tempfile doesn't support ADS.
- tempdir = unicode(tempfile.mkdtemp(prefix='trace_inputs'))
- try:
- tempdir = trace_inputs.get_native_path_case(tempdir)
- basename = 'foo.txt'
- filename = basename + ':Zone.Identifier'
- filepath = os.path.join(tempdir, filename)
- open(filepath, 'w').close()
- self.assertEqual(filepath, trace_inputs.get_native_path_case(filepath))
- data_suffix = ':$DATA'
- self.assertEqual(
- filepath + data_suffix,
- trace_inputs.get_native_path_case(filepath + data_suffix))
-
- open(filepath + '$DATA', 'w').close()
- self.assertEqual(
- filepath + data_suffix,
- trace_inputs.get_native_path_case(filepath + data_suffix))
- # Ensure the ADS weren't created as separate file. You love NTFS, don't
- # you?
- self.assertEqual([basename], os.listdir(tempdir))
- finally:
- shutil.rmtree(tempdir)
-
if sys.platform != 'win32':
class StraceInputs(unittest.TestCase):
« no previous file with comments | « tests/isolate_test.py ('k') | trace_inputs.py » ('j') | utils/file_path.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698