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

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

Issue 10540172: Add variables support to trace_test_cases.py, removing the last use of --product-dir. (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 | « no previous file | tools/isolate/isolate_common.py » ('j') | 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 """Does one of the following depending on the --mode argument: 6 """Does one of the following depending on the --mode argument:
7 check Verifies all the inputs exist, touches the file specified with 7 check Verifies all the inputs exist, touches the file specified with
8 --result and exits. 8 --result and exits.
9 hashtable Puts a manifest file and hard links each of the inputs into the 9 hashtable Puts a manifest file and hard links each of the inputs into the
10 output directory. 10 output directory.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 return deepest_root 242 return deepest_root
243 243
244 244
245 def process_variables(variables, relative_base_dir, error): 245 def process_variables(variables, relative_base_dir, error):
246 """Processes path variables as a special case and returns a copy of the dict. 246 """Processes path variables as a special case and returns a copy of the dict.
247 247
248 For each 'path' varaible: first normalizes it, verifies it exists, converts it 248 For each 'path' varaible: first normalizes it, verifies it exists, converts it
249 to an absolute path, then sets it as relative to relative_base_dir. 249 to an absolute path, then sets it as relative to relative_base_dir.
250 """ 250 """
251 variables = variables.copy() 251 variables = variables.copy()
252 for i in ('DEPTH', 'PRODUCT_DIR'): 252 for i in isolate_common.PATH_VARIABLES:
253 if i not in variables: 253 if i not in variables:
254 continue 254 continue
255 variable = os.path.normpath(variables[i]) 255 variable = os.path.normpath(variables[i])
256 if not os.path.isdir(variable): 256 if not os.path.isdir(variable):
257 error('%s=%s is not a directory' % (i, variable)) 257 error('%s=%s is not a directory' % (i, variable))
258 # Variables could contain / or \ on windows. Always normalize to 258 # Variables could contain / or \ on windows. Always normalize to
259 # os.path.sep. 259 # os.path.sep.
260 variable = os.path.abspath(variable.replace('/', os.path.sep)) 260 variable = os.path.abspath(variable.replace('/', os.path.sep))
261 # All variables are relative to the .isolate file. 261 # All variables are relative to the .isolate file.
262 variables[i] = os.path.relpath(variable, relative_base_dir) 262 variables[i] = os.path.relpath(variable, relative_base_dir)
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 finally: 559 finally:
560 run_test_from_archive.rmtree(outdir) 560 run_test_from_archive.rmtree(outdir)
561 561
562 562
563 def MODEread(_outdir, state): 563 def MODEread(_outdir, state):
564 """Reads the trace file generated with --mode=trace.""" 564 """Reads the trace file generated with --mode=trace."""
565 api = trace_inputs.get_api() 565 api = trace_inputs.get_api()
566 logfile = state.result_file + '.log' 566 logfile = state.result_file + '.log'
567 if not os.path.isfile(logfile): 567 if not os.path.isfile(logfile):
568 return 1 568 return 1
569 product_dir = None
570 if state.resultdir and state.root_dir:
571 # Defaults to none if both are the same directory.
572 try:
573 product_dir = os.path.relpath(state.resultdir, state.root_dir) or None
574 except ValueError:
575 # This happens on Windows if state.resultdir is one drive, let's say
576 # 'C:\' and state.root_dir on another one like 'D:\'.
577 product_dir = None
578 try: 569 try:
579 results = trace_inputs.load_trace( 570 results = trace_inputs.load_trace(
580 logfile, state.root_dir, api, isolate_common.default_blacklist) 571 logfile, state.root_dir, api, isolate_common.default_blacklist)
581 simplified = trace_inputs.extract_directories(state.root_dir, results.files) 572 value = isolate_common.generate_isolate(
582 variables = isolate_common.generate_dict( 573 results.existent,
583 (f.path for f in simplified), 574 state.root_dir,
584 state.result.relative_cwd, 575 state.saved_state.variables,
585 product_dir) 576 state.result.relative_cwd)
586 # Outputs in a way that is easy to merge with merge_isolate.py.
587 value = {
588 'conditions': [
589 ['OS=="%s"' % isolate_common.get_flavor(), {
590 'variables': variables,
591 }],
592 ],
593 }
594 isolate_common.pretty_print(value, sys.stdout) 577 isolate_common.pretty_print(value, sys.stdout)
595 return 0 578 return 0
596 except trace_inputs.TracingFailure, e: 579 except trace_inputs.TracingFailure, e:
597 print >> sys.stderr, ( 580 print >> sys.stderr, (
598 '\nReading traces failed for: %s' % ' '.join(state.result.command)) 581 '\nReading traces failed for: %s' % ' '.join(state.result.command))
599 print >> sys.stderr, str(e) 582 print >> sys.stderr, str(e)
600 return 1 583 return 1
601 584
602 585
603 def MODEtrace(_outdir, state): 586 def MODEtrace(_outdir, state):
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 result_file, 763 result_file,
781 input_file, 764 input_file,
782 options.mode, 765 options.mode,
783 variables, 766 variables,
784 out_dir, 767 out_dir,
785 parser.error) 768 parser.error)
786 769
787 770
788 if __name__ == '__main__': 771 if __name__ == '__main__':
789 sys.exit(main()) 772 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/isolate/isolate_common.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698