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

Side by Side Diff: tests/corelib/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: Address review comments. 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
« no previous file with comments | « tests/co19/test_config.dart ('k') | tests/standalone/test_config.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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("corelib_test_config"); 5 #library("corelib_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 CorelibTestSuite { 11 class CorelibTestSuite {
11 String directoryPath = "tests/corelib/src"; 12 String directoryPath = "tests/corelib/src";
12 final String statusFilePath = "tests/corelib/corelib.status"; 13 final String statusFilePath = "tests/corelib/corelib.status";
13 Function doTest; 14 Function doTest;
14 Function doDone; 15 Function doDone;
15 String shellPath; 16 String shellPath;
16 String pathSeparator; 17 String pathSeparator;
17 Map configuration; 18 Map configuration;
18 TestExpectations testExpectations; 19 TestExpectations testExpectations;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 !patterns.some((re) => re.hasMatch(filename))) { 55 !patterns.some((re) => re.hasMatch(filename))) {
55 return; 56 return;
56 } 57 }
57 58
58 int start = filename.lastIndexOf(pathSeparator); 59 int start = filename.lastIndexOf(pathSeparator);
59 String testName = filename.substring(start + 1, filename.length - 5); 60 String testName = filename.substring(start + 1, filename.length - 5);
60 Set<String> expectations = testExpectations.expectations(testName); 61 Set<String> expectations = testExpectations.expectations(testName);
61 62
62 if (expectations.contains(SKIP)) return; 63 if (expectations.contains(SKIP)) return;
63 64
64 List args = ["--ignore-unrecognized-flags"]; 65 var optionsFromFile = TestUtils.optionsFromFile(filename, configuration);
65 if (configuration["checked"]) { 66 var argumentLists =
66 args.add("--enable_type_checks"); 67 TestUtils.argumentLists(filename, optionsFromFile, configuration);
67 } 68 for (var args in argumentLists) {
68 if (configuration["component"] == "leg") { 69 var timeout = configuration['timeout'];
69 args.add("--enable_leg"); 70 var isNegative = optionsFromFile['isNegative'];
70 }
71
72 var optionsFromFile = testOptions(filename);
73 List<List<String>> optionsList = optionsFromFile["vmOptions"];
74 List<String> dartOptions = optionsFromFile["dartOptions"];
75 args.addAll(dartOptions == null ? [filename] : dartOptions);
76
77 if (optionsList.isEmpty()) {
78 doTest(new TestCase(testName, 71 doTest(new TestCase(testName,
79 shellPath, 72 shellPath,
80 args, 73 args,
81 configuration["timeout"], 74 timeout,
82 completeHandler, 75 completeHandler,
83 expectations)); 76 expectations,
84 } else { 77 isNegative));
85 for (var options in optionsList) {
86 options.addAll(args);
87 doTest(new TestCase(testName,
88 shellPath,
89 options,
90 configuration["timeout"],
91 completeHandler,
92 expectations));
93 }
94 } 78 }
95 } 79 }
96 80
97 Map testOptions(String filename) {
98 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
99 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
100
101 // Read the entire file into a byte buffer and transform it to a
102 // String. This will treat the file as ascii but the only parts
103 // we are interested in will be ascii in any case.
104 File file = new File(filename);
105 file.openSync();
106 List chars = new List(file.lengthSync());
107 var offset = 0;
108 while (offset != chars.length) {
109 offset += file.readListSync(chars, offset, chars.length - offset);
110 }
111 file.closeSync();
112 String contents = new String.fromCharCodes(chars);
113 chars = null;
114
115 // Find the options in the file.
116 List<List> result = new List<List>();
117 List<String> dartOptions;
118 bool isNegative = false;
119
120 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
121 for (var match in matches) {
122 result.add(match[1].split(' ').filter((e) => e != ''));
123 }
124
125 matches = dartOptionsRegExp.allMatches(contents);
126 for (var match in matches) {
127 if (dartOptions != null) {
128 throw new Exception(
129 'More than one "// DartOptions=" line in test $filename');
130 }
131 dartOptions = match[1].split(' ').filter((e) => e != '');
132 }
133
134 return { "vmOptions": result, "dartOptions": dartOptions };
135 }
136
137 void completeHandler(TestCase testCase) { 81 void completeHandler(TestCase testCase) {
138 } 82 }
139 } 83 }
OLDNEW
« no previous file with comments | « tests/co19/test_config.dart ('k') | tests/standalone/test_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698