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

Unified Diff: utils/tests/pub/io_test.dart

Issue 12079112: Make a bunch of stuff in pub synchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix after merge. Created 7 years, 11 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 | « utils/pub/validator/name.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/io_test.dart
diff --git a/utils/tests/pub/io_test.dart b/utils/tests/pub/io_test.dart
index 94e8a52d871ee15d5e15d0a276b48c4e4199f868..29e970982d0e47a1b12d25f5a1a1348333e424f7 100644
--- a/utils/tests/pub/io_test.dart
+++ b/utils/tests/pub/io_test.dart
@@ -6,16 +6,19 @@ library io_test;
import '../../../pkg/unittest/lib/unittest.dart';
import '../../pub/io.dart';
+import '../../pub/utils.dart';
main() {
group('listDir', () {
test('lists a simple directory non-recursively', () {
expect(withTempDir((path) {
- var future = writeTextFile(join(path, 'file1.txt'), '')
- .then((_) => writeTextFile(join(path, 'file2.txt'), ''))
- .then((_) => createDir(join(path, 'subdir')))
- .then((_) => writeTextFile(join(path, 'subdir', 'file3.txt'), ''))
- .then((_) => listDir(path));
+ var future = defer(() {
+ writeTextFile(join(path, 'file1.txt'), '');
+ writeTextFile(join(path, 'file2.txt'), '');
+ createDir(join(path, 'subdir'));
+ writeTextFile(join(path, 'subdir', 'file3.txt'), '');
+ return listDir(path);
+ });
expect(future, completion(unorderedEquals([
join(path, 'file1.txt'),
join(path, 'file2.txt'),
@@ -27,11 +30,13 @@ main() {
test('lists a simple directory recursively', () {
expect(withTempDir((path) {
- var future = writeTextFile(join(path, 'file1.txt'), '')
- .then((_) => writeTextFile(join(path, 'file2.txt'), ''))
- .then((_) => createDir(join(path, 'subdir')))
- .then((_) => writeTextFile(join(path, 'subdir', 'file3.txt'), ''))
- .then((_) => listDir(path, recursive: true));
+ var future = defer(() {
+ writeTextFile(join(path, 'file1.txt'), '');
+ writeTextFile(join(path, 'file2.txt'), '');
+ createDir(join(path, 'subdir'));
+ writeTextFile(join(path, 'subdir', 'file3.txt'), '');
+ return listDir(path, recursive: true);
+ });
expect(future, completion(unorderedEquals([
join(path, 'file1.txt'),
join(path, 'file2.txt'),
@@ -44,12 +49,14 @@ main() {
test('ignores hidden files by default', () {
expect(withTempDir((path) {
- var future = writeTextFile(join(path, 'file1.txt'), '')
- .then((_) => writeTextFile(join(path, 'file2.txt'), ''))
- .then((_) => writeTextFile(join(path, '.file3.txt'), ''))
- .then((_) => createDir(join(path, '.subdir')))
- .then((_) => writeTextFile(join(path, '.subdir', 'file3.txt'), ''))
- .then((_) => listDir(path, recursive: true));
+ var future = defer(() {
+ writeTextFile(join(path, 'file1.txt'), '');
+ writeTextFile(join(path, 'file2.txt'), '');
+ writeTextFile(join(path, '.file3.txt'), '');
+ createDir(join(path, '.subdir'));
+ writeTextFile(join(path, '.subdir', 'file3.txt'), '');
+ return listDir(path, recursive: true);
+ });
expect(future, completion(unorderedEquals([
join(path, 'file1.txt'),
join(path, 'file2.txt')
@@ -60,14 +67,14 @@ main() {
test('includes hidden files when told to', () {
expect(withTempDir((path) {
- var future = writeTextFile(join(path, 'file1.txt'), '')
- .then((_) => writeTextFile(join(path, 'file2.txt'), ''))
- .then((_) => writeTextFile(join(path, '.file3.txt'), ''))
- .then((_) => createDir(join(path, '.subdir')))
- .then((_) => writeTextFile(join(path, '.subdir', 'file3.txt'), ''))
- .then((_) {
- return listDir(path, recursive: true, includeHiddenFiles: true);
- });
+ var future = defer(() {
+ writeTextFile(join(path, 'file1.txt'), '');
+ writeTextFile(join(path, 'file2.txt'), '');
+ writeTextFile(join(path, '.file3.txt'), '');
+ createDir(join(path, '.subdir'));
+ writeTextFile(join(path, '.subdir', 'file3.txt'), '');
+ return listDir(path, recursive: true, includeHiddenFiles: true);
+ });
expect(future, completion(unorderedEquals([
join(path, 'file1.txt'),
join(path, 'file2.txt'),
@@ -82,19 +89,18 @@ main() {
test('returns the unresolved paths for symlinks', () {
expect(withTempDir((path) {
var dirToList = join(path, 'dir-to-list');
- var future = writeTextFile(join(path, 'file1.txt'), '')
- .then((_) => writeTextFile(join(path, 'file2.txt'), ''))
- .then((_) => createDir(dirToList))
- .then((_) {
- return createSymlink(
- join(path, 'file1.txt'),
- join(dirToList, 'link1'));
- }).then((_) => createDir(join(dirToList, 'subdir')))
- .then((_) {
- return createSymlink(
+ var future = defer(() {
+ writeTextFile(join(path, 'file1.txt'), '');
+ writeTextFile(join(path, 'file2.txt'), '');
+ createDir(dirToList);
+ return createSymlink(join(path, 'file1.txt'),
+ join(dirToList, 'link1'));
+ }).then((_) {
+ createDir(join(dirToList, 'subdir'));
+ return createSymlink(
join(path, 'file2.txt'),
join(dirToList, 'subdir', 'link2'));
- }).then((_) => listDir(dirToList, recursive: true));
+ }).then((_) => listDir(dirToList, recursive: true));
expect(future, completion(unorderedEquals([
join(dirToList, 'link1'),
join(dirToList, 'subdir'),
@@ -106,9 +112,10 @@ main() {
test('works with recursive symlinks', () {
expect(withTempDir((path) {
- var future = writeTextFile(join(path, 'file1.txt'), '')
- .then((_) => createSymlink(path, join(path, 'linkdir')))
- .then((_) => listDir(path, recursive: true));
+ var future = defer(() {
+ writeTextFile(join(path, 'file1.txt'), '');
+ return createSymlink(path, join(path, 'linkdir'));
+ }).then((_) => listDir(path, recursive: true));
expect(future, completion(unorderedEquals([
join(path, 'file1.txt'),
join(path, 'linkdir')
« no previous file with comments | « utils/pub/validator/name.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698