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

Side by Side Diff: third_party/closure_compiler/compile.py

Issue 1128843007: Add tests for third_party/closure_compiler/compile.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move out_dir creation to _run_js_check() Created 5 years, 7 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
« no previous file with comments | « no previous file | third_party/closure_compiler/compiler_customization_test.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/python 1 #!/usr/bin/python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 """Runs Closure compiler on JavaScript files to check for errors and produce 6 """Runs Closure compiler on JavaScript files to check for errors and produce
7 minified output.""" 7 minified output."""
8 8
9 import argparse 9 import argparse
10 import os 10 import os
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 output_wrapper: Wraps output into this string at the place denoted by the 263 output_wrapper: Wraps output into this string at the place denoted by the
264 marker token %output%. 264 marker token %output%.
265 265
266 Returns: 266 Returns:
267 (errors, stderr) A parsed list of errors (strings) found by the compiler 267 (errors, stderr) A parsed list of errors (strings) found by the compiler
268 and the raw stderr (as a string). 268 and the raw stderr (as a string).
269 """ 269 """
270 args = ["--js=%s" % s for s in sources] 270 args = ["--js=%s" % s for s in sources]
271 271
272 if out_file: 272 if out_file:
273 out_dir = os.path.dirname(out_file)
274 if not os.path.exists(out_dir):
275 os.makedirs(out_dir)
273 args += ["--js_output_file=%s" % out_file] 276 args += ["--js_output_file=%s" % out_file]
274 args += ["--create_source_map=%s" % (self._MAP_FILE_FORMAT % out_file)] 277 args += ["--create_source_map=%s" % (self._MAP_FILE_FORMAT % out_file)]
275 278
276 if externs: 279 if externs:
277 args += ["--externs=%s" % e for e in externs] 280 args += ["--externs=%s" % e for e in externs]
278 281
279 if output_wrapper: 282 if output_wrapper:
280 args += ['--output_wrapper="%s"' % output_wrapper] 283 args += ['--output_wrapper="%s"' % output_wrapper]
281 284
282 args_file_content = " %s" % " ".join(self._common_args() + args) 285 args_file_content = " %s" % " ".join(self._common_args() + args)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 opts = parser.parse_args() 415 opts = parser.parse_args()
413 416
414 depends = opts.depends or [] 417 depends = opts.depends or []
415 externs = set(opts.externs or []) 418 externs = set(opts.externs or [])
416 419
417 polymer_externs = os.path.join(os.path.dirname(_CURRENT_DIR), 'polymer', 420 polymer_externs = os.path.join(os.path.dirname(_CURRENT_DIR), 'polymer',
418 'v0_8', 'components-chromium', 421 'v0_8', 'components-chromium',
419 'polymer-externs', 'polymer.externs.js') 422 'polymer-externs', 'polymer.externs.js')
420 externs.add(polymer_externs) 423 externs.add(polymer_externs)
421 424
422 if opts.out_file:
423 out_dir = os.path.dirname(opts.out_file)
424 if not os.path.exists(out_dir):
425 os.makedirs(out_dir)
426
427 checker = Checker(verbose=opts.verbose, strict=opts.strict) 425 checker = Checker(verbose=opts.verbose, strict=opts.strict)
428 if opts.single_file: 426 if opts.single_file:
429 for source in opts.sources: 427 for source in opts.sources:
430 depends, externs = build.inputs.resolve_recursive_dependencies( 428 depends, externs = build.inputs.resolve_recursive_dependencies(
431 source, depends, externs) 429 source, depends, externs)
432 found_errors, _ = checker.check(source, out_file=opts.out_file, 430 found_errors, _ = checker.check(source, out_file=opts.out_file,
433 depends=depends, externs=externs, 431 depends=depends, externs=externs,
434 output_wrapper=opts.output_wrapper) 432 output_wrapper=opts.output_wrapper)
435 if found_errors: 433 if found_errors:
436 sys.exit(1) 434 sys.exit(1)
437 else: 435 else:
438 found_errors, stderr = checker.check_multiple( 436 found_errors, stderr = checker.check_multiple(
439 opts.sources, 437 opts.sources,
440 out_file=opts.out_file, 438 out_file=opts.out_file,
441 output_wrapper=opts.output_wrapper, 439 output_wrapper=opts.output_wrapper,
442 externs=externs) 440 externs=externs)
443 if found_errors: 441 if found_errors:
444 print stderr 442 print stderr
445 sys.exit(1) 443 sys.exit(1)
446 444
447 if opts.success_stamp: 445 if opts.success_stamp:
448 with open(opts.success_stamp, "w"): 446 with open(opts.success_stamp, "w"):
449 os.utime(opts.success_stamp, None) 447 os.utime(opts.success_stamp, None)
OLDNEW
« no previous file with comments | « no previous file | third_party/closure_compiler/compiler_customization_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698