| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Classes and methods for enumerating and preparing tests. | 6 * Classes and methods for enumerating and preparing tests. |
| 7 * | 7 * |
| 8 * This library includes: | 8 * This library includes: |
| 9 * | 9 * |
| 10 * - Creating tests by listing all the Dart files in certain directories, | 10 * - Creating tests by listing all the Dart files in certain directories, |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 * example3_tests.dart | 234 * example3_tests.dart |
| 235 * | 235 * |
| 236 * The important parts: | 236 * The important parts: |
| 237 * | 237 * |
| 238 * * The leaf directory name is the name of your test suite. | 238 * * The leaf directory name is the name of your test suite. |
| 239 * * The status file uses the same name. | 239 * * The status file uses the same name. |
| 240 * * Test files are directly in that directory and end in "_tests.dart". | 240 * * Test files are directly in that directory and end in "_tests.dart". |
| 241 * | 241 * |
| 242 * If you follow that convention, then you can construct one of these like: | 242 * If you follow that convention, then you can construct one of these like: |
| 243 * | 243 * |
| 244 * new DirectoryTestSuite(configuration, 'path/to/mytestsuite'); | 244 * new StandardTestSuite.forDirectory(configuration, 'path/to/mytestsuite'); |
| 245 * | 245 * |
| 246 * instead of having to create a custom [StandardTestSuite] subclass. In | 246 * instead of having to create a custom [StandardTestSuite] subclass. In |
| 247 * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] | 247 * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] |
| 248 * in test.dart, this will all be set up for you. | 248 * in test.dart, this will all be set up for you. |
| 249 */ | 249 */ |
| 250 factory StandardTestSuite.forDirectory( | 250 factory StandardTestSuite.forDirectory( |
| 251 Map configuration, String directory) { | 251 Map configuration, String directory) { |
| 252 final name = directory.substring(directory.lastIndexOf('/') + 1); | 252 final name = directory.substring(directory.lastIndexOf('/') + 1); |
| 253 | 253 |
| 254 return new StandardTestSuite(configuration, | 254 return new StandardTestSuite(configuration, |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 | 927 |
| 928 List<String> otherScripts = new List<String>(); | 928 List<String> otherScripts = new List<String>(); |
| 929 matches = otherScriptsRegExp.allMatches(contents); | 929 matches = otherScriptsRegExp.allMatches(contents); |
| 930 for (var match in matches) { | 930 for (var match in matches) { |
| 931 otherScripts.addAll(match[1].split(' ').filter((e) => e != '')); | 931 otherScripts.addAll(match[1].split(' ').filter((e) => e != '')); |
| 932 } | 932 } |
| 933 | 933 |
| 934 if (contents.contains("@compile-error")) { | 934 if (contents.contains("@compile-error")) { |
| 935 isNegative = true; | 935 isNegative = true; |
| 936 } | 936 } |
| 937 | 937 |
| 938 if (contents.contains("@runtime-error") && hasRuntime) { | 938 if (contents.contains("@runtime-error") && hasRuntime) { |
| 939 isNegative = true; | 939 isNegative = true; |
| 940 } | 940 } |
| 941 | 941 |
| 942 bool isMultitest = multiTestRegExp.hasMatch(contents); | 942 bool isMultitest = multiTestRegExp.hasMatch(contents); |
| 943 bool containsLeadingHash = leadingHashRegExp.hasMatch(contents); | 943 bool containsLeadingHash = leadingHashRegExp.hasMatch(contents); |
| 944 Match isolateMatch = isolateStubsRegExp.firstMatch(contents); | 944 Match isolateMatch = isolateStubsRegExp.firstMatch(contents); |
| 945 String isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; | 945 String isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; |
| 946 bool containsDomImport = domImportRegExp.hasMatch(contents); | 946 bool containsDomImport = domImportRegExp.hasMatch(contents); |
| 947 bool isLibraryDefinition = libraryDefinitionRegExp.hasMatch(contents); | 947 bool isLibraryDefinition = libraryDefinitionRegExp.hasMatch(contents); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 dir.onDone = (ignore) => activityCompleted(); | 1015 dir.onDone = (ignore) => activityCompleted(); |
| 1016 dir.list(recursive: listRecursively()); | 1016 dir.list(recursive: listRecursively()); |
| 1017 } | 1017 } |
| 1018 } | 1018 } |
| 1019 // Completed the enqueueing of listers. | 1019 // Completed the enqueueing of listers. |
| 1020 activityCompleted(); | 1020 activityCompleted(); |
| 1021 } | 1021 } |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 | 1024 |
| 1025 /** | |
| 1026 * A standard test suite whose file organization matches an expected structure. | |
| 1027 * To use this, your suite should look like: | |
| 1028 * | |
| 1029 * dart/ | |
| 1030 * path/ | |
| 1031 * to/ | |
| 1032 * mytestsuite/ | |
| 1033 * mytestsuite.status | |
| 1034 * example1_tests.dart | |
| 1035 * example2_tests.dart | |
| 1036 * example3_tests.dart | |
| 1037 * | |
| 1038 * The important parts: | |
| 1039 * | |
| 1040 * * The leaf directory name is the name of your test suite. | |
| 1041 * * The status file uses the same name. | |
| 1042 * * Test files are directly in that directory and end in "_tests.dart". | |
| 1043 * | |
| 1044 * If you follow that convention, then you can construct one of these like: | |
| 1045 * | |
| 1046 * new DirectoryTestSuite(configuration, 'path/to/mytestsuite'); | |
| 1047 * | |
| 1048 * instead of having to create a custom [StandardTestSuite] subclass. In | |
| 1049 * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] in | |
| 1050 * test.dart, this will all be set up for you. | |
| 1051 */ | |
| 1052 class DirectoryTestSuite extends StandardTestSuite { | |
| 1053 factory DirectoryTestSuite(Map configuration, String directory) { | |
| 1054 final name = directory.substring(directory.lastIndexOf('/') + 1); | |
| 1055 print(name); | |
| 1056 | |
| 1057 return new DirectoryTestSuite._internal(configuration, | |
| 1058 name, directory, ['$directory/$name.status']); | |
| 1059 } | |
| 1060 | |
| 1061 DirectoryTestSuite._internal(Map configuration, | |
| 1062 String suiteName, | |
| 1063 String directoryPath, | |
| 1064 List<String> statusFilePaths) | |
| 1065 : super(configuration, suiteName, directoryPath, statusFilePaths); | |
| 1066 | |
| 1067 bool isTestFile(String filename) => filename.endsWith('_tests.dart'); | |
| 1068 } | |
| 1069 | |
| 1070 | |
| 1071 class JUnitTestSuite implements TestSuite { | 1025 class JUnitTestSuite implements TestSuite { |
| 1072 Map configuration; | 1026 Map configuration; |
| 1073 String suiteName; | 1027 String suiteName; |
| 1074 String directoryPath; | 1028 String directoryPath; |
| 1075 String statusFilePath; | 1029 String statusFilePath; |
| 1076 final String dartDir; | 1030 final String dartDir; |
| 1077 String buildDir; | 1031 String buildDir; |
| 1078 String classPath; | 1032 String classPath; |
| 1079 List<String> testClasses; | 1033 List<String> testClasses; |
| 1080 Function doTest; | 1034 Function doTest; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 * $noCrash tests are expected to be flaky but not crash | 1337 * $noCrash tests are expected to be flaky but not crash |
| 1384 * $pass tests are expected to pass | 1338 * $pass tests are expected to pass |
| 1385 * $failOk tests are expected to fail that we won't fix | 1339 * $failOk tests are expected to fail that we won't fix |
| 1386 * $fail tests are expected to fail that we should fix | 1340 * $fail tests are expected to fail that we should fix |
| 1387 * $crash tests are expected to crash that we should fix | 1341 * $crash tests are expected to crash that we should fix |
| 1388 * $timeout tests are allowed to timeout | 1342 * $timeout tests are allowed to timeout |
| 1389 """; | 1343 """; |
| 1390 print(report); | 1344 print(report); |
| 1391 } | 1345 } |
| 1392 } | 1346 } |
| OLD | NEW |