OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of layout_test; |
| 6 |
5 // The filters must be set by the caller that #sources this file. | 7 // The filters must be set by the caller that #sources this file. |
6 List includeFilters; | 8 List includeFilters; |
| 9 List excludeFilters; |
7 | 10 |
8 // TODO(gram): dart2js is not handling 'part of' properly yet; when it | 11 /** |
9 // does uncomment this. | 12 * A special marker string used to separate group names and |
10 //part of layout_test; | 13 * identify non-debug output. |
11 | 14 */ |
12 List excludeFilters; | 15 final marker = '###'; |
13 | 16 |
14 class LayoutTestConfiguration extends unittest.Configuration { | 17 class LayoutTestConfiguration extends unittest.Configuration { |
15 get autoStart => false; | 18 get autoStart => false; |
16 void onTestResult(unittest.TestCase testCase) { | 19 void onTestResult(unittest.TestCase testCase) { |
17 window.postMessage('done', '*'); // Unblock DRT | 20 window.postMessage('done', '*'); // Unblock DRT |
18 } | 21 } |
19 } | 22 } |
20 | 23 |
21 filterTest(t) { | 24 filterTest(t) { |
22 var name = t.description.replaceAll("###", " "); | 25 var name = t.description.replaceAll(marker, " "); |
23 if (includeFilters.length > 0) { | 26 if (includeFilters.length > 0) { |
24 for (var f in includeFilters) { | 27 for (var f in includeFilters) { |
25 if (name.indexOf(f) >= 0) return true; | 28 if (name.indexOf(f) >= 0) return true; |
26 } | 29 } |
27 return false; | 30 return false; |
28 } else if (excludeFilters.length > 0) { | 31 } else if (excludeFilters.length > 0) { |
29 for (var f in excludeFilters) { | 32 for (var f in excludeFilters) { |
30 if (name.indexOf(f) >= 0) return false; | 33 if (name.indexOf(f) >= 0) return false; |
31 } | 34 } |
32 return true; | 35 return true; |
33 } else { | 36 } else { |
34 return true; | 37 return true; |
35 } | 38 } |
36 } | 39 } |
37 | 40 |
38 runTests(testMain) { | 41 runTests(testMain) { |
39 unittest.groupSep = '###'; | 42 unittest.groupSep = marker; |
40 unittest.configure(new LayoutTestConfiguration()); | 43 unittest.unittestConfiguration = new LayoutTestConfiguration(); |
41 | 44 |
42 // Create the set of test cases. | 45 // Create the set of test cases. |
43 unittest.group('', testMain); | 46 unittest.group('', testMain); |
44 | 47 |
45 // Do any user-specified test filtering. | 48 // Do any user-specified test filtering. |
46 unittest.filterTests(filterTest); | 49 unittest.filterTests(filterTest); |
47 | 50 |
48 // Filter to the test number in the search query. | 51 // Filter to the test number in the search query. |
49 var testNum = int.parse(window.location.search.substring(6)); | 52 var testNum = int.parse(window.location.search.substring(6)); |
50 if (testNum < 0 || testNum >= unittest.testCases.length) { | 53 if (testNum < 0 || testNum >= unittest.testCases.length) { |
51 print('#TEST NONEXISTENT'); | 54 print('#TEST NONEXISTENT'); |
52 window.postMessage('done', '*'); // Unblock DRT | 55 window.postMessage('done', '*'); // Unblock DRT |
53 } else { | 56 } else { |
54 var name = unittest.testCases[testNum].description; | 57 var name = unittest.testCases[testNum].description; |
55 print('#TEST $name'); | 58 print('#TEST $name'); |
56 unittest.filterTests(name); | 59 unittest.filterTests(name); |
57 // Run the test. | 60 // Run the test. |
58 print('Tests - ${unittest.testCases.length}'); | 61 print('Tests - ${unittest.testCases.length}'); |
59 unittest.runTests(); | 62 unittest.runTests(); |
60 } | 63 } |
61 } | 64 } |
OLD | NEW |