Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: tools/testing/dart/test_suite.dart

Issue 9015005: Add dartc junit tests to test.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tools/testing/dart/test_runner.dart ('K') | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_suite.dart
diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart
index 8d8c6ddd29fbbde00bd5727bdbe5558b1d8b8c0c..5690004a4e36eeef3fea2c19341dc06c03d24ebe 100644
--- a/tools/testing/dart/test_suite.dart
+++ b/tools/testing/dart/test_suite.dart
@@ -771,7 +771,8 @@ class DartcCompilationTestSuite extends StandardTestSuite {
// directories?
var tempDir = new Directory('');
tempDir.createTempSync();
- return ['-check-only', '-fatal-type-errors', '-Werror', '-out', tempDir.path];
+ return ['-check-only', '-fatal-type-errors', '-Werror', '-out',
Bill Hesse 2011/12/29 18:32:24 revert this stray edit.
Bill Hesse 2011/12/30 16:04:33 Line would be too long without it.
+ tempDir.path];
}
void processDirectory() {
@@ -796,10 +797,126 @@ class DartcCompilationTestSuite extends StandardTestSuite {
}
+class JUnitTestSuite implements TestSuite {
+ Map configuration;
+ String suiteName;
+ String directoryPath;
+ String statusFilePath;
+ String dartDir;
+ String buildDir;
+ String classPath;
+ List<String> testClasses;
+ Function doTest;
+ Function doDone;
+ TestExpectations testExpectations;
+
+ JUnitTestSuite(Map this.configuration,
+ String this.suiteName,
+ String this.directoryPath,
+ String this.statusFilePath);
+
+ void isTestFile(String filename) => filename.endsWith("Tests.java") &&
+ !filename.contains('com/google/dart/compiler/vm') &&
+ !filename.contains('com/google/dart/corelib/SharedTests.java');
+
+ void forEachTest(Function onTest,
+ Map testCacheIgnored,
+ [Function onDone = null]) {
+ doTest = onTest;
+ doDone = (onDone != null) ? onDone : (() => null);
+
+ if (configuration['component'] != 'dartc') {
+ // Do nothing. Asynchronously report that the suite is enqueued.
+ new Timer((timerUnused){ doDone(); }, 0);
+ return;
+ }
+ RegExp pattern = configuration['selectors']['dartc'];
+ if (!pattern.hasMatch('junit_tests')) {
+ new Timer((timerUnused){ doDone(); }, 0);
+ return;
+ }
+
+ dartDir = new File('.').fullPathSync();
+ buildDir = TestUtils.buildDir(configuration);
+ computeClassPath();
+ testClasses = <String>[];
+ // Do not read the status file.
+ // All exclusions are hardcoded in this script, as they are in testcfg.py.
+ processDirectory();
+ }
+
+ void processDirectory() {
+ directoryPath = getDirname(directoryPath);
+ Directory dir = new Directory(directoryPath);
+
+ dir.errorHandler = (s) {
+ throw s;
+ };
+ dir.fileHandler = processFile;
+ dir.doneHandler = createTest;
+ dir.list(recursive: true);
+ }
+
+ void processFile(String filename) {
+ if (!isTestFile(filename)) return;
+
+ int index = filename.indexOf('compiler/javatests/com/google/dart');
+ if (index != -1) {
+ String testRelativePath =
+ filename.substring(index + 'compiler/javatests/'.length,
+ filename.length - '.java'.length);
+ String testClass = testRelativePath.replaceAll('/', '.');
+ testClasses.add(testClass);
+ }
+ }
+
+ void createTest(successIgnored) {
+ String d8 = '$dartDir/$buildDir/d8${TestUtils.executableSuffix}';
+ List<String> args = <String>[
+ '-ea',
+ '-classpath', classPath,
+ '-Dcom.google.dart.runner.d8=$d8',
+ '-Dcom.google.dart.corelib.SharedTests.test_py=$dartDir/tools/test.py',
+ 'org.junit.runner.JUnitCore'];
+ args.addAll(testClasses);
+
+ doTest(new TestCase(suiteName,
+ 'java',
+ args,
+ configuration,
+ (){},
+ new Set<String>.from([PASS])));
+ doDone();
+ }
+
+ void computeClassPath() {
+ List<String> jars = <String>['$buildDir/compiler/lib/dartc.jar',
+ '$buildDir/compiler/lib/corelib.jar',
+ '$buildDir/compiler-tests.jar',
+ '$buildDir/closure_out/compiler.jar'];
+ for (String jar in ['args4j/2.0.12/args4j-2.0.12.jar',
ngeoffray 2011/12/30 10:20:06 Why doing a for loop instead of just adding them t
Bill Hesse 2011/12/30 16:04:33 These are all third-party libraries, so we want to
+ 'guava/r09/guava-r09.jar',
+ 'json/r2_20080312/json.jar',
+ 'rhino/1_7R3/js.jar',
+ 'hamcrest/v1_3/hamcrest-core-1.3.0RC2.jar',
+ 'hamcrest/v1_3/hamcrest-generator-1.3.0RC2.jar',
+ 'hamcrest/v1_3/hamcrest-integration-1.3.0RC2.jar',
+ 'hamcrest/v1_3/hamcrest-library-1.3.0RC2.jar',
+ 'junit/v4_8_2/junit.jar']) {
+ jars.add('third_party/$jar');
+ }
+
+ classPath = Strings.join(jars, ':');
+ }
+}
+
+
class TestUtils {
+ static String get executableSuffix() =>
+ (new Platform().operatingSystem() == 'windows') ? '.exe' : '';
+
static String executableName(Map configuration) {
- String postfix =
- (new Platform().operatingSystem() == 'windows') ? '.exe' : '';
+ String postfix = executableSuffix;
switch (configuration['component']) {
case 'vm':
return 'dart$postfix';
« tools/testing/dart/test_runner.dart ('K') | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698