summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 23:25:33 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 23:25:33 +0000
commite47aee08984a9a341ceccb8e4d342ac616982d2c (patch)
treede48ab5f9426b8e16a57ec31704141c707a4ac64
parent49742b37c3b46d9c9001be10d5dbd9dbdbe03040 (diff)
downloadchromium_src-e47aee08984a9a341ceccb8e4d342ac616982d2c.zip
chromium_src-e47aee08984a9a341ceccb8e4d342ac616982d2c.tar.gz
chromium_src-e47aee08984a9a341ceccb8e4d342ac616982d2c.tar.bz2
Do not call extract_directories() in load_trace() anymore.
There will be cases where this is not wanted. NOTRY=true R=cmp@chromium.org BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10536019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140652 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xtools/isolate/isolate.py3
-rwxr-xr-xtools/isolate/trace_inputs.py7
-rwxr-xr-xtools/isolate/trace_inputs_smoke_test.py89
-rwxr-xr-xtools/isolate/trace_test_cases.py3
4 files changed, 82 insertions, 20 deletions
diff --git a/tools/isolate/isolate.py b/tools/isolate/isolate.py
index 5592ff7..50082d4 100755
--- a/tools/isolate/isolate.py
+++ b/tools/isolate/isolate.py
@@ -591,7 +591,8 @@ def MODEtrace(_outdir, state):
logfile,
True)
- _, simplified = trace_inputs.load_trace(logfile, state.root_dir, api)
+ results = trace_inputs.load_trace(logfile, state.root_dir, api)
+ simplified = trace_inputs.extract_directories(state.root_dir, results.files)
variables = isolate_common.generate_dict(
(f.path for f in simplified),
state.result.relative_cwd,
diff --git a/tools/isolate/trace_inputs.py b/tools/isolate/trace_inputs.py
index 531e73b..556e633 100755
--- a/tools/isolate/trace_inputs.py
+++ b/tools/isolate/trace_inputs.py
@@ -2406,8 +2406,7 @@ def load_trace(logfile, root_dir, api):
results = api.parse_log(logfile, get_blacklist(api))
if root_dir:
results = results.strip_root(root_dir)
- simplified = extract_directories(root_dir, results.files)
- return results, simplified
+ return results
def CMDclean(parser, args):
@@ -2467,8 +2466,8 @@ def CMDread(parser, args):
api = get_api()
try:
- results, simplified = load_trace(options.log, options.root_dir, api)
-
+ results = load_trace(options.log, options.root_dir, api)
+ simplified = extract_directories(options.root_dir, results.files)
if options.json:
write_json(sys.stdout, results.flatten(), False)
else:
diff --git a/tools/isolate/trace_inputs_smoke_test.py b/tools/isolate/trace_inputs_smoke_test.py
index bd67455..2efad03 100755
--- a/tools/isolate/trace_inputs_smoke_test.py
+++ b/tools/isolate/trace_inputs_smoke_test.py
@@ -42,9 +42,11 @@ class TraceInputsBase(unittest.TestCase):
# - OSX replaces /usr/bin/python with /usr/bin/python2.7.
self.cwd = os.path.join(ROOT_DIR, u'data')
self.initial_cwd = self.cwd
+ self.expected_cwd = ROOT_DIR
if sys.platform == 'win32':
# Not supported on Windows.
self.initial_cwd = None
+ self.expected_cwd = None
# There's 3 kinds of references to python, self.executable,
# self.real_executable and self.naked_executable. It depends how python was
@@ -236,12 +238,11 @@ class TraceInputsImport(TraceInputsBase):
#self.assertEquals('', output)
return self.trace_inputs.load_trace(self.log, ROOT_DIR, api)
- def test_trace_wrong_path(self):
- # Deliberately start the trace from the wrong path. Starts it from the
- # directory 'data' so 'data/data/trace_inputs/child1.py' is not accessible,
- # so child2.py process is not started.
- results, simplified = self._execute(self.get_child_command(False))
- expected = {
+ def _gen_dict_wrong_path(self):
+ """Returns the expected flattened Results when child1.py is called with the
+ wrong relative path.
+ """
+ return {
'root': {
'children': [],
'command': [
@@ -254,13 +255,60 @@ class TraceInputsImport(TraceInputsBase):
'initial_cwd': self.initial_cwd,
},
}
- actual = results.flatten()
- self.assertTrue(actual['root'].pop('pid'))
- self.assertEquals(expected, actual)
- self.assertEquals([], simplified)
- def test_trace(self):
- expected = {
+ def _gen_dict_full(self):
+ """Returns the expected flattened Results when child1.py is called with
+ --child.
+ """
+ return {
+ 'root': {
+ 'children': [
+ {
+ 'children': [],
+ 'command': ['python', 'child2.py'],
+ 'executable': self.naked_executable,
+ 'files': [
+ {
+ 'path': os.path.join(u'data', 'trace_inputs', 'child2.py'),
+ 'size': self._size(u'data', 'trace_inputs', 'child2.py'),
+ },
+ {
+ 'path': os.path.join(u'data', 'trace_inputs', 'test_file.txt'),
+ 'size': 4,
+ },
+ ],
+ 'initial_cwd': self.expected_cwd,
+ },
+ ],
+ 'command': [
+ self.executable,
+ os.path.join('data', 'trace_inputs', 'child1.py'),
+ '--child',
+ ],
+ 'executable': self.real_executable,
+ 'files': [
+ {
+ 'path': os.path.join(u'data', 'trace_inputs', 'child1.py'),
+ 'size': self._size(u'data', 'trace_inputs', 'child1.py'),
+ },
+ {
+ 'path': u'trace_inputs.py',
+ 'size': self._size('trace_inputs.py'),
+ },
+ {
+ 'path': u'trace_inputs_smoke_test.py',
+ 'size': self._size('trace_inputs_smoke_test.py'),
+ },
+ ],
+ 'initial_cwd': self.expected_cwd,
+ },
+ }
+
+ def _gen_dict_full_gyp(self):
+ """Returns the expected flattened Results when child1.py is called with
+ --child-gyp.
+ """
+ return {
'root': {
'children': [
{
@@ -303,7 +351,20 @@ class TraceInputsImport(TraceInputsBase):
'initial_cwd': self.initial_cwd,
},
}
- results, simplified = self._execute(self.get_child_command(True))
+
+ def test_trace_wrong_path(self):
+ # Deliberately start the trace from the wrong path. Starts it from the
+ # directory 'data' so 'data/data/trace_inputs/child1.py' is not accessible,
+ # so child2.py process is not started.
+ results = self._execute(self.get_child_command(False))
+ expected = self._gen_dict_wrong_path()
+ actual = results.flatten()
+ self.assertTrue(actual['root'].pop('pid'))
+ self.assertEquals(expected, actual)
+
+ def test_trace(self):
+ expected = self._gen_dict_full_gyp()
+ results = self._execute(self.get_child_command(True))
actual = results.flatten()
self.assertTrue(actual['root'].pop('pid'))
self.assertTrue(actual['root']['children'][0].pop('pid'))
@@ -313,10 +374,10 @@ class TraceInputsImport(TraceInputsBase):
u'trace_inputs.py',
u'trace_inputs_smoke_test.py',
]
+ simplified = self.trace_inputs.extract_directories(ROOT_DIR, results.files)
self.assertEquals(files, [f.path for f in simplified])
-
if __name__ == '__main__':
VERBOSE = '-v' in sys.argv
logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR)
diff --git a/tools/isolate/trace_test_cases.py b/tools/isolate/trace_test_cases.py
index fceaa4c..66dff09 100755
--- a/tools/isolate/trace_test_cases.py
+++ b/tools/isolate/trace_test_cases.py
@@ -55,11 +55,12 @@ def trace_test_case(
continue
duration = time.time() - start
try:
- results, simplified = trace_inputs.load_trace(logname, root_dir, api)
+ results = trace_inputs.load_trace(logname, root_dir, api)
break
except trace_inputs.TracingFailure, e:
print >> sys.stderr, '\nTracing failed for: %s' % ' '.join(cmd)
print >> sys.stderr, str(e)
+ simplified = trace_inputs.extract_directories(root_dir, results.files)
if simplified:
variables = isolate_common.generate_dict(simplified, cwd_dir, product_dir)
else: