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

Side by Side Diff: tests/co19/test_config.dart

Issue 8574052: Start extracting common test_config.dart functionality into a utility library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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("co19_test_config"); 5 #library("co19_test_config");
6 6
7 #import("../../tools/testing/dart/status_file_parser.dart");
8 #import("../../tools/testing/dart/test_config_utils.dart");
7 #import("../../tools/testing/dart/test_runner.dart"); 9 #import("../../tools/testing/dart/test_runner.dart");
8 #import("../../tools/testing/dart/status_file_parser.dart");
9 10
10 class Co19TestSuite { 11 class Co19TestSuite {
11 String directoryPath = "tests/co19/src"; 12 String directoryPath = "tests/co19/src";
12 Function doTest; 13 Function doTest;
13 Function doDone; 14 Function doDone;
14 String shellPath; 15 String shellPath;
15 String pathSeparator; 16 String pathSeparator;
16 Map configuration; 17 Map configuration;
17 TestExpectations testExpectations; 18 TestExpectations testExpectations;
18 RegExp testRegExp; 19 RegExp testRegExp;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 !patterns.some((re) => re.hasMatch(filename))) { 64 !patterns.some((re) => re.hasMatch(filename))) {
64 return; 65 return;
65 } 66 }
66 67
67 int start = filename.lastIndexOf('src' + pathSeparator); 68 int start = filename.lastIndexOf('src' + pathSeparator);
68 String testName = filename.substring(start + 4, filename.length - 5); 69 String testName = filename.substring(start + 4, filename.length - 5);
69 Set<String> expectations = testExpectations.expectations(testName); 70 Set<String> expectations = testExpectations.expectations(testName);
70 71
71 if (expectations.contains(SKIP)) return; 72 if (expectations.contains(SKIP)) return;
72 73
73 List args = ["--ignore-unrecognized-flags"]; 74 var optionsFromFile = TestUtils.optionsFromFile(filename, configuration);
74 if (configuration["checked"]) { 75 var argumentLists =
75 args.add("--enable_type_checks"); 76 TestUtils.argumentLists(filename, optionsFromFile, configuration);
76 } 77 for (var args in argumentLists) {
77 if (configuration["component"] == "leg") { 78 var timeout = configuration['timeout'];
78 args.add("--enable_leg"); 79 var isNegative = optionsFromFile['isNegative'];
79 }
80
81 var optionsFromFile = testOptions(filename);
82 List<List<String>> optionsList = optionsFromFile["vmOptions"];
83 List<String> dartOptions = optionsFromFile["dartOptions"];
84 args.addAll(dartOptions == null ? [filename] : dartOptions);
85 var isNegative = optionsFromFile["isNegative"];
86
87 if (optionsList.isEmpty()) {
88 doTest(new TestCase(testName, 80 doTest(new TestCase(testName,
89 shellPath, 81 shellPath,
90 args, 82 args,
91 configuration["timeout"], 83 timeout,
92 completeHandler, 84 completeHandler,
93 expectations, 85 expectations,
94 isNegative)); 86 isNegative));
95 } else {
96 for (var options in optionsList) {
97 options.addAll(args);
98 doTest(new TestCase(testName,
99 shellPath,
100 options,
101 configuration["timeout"],
102 completeHandler,
103 expectations,
104 isNegative));
105 }
106 } 87 }
107 } 88 }
108 89
109
110 Map testOptions(String filename) {
111 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
112 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
113
114 // Read the entire file into a byte buffer and transform it to a
115 // String. This will treat the file as ascii but the only parts
116 // we are interested in will be ascii in any case.
117 File file = new File(filename);
118 file.openSync();
119 List chars = new List(file.lengthSync());
120 var offset = 0;
121 while (offset != chars.length) {
122 offset += file.readListSync(chars, offset, chars.length - offset);
123 }
124 file.closeSync();
125 String contents = new String.fromCharCodes(chars);
126 chars = null;
127
128 // Find the options in the file.
129 List<List> result = new List<List>();
130 List<String> dartOptions;
131 bool isNegative = false;
132
133 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
134 for (var match in matches) {
135 result.add(match[1].split(' ').filter((e) => e != ''));
136 }
137
138 matches = dartOptionsRegExp.allMatches(contents);
139 for (var match in matches) {
140 if (dartOptions != null) {
141 throw new Exception(
142 'More than one "// DartOptions=" line in test $filename');
143 }
144 dartOptions = match[1].split(' ').filter((e) => e != '');
145 }
146
147 if (contents.contains("@compile-error") ||
148 contents.contains("@runtime-error")) {
149 isNegative = true;
150 } else if (contents.contains("@dynamic-type-error") &&
151 configuration['checked']) {
152 isNegative = true;
153 }
154
155 return { "vmOptions": result,
156 "dartOptions": dartOptions,
157 "isNegative" : isNegative };
158 }
159
160 void completeHandler(TestCase test) { 90 void completeHandler(TestCase test) {
161 } 91 }
162 } 92 }
OLDNEW
« no previous file with comments | « no previous file | tests/corelib/test_config.dart » ('j') | tools/testing/dart/test_config_utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698