summaryrefslogtreecommitdiffstats
path: root/tools/isolate/trace_inputs_test.py
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 17:40:19 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 17:40:19 +0000
commitdf22662a437cc1873bcc3fd38c8a1b3068f62aee (patch)
tree2df2edcd698da71da533a382fd021dc83171935b /tools/isolate/trace_inputs_test.py
parent99229b21191cfe0f6b78d2ae29d1e042a3afd5d4 (diff)
downloadchromium_src-df22662a437cc1873bcc3fd38c8a1b3068f62aee.zip
chromium_src-df22662a437cc1873bcc3fd38c8a1b3068f62aee.tar.gz
chromium_src-df22662a437cc1873bcc3fd38c8a1b3068f62aee.tar.bz2
get_native_path_case() now preserves the trailing os.sep.path and work with non-existing path.
This simplifies a few code paths. Add unit test to make sure the behavior is consistent accross platforms. Fixes test regressions. R=cmp@chromium.org NOTRY=true BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10753006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146137 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/isolate/trace_inputs_test.py')
-rwxr-xr-xtools/isolate/trace_inputs_test.py45
1 files changed, 40 insertions, 5 deletions
diff --git a/tools/isolate/trace_inputs_test.py b/tools/isolate/trace_inputs_test.py
index 79d7da1..3301b27 100755
--- a/tools/isolate/trace_inputs_test.py
+++ b/tools/isolate/trace_inputs_test.py
@@ -64,12 +64,47 @@ class TraceInputs(unittest.TestCase):
self.assertEquals(os.path.join('/usr', '$FOO/bar'), actual.full_path)
self.assertEquals(True, actual.tainted)
- if sys.platform == 'win32':
- def test_native_case_windows(self):
- windows_path = os.environ['SystemRoot']
+ 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.assertEquals(trace_inputs.get_native_path_case(path), 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.assertEquals(trace_inputs.get_native_path_case(path), path)
+
+ 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('~')
+ self.assertTrue(os.path.isdir(path))
+ # This test assumes the variable is in the native path case on disk, this
+ # should be the case. Verify this assumption:
+ self.assertEquals(path, trace_inputs.get_native_path_case(path))
self.assertEquals(
- trace_inputs.get_native_path_case(windows_path.lower()),
- trace_inputs.get_native_path_case(windows_path.upper()))
+ 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('~', non_existing))
+ 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.assertEquals(lower[:-len(non_existing)], upper[:-len(non_existing)])
if sys.platform != 'win32':
def test_symlink(self):