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

Side by Side Diff: tests/standalone/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/corelib/test_config.dart ('k') | tools/testing/dart/test_config_utils.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("standalone_test_config"); 5 #library("standalone_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 StandaloneTestSuite { 11 class StandaloneTestSuite {
11 String directoryPath = "tests/standalone/src"; 12 String directoryPath = "tests/standalone/src";
12 final String statusFilePath = "tests/standalone/standalone.status"; 13 final String statusFilePath = "tests/standalone/standalone.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 // Since '.*' does not match a newline these RegExps can be used
99 // on the entire contents of files instead of individual lines.
100 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
101 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
102
103 // Read the entire file into a byte buffer and transform it to a
104 // String. This will treat the file as ascii but the only parts
105 // we are interested in will be ascii in any case.
106 File file = new File(filename);
107 file.openSync();
108 List chars = new List(file.lengthSync());
109 var offset = 0;
110 while (offset != chars.length) {
111 offset += file.readListSync(chars, offset, chars.length - offset);
112 }
113 file.closeSync();
114 String contents = new String.fromCharCodes(chars);
115 chars = null;
116
117 // Find the options in the file.
118 List<List> result = new List<List>();
119 List<String> dartOptions;
120 bool isNegative = false;
121
122 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
123 for (var match in matches) {
124 result.add(match[1].split(' ').filter((e) => e != ''));
125 }
126
127 matches = dartOptionsRegExp.allMatches(contents);
128 for (var match in matches) {
129 if (dartOptions != null) {
130 throw new Exception(
131 'More than one "// DartOptions=" line in test $filename');
132 }
133 dartOptions = match[1].split(' ').filter((e) => e != '');
134 }
135
136 return { "vmOptions": result, "dartOptions": dartOptions };
137 }
138
139 void completeHandler(TestCase testCase) { 81 void completeHandler(TestCase testCase) {
140 } 82 }
141 } 83 }
OLDNEW
« no previous file with comments | « tests/corelib/test_config.dart ('k') | tools/testing/dart/test_config_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698