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

Side by Side Diff: tools/isolate/trace_inputs_test.py

Issue 10542087: Add variable replacement in trace_inputs.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/isolate/trace_inputs.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import logging 6 import logging
7 import os 7 import os
8 import unittest 8 import unittest
9 import sys 9 import sys
10 10
11 FILE_NAME = os.path.abspath(__file__) 11 FILE_NAME = os.path.abspath(__file__)
12 ROOT_DIR = os.path.dirname(FILE_NAME) 12 ROOT_DIR = os.path.dirname(FILE_NAME)
13 13
14 import trace_inputs 14 import trace_inputs
15 15
16 16
17 class TraceInputs(unittest.TestCase): 17 class TraceInputs(unittest.TestCase):
18 def test_process_quoted_arguments(self): 18 def test_process_quoted_arguments(self):
19 test_cases = ( 19 test_cases = (
20 ('"foo"', ['foo']), 20 ('"foo"', ['foo']),
21 ('"foo", "bar"', ['foo', 'bar']), 21 ('"foo", "bar"', ['foo', 'bar']),
22 ('"foo"..., "bar"', ['foo', 'bar']), 22 ('"foo"..., "bar"', ['foo', 'bar']),
23 ('"foo", "bar"...', ['foo', 'bar']), 23 ('"foo", "bar"...', ['foo', 'bar']),
24 ) 24 )
25 for actual, expected in test_cases: 25 for actual, expected in test_cases:
26 self.assertEquals(expected, trace_inputs.process_quoted_arguments(actual)) 26 self.assertEquals(expected, trace_inputs.process_quoted_arguments(actual))
27 27
28 def test_variable_abs(self):
29 value = trace_inputs.Results.File(None, '/foo/bar', False)
30 actual = value.replace_variables({'$FOO': '/foo'})
31 self.assertEquals('$FOO/bar', actual.path)
32 self.assertEquals('$FOO/bar', actual.full_path)
33 self.assertEquals(True, actual.tainted)
34
35 def test_variable_rel(self):
36 value = trace_inputs.Results.File('/usr', 'foo/bar', False)
37 actual = value.replace_variables({'$FOO': 'foo'})
38 self.assertEquals('$FOO/bar', actual.path)
39 self.assertEquals(os.path.join('/usr', '$FOO/bar'), actual.full_path)
40 self.assertEquals(True, actual.tainted)
41
28 42
29 def join_norm(*args): 43 def join_norm(*args):
30 """Joins and normalizes path in a single step.""" 44 """Joins and normalizes path in a single step."""
31 return unicode(os.path.normpath(os.path.join(*args))) 45 return unicode(os.path.normpath(os.path.join(*args)))
32 46
33 47
34 if sys.platform != 'win32': 48 if sys.platform != 'win32':
35 class StraceInputs(unittest.TestCase): 49 class StraceInputs(unittest.TestCase):
36 # Represents the root process pid (an arbitrary number). 50 # Represents the root process pid (an arbitrary number).
37 _ROOT_PID = 27 51 _ROOT_PID = 27
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 'size': -1, 303 'size': -1,
290 }, 304 },
291 ] 305 ]
292 self._test_lines(lines, '/home/foo_bar_user/src', files) 306 self._test_lines(lines, '/home/foo_bar_user/src', files)
293 307
294 308
295 if __name__ == '__main__': 309 if __name__ == '__main__':
296 VERBOSE = '-v' in sys.argv 310 VERBOSE = '-v' in sys.argv
297 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) 311 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR)
298 unittest.main() 312 unittest.main()
OLDNEW
« 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