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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/scheduled_test/test/descriptor/nothing_test.dart ('k') | pkg/scheduled_test/test/descriptor/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/test/descriptor/pattern_test.dart
diff --git a/pkg/scheduled_test/test/descriptor/pattern_test.dart b/pkg/scheduled_test/test/descriptor/pattern_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a9f734ef46143f31a35b1ee34e21117acd35a5a1
--- /dev/null
+++ b/pkg/scheduled_test/test/descriptor/pattern_test.dart
@@ -0,0 +1,169 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:pathos/path.dart' as path;
+import 'package:scheduled_test/descriptor.dart' as d;
+import 'package:scheduled_test/scheduled_test.dart';
+
+import '../metatest.dart';
+import 'utils.dart';
+
+String sandbox;
+
+void main() {
+ setUpTimeout();
+
+ expectTestsPass("pattern().validate() succeeds if there's a file matching "
+ "the pattern and the child entry", () {
+ test('test', () {
+ scheduleSandbox();
+
+ d.file('foo', 'blap').create();
+
+ d.filePattern(new RegExp(r'f..'), 'blap').validate();
+ });
+ });
+
+ expectTestsPass("pattern().validate() succeeds if there's a dir matching "
+ "the pattern and the child entry", () {
+ test('test', () {
+ scheduleSandbox();
+
+ d.dir('foo', [
+ d.file('bar', 'baz')
+ ]).create();
+
+ d.dirPattern(new RegExp(r'f..'), [
+ d.file('bar', 'baz')
+ ]).validate();
+ });
+ });
+
+ expectTestsPass("pattern().validate() succeeds if there's multiple files "
+ "matching the pattern but only one matching the child entry", () {
+ test('test', () {
+ scheduleSandbox();
+
+ d.file('foo', 'blap').create();
+ d.file('fee', 'blak').create();
+ d.file('faa', 'blut').create();
+
+ d.filePattern(new RegExp(r'f..'), 'blap').validate();
+ });
+ });
+
+ expectTestsPass("pattern().validate() fails if there's no file matching the "
+ "pattern", () {
+ var errors;
+ test('test 1', () {
+ scheduleSandbox();
+
+ currentSchedule.onException.schedule(() {
+ errors = currentSchedule.errors;
+ });
+
+ d.filePattern(new RegExp(r'f..'), 'bar').validate();
+ });
+
+ test('test 2', () {
+ expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
+ expect(errors.length, equals(1));
+ expect(errors.first.error,
+ matches(r"^No entry found in '[^']+' matching /f\.\./\.$"));
+ });
+ }, passing: ['test 2']);
+
+ expectTestsPass("pattern().validate() fails if there's a file matching the "
+ "pattern but not the entry", () {
+ var errors;
+ test('test 1', () {
+ scheduleSandbox();
+
+ currentSchedule.onException.schedule(() {
+ errors = currentSchedule.errors;
+ });
+
+ d.file('foo', 'bap').create();
+ d.filePattern(new RegExp(r'f..'), 'bar').validate();
+ });
+
+ test('test 2', () {
+ expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
+ expect(errors.length, equals(1));
+ expect(errors.first.error,
+ matches(r"^Caught error\n"
+ r"| File 'foo' should contain:\n"
+ r"| | bar\n"
+ r"| but actually contained:\n"
+ r"| X bap\n"
+ r"while validating\n"
+ r"| foo$"));
+ });
+ }, passing: ['test 2']);
+
+ expectTestsPass("pattern().validate() fails if there's a dir matching the "
+ "pattern but not the entry", () {
+ var errors;
+ test('test 1', () {
+ scheduleSandbox();
+
+ currentSchedule.onException.schedule(() {
+ errors = currentSchedule.errors;
+ });
+
+ d.dir('foo', [
+ d.file('bar', 'bap')
+ ]).create();
+
+ d.dirPattern(new RegExp(r'f..'), [
+ d.file('bar', 'baz')
+ ]).validate();
+ });
+
+ test('test 2', () {
+ expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
+ expect(errors.length, equals(1));
+ expect(errors.first.error,
+ matches(r"^Caught error\n"
+ r"| File 'bar' should contain:\n"
+ r"| | baz\n"
+ r"| but actually contained:\n"
+ r"| X bap"
+ r"while validating\n"
+ r"| foo\n"
+ r"| '-- bar$"));
+ });
+ }, passing: ['test 2']);
+
+ expectTestsPass("pattern().validate() fails if there's multiple files "
+ "matching the pattern and the child entry", () {
+ var errors;
+ test('test 1', () {
+ scheduleSandbox();
+
+ currentSchedule.onException.schedule(() {
+ errors = currentSchedule.errors;
+ });
+
+ d.file('foo', 'bar').create();
+ d.file('fee', 'bar').create();
+ d.file('faa', 'bar').create();
+ d.filePattern(new RegExp(r'f..'), 'bar').validate();
+ });
+
+ test('test 2', () {
+ expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
+ expect(errors.length, equals(1));
+ expect(errors.first.error, matches(
+ r"^Multiple valid entries found in '[^']+' matching "
+ r"\/f\.\./:\n"
+ r"\* faa\n"
+ r"\* fee\n"
+ r"\* foo$"));
+ });
+ }, passing: ['test 2']);
+}
« no previous file with comments | « pkg/scheduled_test/test/descriptor/nothing_test.dart ('k') | pkg/scheduled_test/test/descriptor/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698