| 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 import os | 5 import os |
| 6 from os.path import join, exists | 6 from os.path import join, exists |
| 7 | 7 |
| 8 import test | 8 import test |
| 9 from testing import test_runner | 9 from testing import test_runner |
| 10 | 10 |
| 11 class VmTestCase(test.TestCase): | 11 class VmTestCase(test.TestCase): |
| 12 def __init__(self, path, context, mode, arch, flags): | 12 def __init__(self, path, context, mode, arch, flags): |
| 13 super(VmTestCase, self).__init__(context, path) | 13 super(VmTestCase, self).__init__(context, path) |
| 14 self.mode = mode | 14 self.mode = mode |
| 15 self.arch = arch | 15 self.arch = arch |
| 16 self.flags = flags | 16 self.flags = flags |
| 17 | 17 |
| 18 def IsNegative(self): | 18 def IsNegative(self): |
| 19 # TODO(kasperl): Figure out how to support negative tests. Maybe | 19 # TODO(kasperl): Figure out how to support negative tests. Maybe |
| 20 # just have a TEST_CASE_NEGATIVE macro? | 20 # just have a TEST_CASE_NEGATIVE macro? |
| 21 return False | 21 return False |
| 22 | 22 |
| 23 def GetLabel(self): | 23 def GetLabel(self): |
| 24 return "%s %s" % ( | 24 return '%s%s vm %s' % (self.mode, self.arch, '/'.join(self.path)) |
| 25 self.context.GetBuildConf(self.mode, self.arch), | |
| 26 '/'.join(self.path)) | |
| 27 | 25 |
| 28 def GetCommand(self): | 26 def GetCommand(self): |
| 29 command = self.context.GetRunTests(self.mode, self.arch) | 27 command = self.context.GetRunTests(self.mode, self.arch) |
| 30 command += [ self.GetName() ] | 28 command += [ self.GetName() ] |
| 31 # Add flags being set in the context. | 29 # Add flags being set in the context. |
| 32 for flag in self.context.flags: | 30 for flag in self.context.flags: |
| 33 command.append(flag) | 31 command.append(flag) |
| 34 if self.flags: command += self.flags | 32 if self.flags: command += self.flags |
| 35 return command | 33 return command |
| 36 | 34 |
| 37 def GetName(self): | 35 def GetName(self): |
| 38 return self.path[-1] | 36 return self.path[-1] |
| 39 | 37 |
| 40 | 38 |
| 41 class VmTestConfiguration(test.TestConfiguration): | 39 class VmTestConfiguration(test.TestConfiguration): |
| 42 def __init__(self, context, root): | 40 def __init__(self, context, root): |
| 43 super(VmTestConfiguration, self).__init__(context, root) | 41 super(VmTestConfiguration, self).__init__(context, root) |
| 44 | 42 |
| 45 def ListTests(self, current_path, path, mode, arch): | 43 def ListTests(self, current_path, path, mode, arch, component): |
| 46 if not arch in ['ia32', 'x64', 'arm', 'simarm']: | 44 if component != 'vm': return [] |
| 47 return [] | |
| 48 run_tests = self.context.GetRunTests(mode, arch) | 45 run_tests = self.context.GetRunTests(mode, arch) |
| 49 output = test_runner.Execute(run_tests + ['--list'], self.context) | 46 output = test_runner.Execute(run_tests + ['--list'], self.context) |
| 50 if output.exit_code != 0: | 47 if output.exit_code != 0: |
| 51 print output.stdout | 48 print output.stdout |
| 52 print output.stderr | 49 print output.stderr |
| 53 return [ ] | 50 return [ ] |
| 54 tests = [ ] | 51 tests = [ ] |
| 55 for test_line in output.stdout.strip().split('\n'): | 52 for test_line in output.stdout.strip().split('\n'): |
| 56 name_and_flags = test_line.split() | 53 name_and_flags = test_line.split() |
| 57 name = name_and_flags[0] | 54 name = name_and_flags[0] |
| 58 flags = name_and_flags[1:] | 55 flags = name_and_flags[1:] |
| 59 test_path = current_path + [name] | 56 test_path = current_path + [name] |
| 60 if self.Contains(path, test_path): | 57 if self.Contains(path, test_path): |
| 61 tests.append(VmTestCase(test_path, self.context, mode, arch, flags)) | 58 tests.append(VmTestCase(test_path, self.context, mode, arch, flags)) |
| 62 return tests | 59 return tests |
| 63 | 60 |
| 64 def GetTestStatus(self, sections, defs): | 61 def GetTestStatus(self, sections, defs): |
| 65 status = join(self.root, 'vm.status') | 62 status = join(self.root, 'vm.status') |
| 66 if exists(status): test.ReadConfigurationInto(status, sections, defs) | 63 if exists(status): test.ReadConfigurationInto(status, sections, defs) |
| 67 | 64 |
| 68 | 65 |
| 69 def GetConfiguration(context, root): | 66 def GetConfiguration(context, root): |
| 70 return VmTestConfiguration(context, root) | 67 return VmTestConfiguration(context, root) |
| OLD | NEW |