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

Unified Diff: tools/isolate/trace_inputs_test.py

Issue 10753006: get_native_path_case() now preserves the trailing os.sep.path and work with non-existing path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « tools/isolate/trace_inputs.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/isolate/trace_inputs_test.py
diff --git a/tools/isolate/trace_inputs_test.py b/tools/isolate/trace_inputs_test.py
index 79d7da14b0ffd57018499003974eb2a0469c72ba..3301b27c5db70638265ee8494172a88dbcbea26c 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):
« no previous file with comments | « tools/isolate/trace_inputs.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698