OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'package:scheduled_test/descriptor.dart' as d; | 5 import 'package:scheduled_test/descriptor.dart' as d; |
6 import 'package:scheduled_test/scheduled_test.dart'; | 6 import 'package:scheduled_test/scheduled_test.dart'; |
7 | 7 |
8 import '../metatest.dart'; | 8 import '../metatest.dart'; |
9 import 'utils.dart'; | 9 import 'utils.dart'; |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 scheduleSandbox(); | 59 scheduleSandbox(); |
60 | 60 |
61 currentSchedule.onException.schedule(() { | 61 currentSchedule.onException.schedule(() { |
62 errors = currentSchedule.errors; | 62 errors = currentSchedule.errors; |
63 }); | 63 }); |
64 | 64 |
65 d.filePattern(new RegExp(r'f..'), 'bar').validate(); | 65 d.filePattern(new RegExp(r'f..'), 'bar').validate(); |
66 }); | 66 }); |
67 | 67 |
68 test('test 2', () { | 68 test('test 2', () { |
69 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 69 expect(errors.single, new isInstanceOf<ScheduleError>()); |
70 expect(errors.length, equals(1)); | 70 expect(errors.single.error.toString(), |
71 expect(errors.first.error, | |
72 matches(r"^No entry found in '[^']+' matching /f\.\./\.$")); | 71 matches(r"^No entry found in '[^']+' matching /f\.\./\.$")); |
73 }); | 72 }); |
74 }, passing: ['test 2']); | 73 }, passing: ['test 2']); |
75 | 74 |
76 expectTestsPass("pattern().validate() fails if there's a file matching the " | 75 expectTestsPass("pattern().validate() fails if there's a file matching the " |
77 "pattern but not the entry", () { | 76 "pattern but not the entry", () { |
78 var errors; | 77 var errors; |
79 test('test 1', () { | 78 test('test 1', () { |
80 scheduleSandbox(); | 79 scheduleSandbox(); |
81 | 80 |
82 currentSchedule.onException.schedule(() { | 81 currentSchedule.onException.schedule(() { |
83 errors = currentSchedule.errors; | 82 errors = currentSchedule.errors; |
84 }); | 83 }); |
85 | 84 |
86 d.file('foo', 'bap').create(); | 85 d.file('foo', 'bap').create(); |
87 d.filePattern(new RegExp(r'f..'), 'bar').validate(); | 86 d.filePattern(new RegExp(r'f..'), 'bar').validate(); |
88 }); | 87 }); |
89 | 88 |
90 test('test 2', () { | 89 test('test 2', () { |
91 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 90 expect(errors.single, new isInstanceOf<ScheduleError>()); |
92 expect(errors.length, equals(1)); | 91 expect(errors.single.error.toString(), |
93 expect(errors.first.error, | |
94 matches(r"^Caught error\n" | 92 matches(r"^Caught error\n" |
95 r"| File 'foo' should contain:\n" | 93 r"| File 'foo' should contain:\n" |
96 r"| | bar\n" | 94 r"| | bar\n" |
97 r"| but actually contained:\n" | 95 r"| but actually contained:\n" |
98 r"| X bap\n" | 96 r"| X bap\n" |
99 r"while validating\n" | 97 r"while validating\n" |
100 r"| foo$")); | 98 r"| foo$")); |
101 }); | 99 }); |
102 }, passing: ['test 2']); | 100 }, passing: ['test 2']); |
103 | 101 |
(...skipping 10 matching lines...) Expand all Loading... |
114 d.dir('foo', [ | 112 d.dir('foo', [ |
115 d.file('bar', 'bap') | 113 d.file('bar', 'bap') |
116 ]).create(); | 114 ]).create(); |
117 | 115 |
118 d.dirPattern(new RegExp(r'f..'), [ | 116 d.dirPattern(new RegExp(r'f..'), [ |
119 d.file('bar', 'baz') | 117 d.file('bar', 'baz') |
120 ]).validate(); | 118 ]).validate(); |
121 }); | 119 }); |
122 | 120 |
123 test('test 2', () { | 121 test('test 2', () { |
124 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 122 expect(errors.single, new isInstanceOf<ScheduleError>()); |
125 expect(errors.length, equals(1)); | 123 expect(errors.single.error.toString(), |
126 expect(errors.first.error, | |
127 matches(r"^Caught error\n" | 124 matches(r"^Caught error\n" |
128 r"| File 'bar' should contain:\n" | 125 r"| File 'bar' should contain:\n" |
129 r"| | baz\n" | 126 r"| | baz\n" |
130 r"| but actually contained:\n" | 127 r"| but actually contained:\n" |
131 r"| X bap" | 128 r"| X bap" |
132 r"while validating\n" | 129 r"while validating\n" |
133 r"| foo\n" | 130 r"| foo\n" |
134 r"| '-- bar$")); | 131 r"| '-- bar$")); |
135 }); | 132 }); |
136 }, passing: ['test 2']); | 133 }, passing: ['test 2']); |
137 | 134 |
138 expectTestsPass("pattern().validate() fails if there's multiple files " | 135 expectTestsPass("pattern().validate() fails if there's multiple files " |
139 "matching the pattern and the child entry", () { | 136 "matching the pattern and the child entry", () { |
140 var errors; | 137 var errors; |
141 test('test 1', () { | 138 test('test 1', () { |
142 scheduleSandbox(); | 139 scheduleSandbox(); |
143 | 140 |
144 currentSchedule.onException.schedule(() { | 141 currentSchedule.onException.schedule(() { |
145 errors = currentSchedule.errors; | 142 errors = currentSchedule.errors; |
146 }); | 143 }); |
147 | 144 |
148 d.file('foo', 'bar').create(); | 145 d.file('foo', 'bar').create(); |
149 d.file('fee', 'bar').create(); | 146 d.file('fee', 'bar').create(); |
150 d.file('faa', 'bar').create(); | 147 d.file('faa', 'bar').create(); |
151 d.filePattern(new RegExp(r'f..'), 'bar').validate(); | 148 d.filePattern(new RegExp(r'f..'), 'bar').validate(); |
152 }); | 149 }); |
153 | 150 |
154 test('test 2', () { | 151 test('test 2', () { |
155 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 152 expect(errors.single, new isInstanceOf<ScheduleError>()); |
156 expect(errors.length, equals(1)); | 153 expect(errors.single.error.toString(), matches( |
157 expect(errors.first.error, matches( | 154 r"^Multiple valid entries found in '[^']+' matching " |
158 r"^Multiple valid entries found in '[^']+' matching " | 155 r"\/f\.\./:\n" |
159 r"\/f\.\./:\n" | 156 r"\* faa\n" |
160 r"\* faa\n" | 157 r"\* fee\n" |
161 r"\* fee\n" | 158 r"\* foo$")); |
162 r"\* foo$")); | |
163 }); | 159 }); |
164 }, passing: ['test 2']); | 160 }, passing: ['test 2']); |
165 } | 161 } |
OLD | NEW |