| OLD | NEW |
| 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("corelib_test_config"); | 5 #library("co19_test_config"); |
| 6 | 6 |
| 7 #import("../../tools/testing/dart/test_runner.dart"); | 7 #import("../../tools/testing/dart/test_runner.dart"); |
| 8 #import("../../tools/testing/dart/status_file_parser.dart"); | 8 #import("../../tools/testing/dart/status_file_parser.dart"); |
| 9 | 9 |
| 10 class CorelibTestSuite { | 10 class Co19TestSuite { |
| 11 String directoryPath = "tests/corelib/src"; | 11 String directoryPath = "tests/co19/src"; |
| 12 final String statusFilePath = "tests/corelib/corelib.status"; | |
| 13 Function doTest; | 12 Function doTest; |
| 14 Function doDone; | 13 Function doDone; |
| 15 String shellPath; | 14 String shellPath; |
| 16 String pathSeparator; | 15 String pathSeparator; |
| 17 Map configuration; | 16 Map configuration; |
| 18 TestExpectationsMap testExpectationsMap; | 17 TestExpectations testExpectations; |
| 18 RegExp testRegExp; |
| 19 | 19 |
| 20 CorelibTestSuite(Map this.configuration) { | 20 Co19TestSuite(Map this.configuration) { |
| 21 shellPath = getDartShellFileName(configuration) ; | 21 shellPath = getDartShellFileName(configuration) ; |
| 22 pathSeparator = new Platform().pathSeparator(); | 22 pathSeparator = new Platform().pathSeparator(); |
| 23 testRegExp = new RegExp(@"t[0-9]{2}.dart$"); |
| 23 } | 24 } |
| 24 | 25 |
| 25 void forEachTest(Function onTest, [Function onDone = null]) { | 26 void forEachTest(Function onTest, [Function onDone = null]) { |
| 26 doTest = onTest; | 27 doTest = onTest; |
| 27 doDone = (ignore) => onDone(); | 28 doDone = (ignore) => onDone(); |
| 28 | 29 |
| 29 // Read test expectations from status file. | 30 // Read test expectations from status file. |
| 30 testExpectationsMap = ReadTestExpectations(statusFilePath, configuration); | 31 testExpectations = new TestExpectations(complexMatching: true); |
| 32 ReadTestExpectationsInto(testExpectations, |
| 33 "tests/co19/co19-compiler.status", |
| 34 configuration); |
| 35 ReadTestExpectationsInto(testExpectations, |
| 36 "tests/co19/co19-frog.status", |
| 37 configuration); |
| 38 ReadTestExpectationsInto(testExpectations, |
| 39 "tests/co19/co19-runtime.status", |
| 40 configuration); |
| 31 | 41 |
| 32 processDirectory(); | 42 processDirectory(directoryPath); |
| 33 } | 43 } |
| 34 | 44 |
| 35 void processDirectory() { | 45 void processDirectory(String path) { |
| 36 directoryPath = getDirname(directoryPath); | 46 path = getDirname(path); |
| 37 Directory dir = new Directory(directoryPath); | 47 Directory dir = new Directory(path); |
| 38 dir.errorHandler = (s) { | 48 dir.errorHandler = (s) { |
| 39 throw s; | 49 throw s; |
| 40 }; | 50 }; |
| 41 dir.fileHandler = processFile; | 51 dir.fileHandler = processFile; |
| 42 dir.doneHandler = doDone; | 52 dir.doneHandler = doDone; |
| 43 dir.list(false); | 53 dir.list(recursive: true); |
| 44 } | 54 } |
| 45 | 55 |
| 46 void processFile(String filename) { | 56 void processFile(String filename) { |
| 47 if (!filename.endsWith("Test.dart")) return; | 57 if (!testRegExp.hasMatch(filename)) return; |
| 48 | 58 |
| 49 // If patterns are given only list the files that match one of the | 59 // If patterns are given only list the files that match one of the |
| 50 // patterns. | 60 // patterns. |
| 51 var patterns = configuration['patterns']; | 61 var patterns = configuration['patterns']; |
| 52 if (!patterns.isEmpty() && | 62 if (!patterns.isEmpty() && |
| 53 !patterns.some((re) => re.hasMatch(filename))) { | 63 !patterns.some((re) => re.hasMatch(filename))) { |
| 54 return; | 64 return; |
| 55 } | 65 } |
| 56 | 66 |
| 57 int start = filename.lastIndexOf(pathSeparator); | 67 int start = filename.lastIndexOf('src' + pathSeparator); |
| 58 String testName = filename.substring(start + 1, filename.length - 5); | 68 String testName = filename.substring(start + 4, filename.length - 5); |
| 59 Set<String> expectations = testExpectationsMap.expectations(testName); | 69 Set<String> expectations = testExpectations.expectations(testName); |
| 60 | 70 |
| 61 // TODO(whesse): Skip files with internal directives, and multipart files, | |
| 62 // until they are handled correctly. | |
| 63 if (expectations.contains(SKIP)) return; | 71 if (expectations.contains(SKIP)) return; |
| 64 | 72 |
| 65 List args = ["--ignore-unrecognized-flags"]; | 73 List args = ["--ignore-unrecognized-flags"]; |
| 66 if (configuration["checked"]) { | 74 if (configuration["checked"]) { |
| 67 args.add("--enable_type_checks"); | 75 args.add("--enable_type_checks"); |
| 68 } | 76 } |
| 69 if (configuration["component"] == "leg") { | 77 if (configuration["component"] == "leg") { |
| 70 args.add("--enable_leg"); | 78 args.add("--enable_leg"); |
| 71 } | 79 } |
| 72 | 80 |
| 73 var optionsFromFile = testOptions(filename); | 81 var optionsFromFile = testOptions(filename); |
| 74 List<List<String>> optionsList = optionsFromFile["vmOptions"]; | 82 List<List<String>> optionsList = optionsFromFile["vmOptions"]; |
| 75 List<String> dartOptions = optionsFromFile["dartOptions"]; | 83 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 76 args.addAll(dartOptions == null ? [filename] : dartOptions); | 84 args.addAll(dartOptions == null ? [filename] : dartOptions); |
| 85 var isNegative = optionsFromFile["isNegative"]; |
| 77 | 86 |
| 78 if (optionsList.isEmpty()) { | 87 if (optionsList.isEmpty()) { |
| 79 doTest(new TestCase(testName, | 88 doTest(new TestCase(testName, |
| 80 shellPath, | 89 shellPath, |
| 81 args, | 90 args, |
| 82 configuration["timeout"], | 91 configuration["timeout"], |
| 83 completeHandler, | 92 completeHandler, |
| 84 expectations)); | 93 expectations, |
| 94 isNegative)); |
| 85 } else { | 95 } else { |
| 86 for (var options in optionsList) { | 96 for (var options in optionsList) { |
| 87 options.addAll(args); | 97 options.addAll(args); |
| 88 doTest(new TestCase(testName, | 98 doTest(new TestCase(testName, |
| 89 shellPath, | 99 shellPath, |
| 90 options, | 100 options, |
| 91 configuration["timeout"], | 101 configuration["timeout"], |
| 92 completeHandler, | 102 completeHandler, |
| 93 expectations)); | 103 expectations, |
| 94 } | 104 isNegative)); |
| 105 } |
| 95 } | 106 } |
| 96 } | 107 } |
| 97 | 108 |
| 109 |
| 98 Map testOptions(String filename) { | 110 Map testOptions(String filename) { |
| 99 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); | 111 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); |
| 100 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); | 112 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); |
| 101 File file = new File(filename); | 113 File file = new File(filename); |
| 102 FileInputStream fileStream = file.openInputStream(); | 114 FileInputStream fileStream = file.openInputStream(); |
| 103 StringInputStream lines = new StringInputStream(fileStream); | 115 StringInputStream lines = new StringInputStream(fileStream); |
| 104 | 116 |
| 105 List<List> result = new List<List>(); | 117 List<List> result = new List<List>(); |
| 106 List<String> dartOptions; | 118 List<String> dartOptions; |
| 119 bool isNegative = false; |
| 107 String line; | 120 String line; |
| 108 while ((line = lines.readLine()) != null) { | 121 while ((line = lines.readLine()) != null) { |
| 109 Match match = testOptionsRegExp.firstMatch(line); | 122 Match match = testOptionsRegExp.firstMatch(line); |
| 110 if (match != null) { | 123 if (match != null) { |
| 111 result.add(match[1].split(' ').filter((e) => e != '')); | 124 result.add(match[1].split(' ').filter((e) => e != '')); |
| 112 } | 125 } |
| 113 | 126 |
| 114 match = dartOptionsRegExp.firstMatch(line); | 127 match = dartOptionsRegExp.firstMatch(line); |
| 115 if (match != null) { | 128 if (match != null) { |
| 116 if (dartOptions != null) { | 129 if (dartOptions != null) { |
| 117 throw new Exception( | 130 throw new Exception( |
| 118 'More than one "// DartOptions=" line in test $filename'); | 131 'More than one "// DartOptions=" line in test $filename'); |
| 119 } | 132 } |
| 120 dartOptions = match[1].split(' ').filter((e) => e != ''); | 133 dartOptions = match[1].split(' ').filter((e) => e != ''); |
| 121 } | 134 } |
| 135 |
| 136 if (line.contains("@compile-error") || line.contains("@runtime-error")) { |
| 137 isNegative = true; |
| 138 } else if (line.contains("@dynamic-type-error") && |
| 139 configuration['checked']) { |
| 140 isNegative = true; |
| 141 } |
| 122 } | 142 } |
| 123 return {"vmOptions": result, "dartOptions": dartOptions}; | 143 return { "vmOptions": result, |
| 144 "dartOptions": dartOptions, |
| 145 "isNegative" : isNegative }; |
| 124 } | 146 } |
| 125 | 147 |
| 126 void completeHandler(TestCase testCase) { | 148 void completeHandler(TestCase testCase) { |
| 127 } | 149 } |
| 128 } | 150 } |
| OLD | NEW |