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

Side by Side Diff: tools/testing/dart/test_config_utils.dart

Issue 8589020: Enable language and isolate tests using the dart test runner. (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
« no previous file with comments | « tools/test.dart ('k') | tools/testing/dart/test_options.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #library("test_config_utils");
6
7 /**
8 * TestUtils is a collection of utility methods used to write
9 * test_config.dart scripts for test suites.
10 */
11 class TestUtils {
12
13 /**
14 * Get a list of argument lists for the dart shell command.
15 */
16 static List<List<String>> argumentLists(String filename,
17 Map optionsFromFile,
18 Map configuration) {
19 List args = ["--ignore-unrecognized-flags"];
20 if (configuration["checked"]) {
21 args.add("--enable_type_checks");
22 }
23 if (configuration["component"] == "leg") {
24 args.add("--enable_leg");
25 }
26 if (configuration["component"] == "dartc") {
27 if (configuration["mode"] == "release") {
28 args.add("--optimize");
29 }
30 }
31
32 List<String> dartOptions = optionsFromFile["dartOptions"];
33 args.addAll(dartOptions == null ? [filename] : dartOptions);
34
35 var result = new List<List<String>>();
36 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"];
37 if (vmOptionsList.isEmpty()) {
38 result.add(args);
39 } else {
40 for (var vmOptions in vmOptionsList) {
41 vmOptions.addAll(args);
42 result.add(vmOptions);
43 }
44 }
45
46 return result;
47 }
48
49 /**
50 * Extract test options from the test file itself.
51 */
52 static Map optionsFromFile(String filename, Map configuration) {
53 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
54 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
55
56 // Read the entire file into a byte buffer and transform it to a
57 // String. This will treat the file as ascii but the only parts
58 // we are interested in will be ascii in any case.
59 File file = new File(filename);
60 file.openSync();
61 List chars = new List(file.lengthSync());
62 var offset = 0;
63 while (offset != chars.length) {
64 offset += file.readListSync(chars, offset, chars.length - offset);
65 }
66 file.closeSync();
67 String contents = new String.fromCharCodes(chars);
68 chars = null;
69
70 // Find the options in the file.
71 List<List> result = new List<List>();
72 List<String> dartOptions;
73 bool isNegative = false;
74
75 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
76 for (var match in matches) {
77 result.add(match[1].split(' ').filter((e) => e != ''));
78 }
79
80 matches = dartOptionsRegExp.allMatches(contents);
81 for (var match in matches) {
82 if (dartOptions != null) {
83 throw new Exception(
84 'More than one "// DartOptions=" line in test $filename');
85 }
86 dartOptions = match[1].split(' ').filter((e) => e != '');
87 }
88
89 if (contents.contains("@compile-error") ||
90 contents.contains("@runtime-error")) {
91 isNegative = true;
92 } else if (contents.contains("@dynamic-type-error") &&
93 configuration['checked']) {
94 isNegative = true;
95 }
96
97 return { "vmOptions": result,
98 "dartOptions": dartOptions,
99 "isNegative" : isNegative };
100 }
101 }
OLDNEW
« no previous file with comments | « tools/test.dart ('k') | tools/testing/dart/test_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698