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