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

Side by Side Diff: pkg/scheduled_test/test/descriptor/pattern_test.dart

Issue 13472016: Split apart several asynchronous tests to reduce timeouts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6 import 'dart:io';
7
8 import 'package:pathos/path.dart' as path;
9 import 'package:scheduled_test/descriptor.dart' as d;
10 import 'package:scheduled_test/scheduled_test.dart';
11
12 import '../metatest.dart';
13 import 'utils.dart';
14
15 String sandbox;
16
17 void main() {
18 metaSetUp(() {
19 // TODO(nweiz): We used to only increase the timeout to 10s for the Windows
20 // bots, but the Linux and Mac bots have started taking upwards of 5s when
21 // running pumpEventQueue, so we're increasing the timeout across the board
22 // (see issue 9248).
23 currentSchedule.timeout = new Duration(seconds: 10);
24 });
25
26 expectTestsPass("pattern().validate() succeeds if there's a file matching "
27 "the pattern and the child entry", () {
28 test('test', () {
29 scheduleSandbox();
30
31 d.file('foo', 'blap').create();
32
33 d.filePattern(new RegExp(r'f..'), 'blap').validate();
34 });
35 });
36
37 expectTestsPass("pattern().validate() succeeds if there's a dir matching "
38 "the pattern and the child entry", () {
39 test('test', () {
40 scheduleSandbox();
41
42 d.dir('foo', [
43 d.file('bar', 'baz')
44 ]).create();
45
46 d.dirPattern(new RegExp(r'f..'), [
47 d.file('bar', 'baz')
48 ]).validate();
49 });
50 });
51
52 expectTestsPass("pattern().validate() succeeds if there's multiple files "
53 "matching the pattern but only one matching the child entry", () {
54 test('test', () {
55 scheduleSandbox();
56
57 d.file('foo', 'blap').create();
58 d.file('fee', 'blak').create();
59 d.file('faa', 'blut').create();
60
61 d.filePattern(new RegExp(r'f..'), 'blap').validate();
62 });
63 });
64
65 expectTestsPass("pattern().validate() fails if there's no file matching the "
66 "pattern", () {
67 var errors;
68 test('test 1', () {
69 scheduleSandbox();
70
71 currentSchedule.onException.schedule(() {
72 errors = currentSchedule.errors;
73 });
74
75 d.filePattern(new RegExp(r'f..'), 'bar').validate();
76 });
77
78 test('test 2', () {
79 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
80 expect(errors.length, equals(1));
81 expect(errors.first.error,
82 matches(r"^No entry found in '[^']+' matching /f\.\./\.$"));
83 });
84 }, passing: ['test 2']);
85
86 expectTestsPass("pattern().validate() fails if there's a file matching the "
87 "pattern but not the entry", () {
88 var errors;
89 test('test 1', () {
90 scheduleSandbox();
91
92 currentSchedule.onException.schedule(() {
93 errors = currentSchedule.errors;
94 });
95
96 d.file('foo', 'bap').create();
97 d.filePattern(new RegExp(r'f..'), 'bar').validate();
98 });
99
100 test('test 2', () {
101 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
102 expect(errors.length, equals(1));
103 expect(errors.first.error,
104 matches(r"^Caught error\n"
105 r"| File 'foo' should contain:\n"
106 r"| | bar\n"
107 r"| but actually contained:\n"
108 r"| X bap\n"
109 r"while validating\n"
110 r"| foo$"));
111 });
112 }, passing: ['test 2']);
113
114 expectTestsPass("pattern().validate() fails if there's a dir matching the "
115 "pattern but not the entry", () {
116 var errors;
117 test('test 1', () {
118 scheduleSandbox();
119
120 currentSchedule.onException.schedule(() {
121 errors = currentSchedule.errors;
122 });
123
124 d.dir('foo', [
125 d.file('bar', 'bap')
126 ]).create();
127
128 d.dirPattern(new RegExp(r'f..'), [
129 d.file('bar', 'baz')
130 ]).validate();
131 });
132
133 test('test 2', () {
134 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
135 expect(errors.length, equals(1));
136 expect(errors.first.error,
137 matches(r"^Caught error\n"
138 r"| File 'bar' should contain:\n"
139 r"| | baz\n"
140 r"| but actually contained:\n"
141 r"| X bap"
142 r"while validating\n"
143 r"| foo\n"
144 r"| '-- bar$"));
145 });
146 }, passing: ['test 2']);
147
148 expectTestsPass("pattern().validate() fails if there's multiple files "
149 "matching the pattern and the child entry", () {
150 var errors;
151 test('test 1', () {
152 scheduleSandbox();
153
154 currentSchedule.onException.schedule(() {
155 errors = currentSchedule.errors;
156 });
157
158 d.file('foo', 'bar').create();
159 d.file('fee', 'bar').create();
160 d.file('faa', 'bar').create();
161 d.filePattern(new RegExp(r'f..'), 'bar').validate();
162 });
163
164 test('test 2', () {
165 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
166 expect(errors.length, equals(1));
167 expect(errors.first.error, matches(
168 r"^Multiple valid entries found in '[^']+' matching "
169 r"\/f\.\./:\n"
170 r"\* faa\n"
171 r"\* fee\n"
172 r"\* foo$"));
173 });
174 }, passing: ['test 2']);
175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698