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