OLD | NEW |
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 # | 4 # |
5 | 5 |
6 import os | 6 import os |
7 import platform | 7 import platform |
8 import re | 8 import re |
9 import shutil | 9 import shutil |
10 import subprocess | 10 import subprocess |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 def GetHtmlName(self): | 344 def GetHtmlName(self): |
345 """Returns the name of the output .html file to create.""" | 345 """Returns the name of the output .html file to create.""" |
346 relpath = os.path.relpath(self.test, self.root_path) | 346 relpath = os.path.relpath(self.test, self.root_path) |
347 return relpath.replace(os.sep, '_') + '.html' | 347 return relpath.replace(os.sep, '_') + '.html' |
348 | 348 |
349 def GetCompileCommand(self, fatal_static_type_errors=False): | 349 def GetCompileCommand(self, fatal_static_type_errors=False): |
350 """Returns cmdline as an array to invoke the compiler on this test.""" | 350 """Returns cmdline as an array to invoke the compiler on this test.""" |
351 | 351 |
352 # We need an absolute path because the compilation will run | 352 # We need an absolute path because the compilation will run |
353 # in a temporary directory. | 353 # in a temporary directory. |
354 build_root = utils.GetBuildRoot(OS_GUESS, self.mode, 'dartc') | 354 build_root = utils.GetBuildRoot(OS_GUESS, self.mode, 'ia32') |
355 dartc = os.path.abspath(os.path.join(build_root, 'compiler', 'bin', | 355 dartc = os.path.abspath(os.path.join(build_root, 'compiler', 'bin', |
356 'dartc')) | 356 'dartc')) |
357 if utils.IsWindows(): dartc += '.exe' | 357 if utils.IsWindows(): dartc += '.exe' |
358 cmd = [dartc, '--work', self.temp_dir] | 358 cmd = [dartc, '--work', self.temp_dir] |
359 if self.mode == 'release': | 359 if self.mode == 'release': |
360 cmd += ['--optimize'] | 360 cmd += ['--optimize'] |
361 cmd += self.vm_options | 361 cmd += self.vm_options |
362 cmd += ['--out', self.GetScriptPath()] | 362 cmd += ['--out', self.GetScriptPath()] |
363 if fatal_static_type_errors: | 363 if fatal_static_type_errors: |
364 # TODO(zundel): update to --fatal_type_errors for both VM and Compiler | 364 # TODO(zundel): update to --fatal_type_errors for both VM and Compiler |
(...skipping 29 matching lines...) Expand all Loading... |
394 return 0 | 394 return 0 |
395 | 395 |
396 | 396 |
397 class StandaloneArchitecture(Architecture): | 397 class StandaloneArchitecture(Architecture): |
398 """Base class for architectures that run tests without a browser.""" | 398 """Base class for architectures that run tests without a browser.""" |
399 | 399 |
400 def __init__(self, root_path, arch, mode, component, test): | 400 def __init__(self, root_path, arch, mode, component, test): |
401 super(StandaloneArchitecture, self).__init__(root_path, arch, mode, componen
t, | 401 super(StandaloneArchitecture, self).__init__(root_path, arch, mode, componen
t, |
402 test) | 402 test) |
403 | 403 |
| 404 def GetExecutable(self): |
| 405 """Returns the path to the Dart test runner (executes the .dart file).""" |
| 406 return utils.GetDart(self.mode, self.arch, self.component) |
| 407 |
| 408 |
404 def GetCompileCommand(self, fatal_static_type_errors=False): | 409 def GetCompileCommand(self, fatal_static_type_errors=False): |
405 fatal_static_type_errors = fatal_static_type_errors # shutup lint! | 410 fatal_static_type_errors = fatal_static_type_errors # shutup lint! |
406 return None | 411 return None |
407 | 412 |
408 def GetRunCommand(self, fatal_static_type_errors=False): | 413 def GetRunCommand(self, fatal_static_type_errors=False): |
409 """Returns a command line to execute for the test.""" | 414 """Returns a command line to execute for the test.""" |
410 dart = self.GetExecutable() | 415 dart = self.GetExecutable() |
411 test_name = os.path.basename(self.test) | 416 test_name = os.path.basename(self.test) |
412 test_path = os.path.abspath(self.test) | 417 test_path = os.path.abspath(self.test) |
413 command = [dart] + self.vm_options | 418 command = [dart] + self.vm_options |
(...skipping 25 matching lines...) Expand all Loading... |
439 | 444 |
440 | 445 |
441 # Long term, we should do the running machinery that is currently in | 446 # Long term, we should do the running machinery that is currently in |
442 # DartRunner.java | 447 # DartRunner.java |
443 class DartcArchitecture(StandaloneArchitecture): | 448 class DartcArchitecture(StandaloneArchitecture): |
444 """Runs the Dart ->JS compiler then runs the result in a standalone JS VM.""" | 449 """Runs the Dart ->JS compiler then runs the result in a standalone JS VM.""" |
445 | 450 |
446 def __init__(self, root_path, arch, mode, component, test): | 451 def __init__(self, root_path, arch, mode, component, test): |
447 super(DartcArchitecture, self).__init__(root_path, arch, mode, component, te
st) | 452 super(DartcArchitecture, self).__init__(root_path, arch, mode, component, te
st) |
448 | 453 |
449 def GetExecutable(self): | |
450 """Returns the name of the executable to run the test.""" | |
451 return os.path.abspath(os.path.join(self.build_root, | |
452 'compiler', | |
453 'bin', | |
454 'dartc_test')) | |
455 | |
456 def GetFatalTypeErrorsFlags(self): | 454 def GetFatalTypeErrorsFlags(self): |
457 return ['--fatal-type-errors'] | 455 return ['--fatal-type-errors'] |
458 | 456 |
459 def HasFatalTypeErrors(self): | 457 def HasFatalTypeErrors(self): |
460 return True | 458 return True |
461 | 459 |
462 def GetRunCommand(self, fatal_static_type_errors=False): | 460 def GetRunCommand(self, fatal_static_type_errors=False): |
463 """Returns a command line to execute for the test.""" | 461 """Returns a command line to execute for the test.""" |
464 cmd = super(DartcArchitecture, self).GetRunCommand( | 462 cmd = super(DartcArchitecture, self).GetRunCommand( |
465 fatal_static_type_errors) | 463 fatal_static_type_errors) |
466 return cmd | 464 return cmd |
467 | 465 |
468 | 466 |
469 class RuntimeArchitecture(StandaloneArchitecture): | |
470 """Executes tests on the standalone VM (runtime).""" | |
471 | |
472 def __init__(self, root_path, arch, mode, component, test): | |
473 super(RuntimeArchitecture, self).__init__(root_path, arch, mode, component, | |
474 test) | |
475 | |
476 def GetExecutable(self): | |
477 """Returns the name of the executable to run the test.""" | |
478 return os.path.abspath(os.path.join(self.build_root, 'dart_bin')) | |
479 | |
480 | |
481 def ExecutePipedCommand(cmd, verbose): | 467 def ExecutePipedCommand(cmd, verbose): |
482 """Execute a command in a subprocess.""" | 468 """Execute a command in a subprocess.""" |
483 if verbose: | 469 if verbose: |
484 print 'Executing: ' + ' '.join(cmd) | 470 print 'Executing: ' + ' '.join(cmd) |
485 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 471 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
486 (output, err) = pipe.communicate() | 472 (output, err) = pipe.communicate() |
487 if pipe.returncode != 0 and verbose: | 473 if pipe.returncode != 0 and verbose: |
488 print 'Execution failed: ' + output + '\n' + err | 474 print 'Execution failed: ' + output + '\n' + err |
489 print output | 475 print output |
490 print err | 476 print err |
491 return pipe.returncode, output, err | 477 return pipe.returncode, output, err |
492 | 478 |
493 | 479 |
494 def ExecuteCommand(cmd, verbose=False): | 480 def ExecuteCommand(cmd, verbose=False): |
495 """Execute a command in a subprocess.""" | 481 """Execute a command in a subprocess.""" |
496 if verbose: print 'Executing: ' + ' '.join(cmd) | 482 if verbose: print 'Executing: ' + ' '.join(cmd) |
497 return subprocess.call(cmd) | 483 return subprocess.call(cmd) |
498 | 484 |
499 | 485 |
500 def GetArchitecture(arch, mode, component, test): | 486 def GetArchitecture(arch, mode, component, test): |
501 root_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) | 487 root_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) |
502 if component == 'chromium': | 488 if component == 'chromium': |
503 return ChromiumArchitecture(root_path, arch, mode, component, test) | 489 return ChromiumArchitecture(root_path, arch, mode, component, test) |
504 | 490 |
505 elif component == 'dartium': | 491 elif component == 'dartium': |
506 return DartiumArchitecture(root_path, arch, mode, component, test) | 492 return DartiumArchitecture(root_path, arch, mode, component, test) |
507 | 493 |
508 elif component == 'vm': | 494 elif component in ['vm', 'frog', 'frogsh']: |
509 return RuntimeArchitecture(root_path, arch, mode, component, test) | 495 return StandaloneArchitecture(root_path, arch, mode, component, test) |
510 | 496 |
511 elif component == 'dartc': | 497 elif component == 'dartc': |
512 return DartcArchitecture(root_path, arch, mode, component, test) | 498 return DartcArchitecture(root_path, arch, mode, component, test) |
OLD | NEW |