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

Side by Side 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 8 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #library("test_suite"); 5 #library("test_suite");
6 6
7 #import("status_file_parser.dart"); 7 #import("status_file_parser.dart");
8 #import("test_runner.dart"); 8 #import("test_runner.dart");
9 #import("multitest.dart"); 9 #import("multitest.dart");
10 10
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 764 }
765 } 765 }
766 766
767 String shellPath() => TestUtils.compilerPath(configuration); 767 String shellPath() => TestUtils.compilerPath(configuration);
768 768
769 List<String> additionalOptions() { 769 List<String> additionalOptions() {
770 // TODO(ager): potentially register cleanup action to delete the temporary 770 // TODO(ager): potentially register cleanup action to delete the temporary
771 // directories? 771 // directories?
772 var tempDir = new Directory(''); 772 var tempDir = new Directory('');
773 tempDir.createTempSync(); 773 tempDir.createTempSync();
774 return ['-check-only', '-fatal-type-errors', '-Werror', '-out', tempDir.path ]; 774 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.
775 tempDir.path];
775 } 776 }
776 777
777 void processDirectory() { 778 void processDirectory() {
778 directoryPath = getDirname(directoryPath); 779 directoryPath = getDirname(directoryPath);
779 // Enqueueing the directory listers is an activity. 780 // Enqueueing the directory listers is an activity.
780 activityStarted(); 781 activityStarted();
781 for (String testDir in _testDirs) { 782 for (String testDir in _testDirs) {
782 Directory dir = new Directory("$directoryPath/$testDir"); 783 Directory dir = new Directory("$directoryPath/$testDir");
783 if (dir.existsSync()) { 784 if (dir.existsSync()) {
784 activityStarted(); 785 activityStarted();
785 dir.errorHandler = (s) { 786 dir.errorHandler = (s) {
786 throw s; 787 throw s;
787 }; 788 };
788 dir.fileHandler = processFile; 789 dir.fileHandler = processFile;
789 dir.doneHandler = (ignore) => activityCompleted(); 790 dir.doneHandler = (ignore) => activityCompleted();
790 dir.list(recursive: listRecursively()); 791 dir.list(recursive: listRecursively());
791 } 792 }
792 } 793 }
793 // Completed the enqueueing of listers. 794 // Completed the enqueueing of listers.
794 activityCompleted(); 795 activityCompleted();
795 } 796 }
796 } 797 }
797 798
798 799
800 class JUnitTestSuite implements TestSuite {
801 Map configuration;
802 String suiteName;
803 String directoryPath;
804 String statusFilePath;
805 String dartDir;
806 String buildDir;
807 String classPath;
808 List<String> testClasses;
809 Function doTest;
810 Function doDone;
811 TestExpectations testExpectations;
812
813 JUnitTestSuite(Map this.configuration,
814 String this.suiteName,
815 String this.directoryPath,
816 String this.statusFilePath);
817
818 void isTestFile(String filename) => filename.endsWith("Tests.java") &&
819 !filename.contains('com/google/dart/compiler/vm') &&
820 !filename.contains('com/google/dart/corelib/SharedTests.java');
821
822 void forEachTest(Function onTest,
823 Map testCacheIgnored,
824 [Function onDone = null]) {
825 doTest = onTest;
826 doDone = (onDone != null) ? onDone : (() => null);
827
828 if (configuration['component'] != 'dartc') {
829 // Do nothing. Asynchronously report that the suite is enqueued.
830 new Timer((timerUnused){ doDone(); }, 0);
831 return;
832 }
833 RegExp pattern = configuration['selectors']['dartc'];
834 if (!pattern.hasMatch('junit_tests')) {
835 new Timer((timerUnused){ doDone(); }, 0);
836 return;
837 }
838
839 dartDir = new File('.').fullPathSync();
840 buildDir = TestUtils.buildDir(configuration);
841 computeClassPath();
842 testClasses = <String>[];
843 // Do not read the status file.
844 // All exclusions are hardcoded in this script, as they are in testcfg.py.
845 processDirectory();
846 }
847
848 void processDirectory() {
849 directoryPath = getDirname(directoryPath);
850 Directory dir = new Directory(directoryPath);
851
852 dir.errorHandler = (s) {
853 throw s;
854 };
855 dir.fileHandler = processFile;
856 dir.doneHandler = createTest;
857 dir.list(recursive: true);
858 }
859
860 void processFile(String filename) {
861 if (!isTestFile(filename)) return;
862
863 int index = filename.indexOf('compiler/javatests/com/google/dart');
864 if (index != -1) {
865 String testRelativePath =
866 filename.substring(index + 'compiler/javatests/'.length,
867 filename.length - '.java'.length);
868 String testClass = testRelativePath.replaceAll('/', '.');
869 testClasses.add(testClass);
870 }
871 }
872
873 void createTest(successIgnored) {
874 String d8 = '$dartDir/$buildDir/d8${TestUtils.executableSuffix}';
875 List<String> args = <String>[
876 '-ea',
877 '-classpath', classPath,
878 '-Dcom.google.dart.runner.d8=$d8',
879 '-Dcom.google.dart.corelib.SharedTests.test_py=$dartDir/tools/test.py',
880 'org.junit.runner.JUnitCore'];
881 args.addAll(testClasses);
882
883 doTest(new TestCase(suiteName,
884 'java',
885 args,
886 configuration,
887 (){},
888 new Set<String>.from([PASS])));
889 doDone();
890 }
891
892 void computeClassPath() {
893 List<String> jars = <String>['$buildDir/compiler/lib/dartc.jar',
894 '$buildDir/compiler/lib/corelib.jar',
895 '$buildDir/compiler-tests.jar',
896 '$buildDir/closure_out/compiler.jar'];
897 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
898 'guava/r09/guava-r09.jar',
899 'json/r2_20080312/json.jar',
900 'rhino/1_7R3/js.jar',
901 'hamcrest/v1_3/hamcrest-core-1.3.0RC2.jar',
902 'hamcrest/v1_3/hamcrest-generator-1.3.0RC2.jar',
903 'hamcrest/v1_3/hamcrest-integration-1.3.0RC2.jar',
904 'hamcrest/v1_3/hamcrest-library-1.3.0RC2.jar',
905 'junit/v4_8_2/junit.jar']) {
906 jars.add('third_party/$jar');
907 }
908
909 classPath = Strings.join(jars, ':');
910 }
911 }
912
913
799 class TestUtils { 914 class TestUtils {
915 static String get executableSuffix() =>
916 (new Platform().operatingSystem() == 'windows') ? '.exe' : '';
917
800 static String executableName(Map configuration) { 918 static String executableName(Map configuration) {
801 String postfix = 919 String postfix = executableSuffix;
802 (new Platform().operatingSystem() == 'windows') ? '.exe' : '';
803 switch (configuration['component']) { 920 switch (configuration['component']) {
804 case 'vm': 921 case 'vm':
805 return 'dart$postfix'; 922 return 'dart$postfix';
806 case 'dartc': 923 case 'dartc':
807 return 'compiler/bin/dartc_test$postfix'; 924 return 'compiler/bin/dartc_test$postfix';
808 case 'frog': 925 case 'frog':
809 case 'leg': 926 case 'leg':
810 return 'frog/bin/frog$postfix'; 927 return 'frog/bin/frog$postfix';
811 case 'frogsh': 928 case 'frogsh':
812 return 'frog/bin/frogsh$postfix'; 929 return 'frog/bin/frogsh$postfix';
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 * $noCrash tests are expected to be flaky but not crash 1044 * $noCrash tests are expected to be flaky but not crash
928 * $pass tests are expected to pass 1045 * $pass tests are expected to pass
929 * $failOk tests are expected to fail that we won't fix 1046 * $failOk tests are expected to fail that we won't fix
930 * $fail tests are expected to fail that we should fix 1047 * $fail tests are expected to fail that we should fix
931 * $crash tests are expected to crash that we should fix 1048 * $crash tests are expected to crash that we should fix
932 * $timeout tests are allowed to timeout\ 1049 * $timeout tests are allowed to timeout\
933 """; 1050 """;
934 print(report); 1051 print(report);
935 } 1052 }
936 } 1053 }
OLDNEW
« 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