| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 403 |
| 404 def GetExecutable(self): | 404 def GetExecutable(self): |
| 405 """Returns the path to the Dart test runner (executes the .dart file).""" | 405 """Returns the path to the Dart test runner (executes the .dart file).""" |
| 406 return utils.GetDartRunner(self.mode, self.arch, self.component) | 406 return utils.GetDartRunner(self.mode, self.arch, self.component) |
| 407 | 407 |
| 408 | 408 |
| 409 def GetCompileCommand(self, fatal_static_type_errors=False): | 409 def GetCompileCommand(self, fatal_static_type_errors=False): |
| 410 fatal_static_type_errors = fatal_static_type_errors # shutup lint! | 410 fatal_static_type_errors = fatal_static_type_errors # shutup lint! |
| 411 return None | 411 return None |
| 412 | 412 |
| 413 def GetOptions(self): |
| 414 return [] |
| 415 |
| 413 def GetRunCommand(self, fatal_static_type_errors=False): | 416 def GetRunCommand(self, fatal_static_type_errors=False): |
| 414 """Returns a command line to execute for the test.""" | 417 """Returns a command line to execute for the test.""" |
| 415 dart = self.GetExecutable() | 418 dart = self.GetExecutable() |
| 416 test_name = os.path.basename(self.test) | 419 command = [dart] + self.GetOptions() + self.vm_options |
| 417 test_path = os.path.abspath(self.test) | 420 if fatal_static_type_errors: |
| 418 command = [dart] + self.vm_options | 421 command += self.GetFatalTypeErrorsFlags() |
| 419 if self.mode == 'release': | 422 |
| 420 command += ['--optimize'] | |
| 421 (classname, extension) = os.path.splitext(test_name) | |
| 422 if self.dart_options: | 423 if self.dart_options: |
| 423 command += self.dart_options | 424 command += self.dart_options |
| 424 elif extension == '.dart': | |
| 425 if fatal_static_type_errors: | |
| 426 command += self.GetFatalTypeErrorsFlags() | |
| 427 if '_' in classname: | |
| 428 (classname, unused_sep, unused_tag) = classname.rpartition('_') | |
| 429 command += [test_path] | |
| 430 else: | 425 else: |
| 431 command += ['--', test_path] | 426 command += [self.test] |
| 432 | 427 |
| 433 return command | 428 return command |
| 434 | 429 |
| 435 def GetFatalTypeErrorsFlags(self): | 430 def GetFatalTypeErrorsFlags(self): |
| 436 return [] | 431 return [] |
| 437 | 432 |
| 438 def RunTest(self, verbose): | 433 def RunTest(self, verbose): |
| 439 command = self.GetRunCommand() | 434 command = self.GetRunCommand() |
| 440 return ExecuteCommand(command, verbose) | 435 return ExecuteCommand(command, verbose) |
| 441 | 436 |
| 442 def Cleanup(self): | 437 def Cleanup(self): |
| 443 return | 438 return |
| 444 | 439 |
| 445 | 440 |
| 441 class LegArchitecture(StandaloneArchitecture): |
| 442 |
| 443 def __init__(self, root_path, arch, mode, component, test): |
| 444 super(LegArchitecture, self).__init__(root_path, arch, mode, component, |
| 445 test) |
| 446 def GetOptions(self): |
| 447 return ['--enable_leg'] |
| 448 |
| 449 def GetExecutable(self): |
| 450 """Returns the path to the Dart test runner (executes the .dart file).""" |
| 451 return utils.GetDartRunner(self.mode, self.arch, 'frog') |
| 452 |
| 453 |
| 446 # Long term, we should do the running machinery that is currently in | 454 # Long term, we should do the running machinery that is currently in |
| 447 # DartRunner.java | 455 # DartRunner.java |
| 448 class DartcArchitecture(StandaloneArchitecture): | 456 class DartcArchitecture(StandaloneArchitecture): |
| 449 """Runs the Dart ->JS compiler then runs the result in a standalone JS VM.""" | 457 """Runs the Dart ->JS compiler then runs the result in a standalone JS VM.""" |
| 450 | 458 |
| 451 def __init__(self, root_path, arch, mode, component, test): | 459 def __init__(self, root_path, arch, mode, component, test): |
| 452 super(DartcArchitecture, self).__init__(root_path, arch, mode, component, te
st) | 460 super(DartcArchitecture, self).__init__(root_path, arch, mode, component, te
st) |
| 453 | 461 |
| 462 def GetOptions(self): |
| 463 if self.mode == 'release': return ['--optimize'] |
| 464 return [] |
| 465 |
| 454 def GetFatalTypeErrorsFlags(self): | 466 def GetFatalTypeErrorsFlags(self): |
| 455 return ['--fatal-type-errors'] | 467 return ['--fatal-type-errors'] |
| 456 | 468 |
| 457 def HasFatalTypeErrors(self): | 469 def HasFatalTypeErrors(self): |
| 458 return True | 470 return True |
| 459 | 471 |
| 460 def GetRunCommand(self, fatal_static_type_errors=False): | |
| 461 """Returns a command line to execute for the test.""" | |
| 462 cmd = super(DartcArchitecture, self).GetRunCommand( | |
| 463 fatal_static_type_errors) | |
| 464 return cmd | |
| 465 | |
| 466 | 472 |
| 467 def ExecutePipedCommand(cmd, verbose): | 473 def ExecutePipedCommand(cmd, verbose): |
| 468 """Execute a command in a subprocess.""" | 474 """Execute a command in a subprocess.""" |
| 469 if verbose: | 475 if verbose: |
| 470 print 'Executing: ' + ' '.join(cmd) | 476 print 'Executing: ' + ' '.join(cmd) |
| 471 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 477 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 472 (output, err) = pipe.communicate() | 478 (output, err) = pipe.communicate() |
| 473 if pipe.returncode != 0 and verbose: | 479 if pipe.returncode != 0 and verbose: |
| 474 print 'Execution failed: ' + output + '\n' + err | 480 print 'Execution failed: ' + output + '\n' + err |
| 475 print output | 481 print output |
| (...skipping 11 matching lines...) Expand all Loading... |
| 487 root_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) | 493 root_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) |
| 488 if component == 'chromium': | 494 if component == 'chromium': |
| 489 return ChromiumArchitecture(root_path, arch, mode, component, test) | 495 return ChromiumArchitecture(root_path, arch, mode, component, test) |
| 490 | 496 |
| 491 elif component == 'dartium': | 497 elif component == 'dartium': |
| 492 return DartiumArchitecture(root_path, arch, mode, component, test) | 498 return DartiumArchitecture(root_path, arch, mode, component, test) |
| 493 | 499 |
| 494 elif component in ['vm', 'frog', 'frogsh']: | 500 elif component in ['vm', 'frog', 'frogsh']: |
| 495 return StandaloneArchitecture(root_path, arch, mode, component, test) | 501 return StandaloneArchitecture(root_path, arch, mode, component, test) |
| 496 | 502 |
| 503 elif component == 'leg': |
| 504 return LegArchitecture(root_path, arch, mode, component, test) |
| 505 |
| 497 elif component == 'dartc': | 506 elif component == 'dartc': |
| 498 return DartcArchitecture(root_path, arch, mode, component, test) | 507 return DartcArchitecture(root_path, arch, mode, component, test) |
| OLD | NEW |