| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 3 # for details. All rights reserved. Use of this source code is governed by a | |
| 4 # BSD-style license that can be found in the LICENSE file. | |
| 5 | |
| 6 import os | |
| 7 from os.path import join, exists | |
| 8 import re | |
| 9 | |
| 10 import test | |
| 11 import utils | |
| 12 | |
| 13 | |
| 14 | |
| 15 class JUnitTestCase(test.TestCase): | |
| 16 def __init__(self, path, context, classnames, mode, arch): | |
| 17 super(JUnitTestCase, self).__init__(context, path) | |
| 18 self.classnames = classnames | |
| 19 self.mode = mode | |
| 20 self.arch = arch | |
| 21 | |
| 22 def IsBatchable(self): | |
| 23 return False | |
| 24 | |
| 25 def IsNegative(self): | |
| 26 return False | |
| 27 | |
| 28 def GetLabel(self): | |
| 29 return "%s/%s %s" % (self.mode, self.arch, '/'.join(self.path)) | |
| 30 | |
| 31 def GetClassPath(self): | |
| 32 third_party = join(self.context.workspace, 'third_party') | |
| 33 jars = ['args4j/2.0.12/args4j-2.0.12.jar', | |
| 34 'guava/r09/guava-r09.jar', | |
| 35 'json/r2_20080312/json.jar', | |
| 36 'rhino/1_7R3/js.jar', | |
| 37 'hamcrest/v1_3/hamcrest-core-1.3.0RC2.jar', | |
| 38 'hamcrest/v1_3/hamcrest-generator-1.3.0RC2.jar', | |
| 39 'hamcrest/v1_3/hamcrest-integration-1.3.0RC2.jar', | |
| 40 'hamcrest/v1_3/hamcrest-library-1.3.0RC2.jar', | |
| 41 'junit/v4_8_2/junit.jar'] | |
| 42 jars = [ join(third_party, jar) for jar in jars ] | |
| 43 buildroot = utils.GetBuildRoot(self.context.os, self.mode, self.arch) | |
| 44 dartc_classes = [ os.path.join(buildroot, 'compiler', 'lib', 'dartc.jar'), | |
| 45 os.path.join(buildroot, 'compiler', 'lib', 'corelib.jar')
] | |
| 46 test_classes = os.path.join(buildroot, 'compiler-tests.jar') | |
| 47 closure_jar = os.path.sep.join([buildroot, 'closure_out', 'compiler.jar']) | |
| 48 return os.path.pathsep.join( | |
| 49 dartc_classes + [test_classes] + [closure_jar] + jars) | |
| 50 | |
| 51 def GetCommand(self): | |
| 52 test_py = join(join(self.context.workspace, 'tools'), 'test.py') | |
| 53 d8 = self.context.GetD8(self.mode, self.arch) | |
| 54 # Note that it is important to run all the JUnit tests in the same process. | |
| 55 # This way we have a chance of causing problems with static state early. | |
| 56 return ['java', '-ea', '-classpath', self.GetClassPath(), | |
| 57 '-Dcom.google.dart.runner.d8=' + d8, | |
| 58 '-Dcom.google.dart.corelib.SharedTests.test_py=' + test_py, | |
| 59 'org.junit.runner.JUnitCore'] + self.classnames | |
| 60 | |
| 61 def GetName(self): | |
| 62 return self.path[-1] | |
| 63 | |
| 64 | |
| 65 class JUnitTestConfiguration(test.TestConfiguration): | |
| 66 def __init__(self, context, root): | |
| 67 super(JUnitTestConfiguration, self).__init__(context, root) | |
| 68 | |
| 69 def ListTests(self, current_path, path, mode, arch, component): | |
| 70 test_path = current_path + ['junit_tests'] | |
| 71 if not self.Contains(path, test_path): | |
| 72 return [] | |
| 73 classes = [] | |
| 74 javatests_path = join(join(join(self.root, '..'), '..'), 'javatests') | |
| 75 javatests_path = os.path.normpath(javatests_path) | |
| 76 for root, dirs, files in os.walk(javatests_path): | |
| 77 if root.endswith('com/google/dart/compiler/vm'): | |
| 78 continue | |
| 79 for f in [x for x in files if self.IsTest(x)]: | |
| 80 classname = [] | |
| 81 classname.extend(root[len(javatests_path) + 1:].split(os.path.sep)) | |
| 82 classname.append(f[:-5]) # Remove .java suffix. | |
| 83 classname = '.'.join(classname) | |
| 84 if classname == 'com.google.dart.corelib.SharedTests': | |
| 85 continue | |
| 86 classes.append(classname) | |
| 87 return [JUnitTestCase(test_path, self.context, classes, mode, arch)] | |
| 88 | |
| 89 def IsTest(self, name): | |
| 90 return name.endswith('Tests.java') | |
| 91 | |
| 92 def GetTestStatus(self, sections, defs): | |
| 93 status = join(self.root, 'dartc.status') | |
| 94 if exists(status): | |
| 95 test.ReadConfigurationInto(status, sections, defs) | |
| 96 | |
| 97 | |
| 98 def GetConfiguration(context, root): | |
| 99 return JUnitTestConfiguration(context, root) | |
| OLD | NEW |