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

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

Issue 9621014: Separate xvfb.py logic into its own script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Save 5 lines, a variable is not needed Created 8 years, 9 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 | « testing/xvfb.py ('k') | tools/isolate/tree_creator.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 verify all the inputs exist, touches the file specified with 7 check verify 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 print >> sys.stderr, 'Using first input %s as executable' % infiles[0] 114 print >> sys.stderr, 'Using first input %s as executable' % infiles[0]
115 cmd = [infiles[0]] 115 cmd = [infiles[0]]
116 outdir = None 116 outdir = None
117 try: 117 try:
118 outdir = tempfile.mkdtemp(prefix='isolate') 118 outdir = tempfile.mkdtemp(prefix='isolate')
119 tree_creator.recreate_tree( 119 tree_creator.recreate_tree(
120 outdir, indir, infiles, tree_creator.HARDLINK) 120 outdir, indir, infiles, tree_creator.HARDLINK)
121 if read_only: 121 if read_only:
122 tree_creator.make_writable(outdir, True) 122 tree_creator.make_writable(outdir, True)
123 123
124 # TODO(maruel): Remove me. Layering violation. Used by
125 # base/base_paths_linux.cc
126 env = os.environ.copy()
127 env['CR_SOURCE_ROOT'] = outdir.encode()
128 # Rebase the command to the right path. 124 # Rebase the command to the right path.
129 cmd[0] = os.path.join(outdir, cmd[0]) 125 cwd = os.path.join(outdir, os.path.relpath(os.getcwd(), indir))
130 logging.info('Running %s' % cmd) 126 logging.info('Running %s, cwd=%s' % (cmd, cwd))
131 result = subprocess.call(cmd, cwd=outdir, env=env) 127 result = subprocess.call(cmd, cwd=cwd)
132 if not result and resultfile: 128 if not result and resultfile:
133 # Signal the build tool that the test succeeded. 129 # Signal the build tool that the test succeeded.
134 touch(resultfile) 130 touch(resultfile)
135 return result 131 return result
136 finally: 132 finally:
137 if read_only: 133 if read_only:
138 tree_creator.make_writable(outdir, False) 134 tree_creator.make_writable(outdir, False)
139 rmtree(outdir) 135 rmtree(outdir)
140 136
141 137
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 help='File to be touched when the command succeeds') 170 help='File to be touched when the command succeeds')
175 parser.add_option( 171 parser.add_option(
176 '--root', metavar='DIR', help='Base directory to fetch files, required') 172 '--root', metavar='DIR', help='Base directory to fetch files, required')
177 parser.add_option( 173 parser.add_option(
178 '--outdir', metavar='DIR', 174 '--outdir', metavar='DIR',
179 help='Directory used to recreate the tree or store the hash table. ' 175 help='Directory used to recreate the tree or store the hash table. '
180 'Defaults to a /tmp subdirectory for modes run and remap.') 176 'Defaults to a /tmp subdirectory for modes run and remap.')
181 parser.add_option( 177 parser.add_option(
182 '--read-only', action='store_true', 178 '--read-only', action='store_true',
183 help='Make the temporary tree read-only') 179 help='Make the temporary tree read-only')
180 parser.add_option(
181 '--files', metavar='FILE',
182 help='File to be read containing input files')
184 183
185 options, args = parser.parse_args() 184 options, args = parser.parse_args()
186 level = [logging.ERROR, logging.INFO, logging.DEBUG][min(2, options.verbose)] 185 level = [logging.ERROR, logging.INFO, logging.DEBUG][min(2, options.verbose)]
187 logging.basicConfig( 186 logging.basicConfig(
188 level=level, 187 level=level,
189 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') 188 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s')
190 189
191 if not options.root: 190 if not options.root:
192 parser.error('--root is required.') 191 parser.error('--root is required.')
193 192
193 if options.files:
194 args = [
195 i.decode('utf-8')
196 for i in open(options.files, 'rb').read().splitlines() if i
197 ] + args
198
194 infiles, cmd = separate_inputs_command(args, options.root) 199 infiles, cmd = separate_inputs_command(args, options.root)
195 if not infiles: 200 if not infiles:
196 parser.error('Need at least one input file to map') 201 parser.error('Need at least one input file to map')
197 # Preprocess the input files. 202 # Preprocess the input files.
198 try: 203 try:
199 infiles, root = tree_creator.preprocess_inputs( 204 infiles, root = tree_creator.preprocess_inputs(
200 options.root, infiles, lambda x: re.match(r'.*\.(svn|pyc)$', x)) 205 options.root, infiles, lambda x: re.match(r'.*\.(svn|pyc)$', x))
201 return isolate( 206 return isolate(
202 options.outdir, 207 options.outdir,
203 options.result, 208 options.result,
204 root, 209 root,
205 infiles, 210 infiles,
206 options.mode, 211 options.mode,
207 options.read_only, 212 options.read_only,
208 cmd) 213 cmd)
209 except tree_creator.MappingError, e: 214 except tree_creator.MappingError, e:
210 print >> sys.stderr, str(e) 215 print >> sys.stderr, str(e)
211 return 1 216 return 1
212 217
213 218
214 if __name__ == '__main__': 219 if __name__ == '__main__':
215 sys.exit(main()) 220 sys.exit(main())
OLDNEW
« no previous file with comments | « testing/xvfb.py ('k') | tools/isolate/tree_creator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698