| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 Google Inc. All rights reserved. | 2 # Copyright (c) 2012 Google Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 def run_in_shell(command_line): | 97 def run_in_shell(command_line): |
| 98 return subprocess.Popen(command_line, stdout=subprocess.PIPE, stderr=subproc
ess.STDOUT, shell=True) | 98 return subprocess.Popen(command_line, stdout=subprocess.PIPE, stderr=subproc
ess.STDOUT, shell=True) |
| 99 | 99 |
| 100 | 100 |
| 101 def hasErrors(output): | 101 def hasErrors(output): |
| 102 return re.search(error_warning_regex, output) != None | 102 return re.search(error_warning_regex, output) != None |
| 103 | 103 |
| 104 | 104 |
| 105 def verify_jsdoc_extra(additional_files): | 105 def verify_jsdoc_extra(additional_files): |
| 106 return run_in_shell('%s -jar %s %s' % (java_exec, jsdoc_validator_jar, ' '.j
oin(descriptors.all_compiled_files() + additional_files))) | 106 file_list = tempfile.NamedTemporaryFile(mode='wt', delete=False) |
| 107 try: |
| 108 file_list.write('\n'.join(descriptors.all_compiled_files() + additional_
files)) |
| 109 finally: |
| 110 file_list.close() |
| 111 return run_in_shell('%s -jar %s --files-list-name %s' % (java_exec, jsdoc_va
lidator_jar, file_list.name)), file_list |
| 107 | 112 |
| 108 | 113 |
| 109 def verify_jsdoc(additional_files): | 114 def verify_jsdoc(additional_files): |
| 110 def file_list(): | 115 def file_list(): |
| 111 return descriptors.all_compiled_files() + additional_files | 116 return descriptors.all_compiled_files() + additional_files |
| 112 | 117 |
| 113 errors_found = False | 118 errors_found = False |
| 114 for full_file_name in file_list(): | 119 for full_file_name in file_list(): |
| 115 lineIndex = 0 | 120 lineIndex = 0 |
| 116 with open(full_file_name, 'r') as sourceFile: | 121 with open(full_file_name, 'r') as sourceFile: |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 command += ' --js ' + injectedScriptSourceTmpFile + ' \\\n' | 307 command += ' --js ' + injectedScriptSourceTmpFile + ' \\\n' |
| 303 command += ' --module ' + jsmodule_name_prefix + 'injected_canvas_script' + '
:1:' + jsmodule_name_prefix + 'injected_script' + ' \\\n' | 308 command += ' --module ' + jsmodule_name_prefix + 'injected_canvas_script' + '
:1:' + jsmodule_name_prefix + 'injected_script' + ' \\\n' |
| 304 command += ' --js ' + injectedScriptCanvasModuleSourceTmpFile + ' \\\n' | 309 command += ' --js ' + injectedScriptCanvasModuleSourceTmpFile + ' \\\n' |
| 305 command += '\n' | 310 command += '\n' |
| 306 | 311 |
| 307 injectedScriptCompileProc = run_in_shell(command) | 312 injectedScriptCompileProc = run_in_shell(command) |
| 308 | 313 |
| 309 print 'Verifying JSDoc comments...' | 314 print 'Verifying JSDoc comments...' |
| 310 additional_jsdoc_check_files = [injectedScriptSourceTmpFile, injectedScriptCanva
sModuleSourceTmpFile] | 315 additional_jsdoc_check_files = [injectedScriptSourceTmpFile, injectedScriptCanva
sModuleSourceTmpFile] |
| 311 errors_found |= verify_jsdoc(additional_jsdoc_check_files) | 316 errors_found |= verify_jsdoc(additional_jsdoc_check_files) |
| 312 jsdocValidatorProc = verify_jsdoc_extra(additional_jsdoc_check_files) | 317 jsdocValidatorProc, jsdocValidatorFileList = verify_jsdoc_extra(additional_jsdoc
_check_files) |
| 313 | 318 |
| 314 print 'Checking generated code in InjectedScriptCanvasModuleSource.js...' | 319 print 'Checking generated code in InjectedScriptCanvasModuleSource.js...' |
| 315 check_injected_webgl_calls_command = '%s/check_injected_webgl_calls_info.py %s %
s' % (scripts_path, webgl_rendering_context_idl_path, canvas_injected_script_sou
rce_name) | 320 check_injected_webgl_calls_command = '%s/check_injected_webgl_calls_info.py %s %
s' % (scripts_path, webgl_rendering_context_idl_path, canvas_injected_script_sou
rce_name) |
| 316 canvasModuleCompileProc = run_in_shell(check_injected_webgl_calls_command) | 321 canvasModuleCompileProc = run_in_shell(check_injected_webgl_calls_command) |
| 317 | 322 |
| 318 print 'Validating InjectedScriptSource.js...' | 323 print 'Validating InjectedScriptSource.js...' |
| 319 check_injected_script_command = '%s/check_injected_script_source.py %s' % (scrip
ts_path, injected_script_source_name) | 324 check_injected_script_command = '%s/check_injected_script_source.py %s' % (scrip
ts_path, injected_script_source_name) |
| 320 validateInjectedScriptProc = run_in_shell(check_injected_script_command) | 325 validateInjectedScriptProc = run_in_shell(check_injected_script_command) |
| 321 | 326 |
| 322 print | 327 print |
| 323 | 328 |
| 324 (jsdocValidatorOut, _) = jsdocValidatorProc.communicate() | 329 (jsdocValidatorOut, _) = jsdocValidatorProc.communicate() |
| 325 if jsdocValidatorOut: | 330 if jsdocValidatorOut: |
| 326 print ('JSDoc validator output:\n%s' % jsdocValidatorOut) | 331 print ('JSDoc validator output:\n%s' % jsdocValidatorOut) |
| 327 errors_found = True | 332 errors_found = True |
| 328 | 333 |
| 334 os.remove(jsdocValidatorFileList.name) |
| 335 |
| 329 (moduleCompileOut, _) = modular_compiler_proc.communicate() | 336 (moduleCompileOut, _) = modular_compiler_proc.communicate() |
| 330 print 'Modular compilation output:' | 337 print 'Modular compilation output:' |
| 331 | 338 |
| 332 start_module_regex = re.compile(r'^@@ START_MODULE:(.+) @@$') | 339 start_module_regex = re.compile(r'^@@ START_MODULE:(.+) @@$') |
| 333 end_module_regex = re.compile(r'^@@ END_MODULE @@$') | 340 end_module_regex = re.compile(r'^@@ END_MODULE @@$') |
| 334 | 341 |
| 335 in_module = False | 342 in_module = False |
| 336 skipped_modules = {} | 343 skipped_modules = {} |
| 337 error_count = 0 | 344 error_count = 0 |
| 338 | 345 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 398 |
| 392 if errors_found: | 399 if errors_found: |
| 393 print 'ERRORS DETECTED' | 400 print 'ERRORS DETECTED' |
| 394 | 401 |
| 395 os.remove(injectedScriptSourceTmpFile) | 402 os.remove(injectedScriptSourceTmpFile) |
| 396 os.remove(injectedScriptCanvasModuleSourceTmpFile) | 403 os.remove(injectedScriptCanvasModuleSourceTmpFile) |
| 397 os.remove(compiler_args_file.name) | 404 os.remove(compiler_args_file.name) |
| 398 os.remove(injected_script_externs_file.name) | 405 os.remove(injected_script_externs_file.name) |
| 399 os.remove(protocol_externs_file) | 406 os.remove(protocol_externs_file) |
| 400 shutil.rmtree(modules_dir, True) | 407 shutil.rmtree(modules_dir, True) |
| OLD | NEW |