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

Side by Side Diff: sdk/lib/_internal/pub/test/package_files_test.dart

Issue 341643002: Make short-running Git operations synchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source/git.dart ('k') | sdk/lib/_internal/pub/test/test_pub.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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 library packages_files_test; 5 library packages_files_test;
6 6
7 import 'package:path/path.dart' as path; 7 import 'package:path/path.dart' as path;
8 import 'package:scheduled_test/scheduled_test.dart'; 8 import 'package:scheduled_test/scheduled_test.dart';
9 9
10 import '../lib/src/entrypoint.dart'; 10 import '../lib/src/entrypoint.dart';
(...skipping 19 matching lines...) Expand all
30 d.dir(appPath, [ 30 d.dir(appPath, [
31 d.file('file1.txt', 'contents'), 31 d.file('file1.txt', 'contents'),
32 d.file('file2.txt', 'contents'), 32 d.file('file2.txt', 'contents'),
33 d.dir('subdir', [ 33 d.dir('subdir', [
34 d.file('subfile1.txt', 'subcontents'), 34 d.file('subfile1.txt', 'subcontents'),
35 d.file('subfile2.txt', 'subcontents') 35 d.file('subfile2.txt', 'subcontents')
36 ]) 36 ])
37 ]).create(); 37 ]).create();
38 38
39 schedule(() { 39 schedule(() {
40 expect(entrypoint.packageFiles(), completion(unorderedEquals([ 40 expect(entrypoint.packageFiles(), unorderedEquals([
41 path.join(root, 'pubspec.yaml'), 41 path.join(root, 'pubspec.yaml'),
42 path.join(root, 'file1.txt'), 42 path.join(root, 'file1.txt'),
43 path.join(root, 'file2.txt'), 43 path.join(root, 'file2.txt'),
44 path.join(root, 'subdir', 'subfile1.txt'), 44 path.join(root, 'subdir', 'subfile1.txt'),
45 path.join(root, 'subdir', 'subfile2.txt') 45 path.join(root, 'subdir', 'subfile2.txt')
46 ]))); 46 ]));
47 }); 47 });
48 }); 48 });
49 49
50 commonTests(); 50 commonTests();
51 }); 51 });
52 52
53 group('with git', () { 53 group('with git', () {
54 setUp(() { 54 setUp(() {
55 ensureGit(); 55 ensureGit();
56 d.git(appPath, [d.appPubspec()]).create(); 56 d.git(appPath, [d.appPubspec()]).create();
57 scheduleEntrypoint(); 57 scheduleEntrypoint();
58 }); 58 });
59 59
60 integration("includes files that are or aren't checked in", () { 60 integration("includes files that are or aren't checked in", () {
61 d.dir(appPath, [ 61 d.dir(appPath, [
62 d.file('file1.txt', 'contents'), 62 d.file('file1.txt', 'contents'),
63 d.file('file2.txt', 'contents'), 63 d.file('file2.txt', 'contents'),
64 d.dir('subdir', [ 64 d.dir('subdir', [
65 d.file('subfile1.txt', 'subcontents'), 65 d.file('subfile1.txt', 'subcontents'),
66 d.file('subfile2.txt', 'subcontents') 66 d.file('subfile2.txt', 'subcontents')
67 ]) 67 ])
68 ]).create(); 68 ]).create();
69 69
70 schedule(() { 70 schedule(() {
71 expect(entrypoint.packageFiles(), completion(unorderedEquals([ 71 expect(entrypoint.packageFiles(), unorderedEquals([
72 path.join(root, 'pubspec.yaml'), 72 path.join(root, 'pubspec.yaml'),
73 path.join(root, 'file1.txt'), 73 path.join(root, 'file1.txt'),
74 path.join(root, 'file2.txt'), 74 path.join(root, 'file2.txt'),
75 path.join(root, 'subdir', 'subfile1.txt'), 75 path.join(root, 'subdir', 'subfile1.txt'),
76 path.join(root, 'subdir', 'subfile2.txt') 76 path.join(root, 'subdir', 'subfile2.txt')
77 ]))); 77 ]));
78 }); 78 });
79 }); 79 });
80 80
81 integration("ignores files that are gitignored", () { 81 integration("ignores files that are gitignored", () {
82 d.dir(appPath, [ 82 d.dir(appPath, [
83 d.file('.gitignore', '*.txt'), 83 d.file('.gitignore', '*.txt'),
84 d.file('file1.txt', 'contents'), 84 d.file('file1.txt', 'contents'),
85 d.file('file2.text', 'contents'), 85 d.file('file2.text', 'contents'),
86 d.dir('subdir', [ 86 d.dir('subdir', [
87 d.file('subfile1.txt', 'subcontents'), 87 d.file('subfile1.txt', 'subcontents'),
88 d.file('subfile2.text', 'subcontents') 88 d.file('subfile2.text', 'subcontents')
89 ]) 89 ])
90 ]).create(); 90 ]).create();
91 91
92 schedule(() { 92 schedule(() {
93 expect(entrypoint.packageFiles(), completion(unorderedEquals([ 93 expect(entrypoint.packageFiles(), unorderedEquals([
94 path.join(root, 'pubspec.yaml'), 94 path.join(root, 'pubspec.yaml'),
95 path.join(root, '.gitignore'), 95 path.join(root, '.gitignore'),
96 path.join(root, 'file2.text'), 96 path.join(root, 'file2.text'),
97 path.join(root, 'subdir', 'subfile2.text') 97 path.join(root, 'subdir', 'subfile2.text')
98 ]))); 98 ]));
99 }); 99 });
100 }); 100 });
101 101
102 commonTests(); 102 commonTests();
103 }); 103 });
104 } 104 }
105 105
106 void scheduleEntrypoint() { 106 void scheduleEntrypoint() {
107 schedule(() { 107 schedule(() {
108 root = path.join(sandboxDir, appPath); 108 root = path.join(sandboxDir, appPath);
109 entrypoint = new Entrypoint(root, new SystemCache.withSources(root)); 109 entrypoint = new Entrypoint(root, new SystemCache.withSources(root));
110 }, 'initializing entrypoint'); 110 }, 'initializing entrypoint');
111 111
112 currentSchedule.onComplete.schedule(() { 112 currentSchedule.onComplete.schedule(() {
113 entrypoint = null; 113 entrypoint = null;
114 }, 'nulling entrypoint'); 114 }, 'nulling entrypoint');
115 } 115 }
116 116
117 void commonTests() { 117 void commonTests() {
118 integration('ignores broken symlinks', () { 118 integration('ignores broken symlinks', () {
119 // Windows requires us to symlink to a directory that actually exists. 119 // Windows requires us to symlink to a directory that actually exists.
120 d.dir(appPath, [d.dir('target')]).create(); 120 d.dir(appPath, [d.dir('target')]).create();
121 scheduleSymlink(path.join(appPath, 'target'), path.join(appPath, 'link')); 121 scheduleSymlink(path.join(appPath, 'target'), path.join(appPath, 'link'));
122 schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'target'))); 122 schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'target')));
123 123
124 schedule(() { 124 schedule(() {
125 expect(entrypoint.packageFiles(), 125 expect(entrypoint.packageFiles(),
126 completion(equals([path.join(root, 'pubspec.yaml')]))); 126 equals([path.join(root, 'pubspec.yaml')]));
127 }); 127 });
128 }); 128 });
129 129
130 integration('ignores pubspec.lock files', () { 130 integration('ignores pubspec.lock files', () {
131 d.dir(appPath, [ 131 d.dir(appPath, [
132 d.file('pubspec.lock'), 132 d.file('pubspec.lock'),
133 d.dir('subdir', [d.file('pubspec.lock')]) 133 d.dir('subdir', [d.file('pubspec.lock')])
134 ]).create(); 134 ]).create();
135 135
136 schedule(() { 136 schedule(() {
137 expect(entrypoint.packageFiles(), 137 expect(entrypoint.packageFiles(),
138 completion(equals([path.join(root, 'pubspec.yaml')]))); 138 equals([path.join(root, 'pubspec.yaml')]));
139 }); 139 });
140 }); 140 });
141 141
142 integration('ignores packages directories', () { 142 integration('ignores packages directories', () {
143 d.dir(appPath, [ 143 d.dir(appPath, [
144 d.dir('packages', [d.file('file.txt', 'contents')]), 144 d.dir('packages', [d.file('file.txt', 'contents')]),
145 d.dir('subdir', [ 145 d.dir('subdir', [
146 d.dir('packages', [d.file('subfile.txt', 'subcontents')]), 146 d.dir('packages', [d.file('subfile.txt', 'subcontents')]),
147 ]) 147 ])
148 ]).create(); 148 ]).create();
149 149
150 schedule(() { 150 schedule(() {
151 expect(entrypoint.packageFiles(), 151 expect(entrypoint.packageFiles(),
152 completion(equals([path.join(root, 'pubspec.yaml')]))); 152 equals([path.join(root, 'pubspec.yaml')]));
153 }); 153 });
154 }); 154 });
155 155
156 integration('allows pubspec.lock directories', () { 156 integration('allows pubspec.lock directories', () {
157 d.dir(appPath, [ 157 d.dir(appPath, [
158 d.dir('pubspec.lock', [ 158 d.dir('pubspec.lock', [
159 d.file('file.txt', 'contents'), 159 d.file('file.txt', 'contents'),
160 ]) 160 ])
161 ]).create(); 161 ]).create();
162 162
163 schedule(() { 163 schedule(() {
164 expect(entrypoint.packageFiles(), completion(unorderedEquals([ 164 expect(entrypoint.packageFiles(), unorderedEquals([
165 path.join(root, 'pubspec.yaml'), 165 path.join(root, 'pubspec.yaml'),
166 path.join(root, 'pubspec.lock', 'file.txt') 166 path.join(root, 'pubspec.lock', 'file.txt')
167 ]))); 167 ]));
168 }); 168 });
169 }); 169 });
170 170
171 group('and "beneath"', () { 171 group('and "beneath"', () {
172 integration('only lists files beneath the given root', () { 172 integration('only lists files beneath the given root', () {
173 d.dir(appPath, [ 173 d.dir(appPath, [
174 d.file('file1.txt', 'contents'), 174 d.file('file1.txt', 'contents'),
175 d.file('file2.txt', 'contents'), 175 d.file('file2.txt', 'contents'),
176 d.dir('subdir', [ 176 d.dir('subdir', [
177 d.file('subfile1.txt', 'subcontents'), 177 d.file('subfile1.txt', 'subcontents'),
178 d.file('subfile2.txt', 'subcontents'), 178 d.file('subfile2.txt', 'subcontents'),
179 d.dir('subsubdir', [ 179 d.dir('subsubdir', [
180 d.file('subsubfile1.txt', 'subsubcontents'), 180 d.file('subsubfile1.txt', 'subsubcontents'),
181 d.file('subsubfile2.txt', 'subsubcontents'), 181 d.file('subsubfile2.txt', 'subsubcontents'),
182 ]) 182 ])
183 ]) 183 ])
184 ]).create(); 184 ]).create();
185 185
186 schedule(() { 186 schedule(() {
187 expect(entrypoint.packageFiles(beneath: path.join(root, 'subdir')), 187 expect(entrypoint.packageFiles(beneath: path.join(root, 'subdir')),
188 completion(unorderedEquals([ 188 unorderedEquals([
189 path.join(root, 'subdir', 'subfile1.txt'), 189 path.join(root, 'subdir', 'subfile1.txt'),
190 path.join(root, 'subdir', 'subfile2.txt'), 190 path.join(root, 'subdir', 'subfile2.txt'),
191 path.join(root, 'subdir', 'subsubdir', 'subsubfile1.txt'), 191 path.join(root, 'subdir', 'subsubdir', 'subsubfile1.txt'),
192 path.join(root, 'subdir', 'subsubdir', 'subsubfile2.txt') 192 path.join(root, 'subdir', 'subsubdir', 'subsubfile2.txt')
193 ]))); 193 ]));
194 }); 194 });
195 }); 195 });
196 196
197 integration("doesn't care if the root is blacklisted", () { 197 integration("doesn't care if the root is blacklisted", () {
198 d.dir(appPath, [ 198 d.dir(appPath, [
199 d.file('file1.txt', 'contents'), 199 d.file('file1.txt', 'contents'),
200 d.file('file2.txt', 'contents'), 200 d.file('file2.txt', 'contents'),
201 d.dir('packages', [ 201 d.dir('packages', [
202 d.file('subfile1.txt', 'subcontents'), 202 d.file('subfile1.txt', 'subcontents'),
203 d.file('subfile2.txt', 'subcontents'), 203 d.file('subfile2.txt', 'subcontents'),
204 d.dir('subsubdir', [ 204 d.dir('subsubdir', [
205 d.file('subsubfile1.txt', 'subsubcontents'), 205 d.file('subsubfile1.txt', 'subsubcontents'),
206 d.file('subsubfile2.txt', 'subsubcontents') 206 d.file('subsubfile2.txt', 'subsubcontents')
207 ]) 207 ])
208 ]) 208 ])
209 ]).create(); 209 ]).create();
210 210
211 schedule(() { 211 schedule(() {
212 expect(entrypoint.packageFiles(beneath: path.join(root, 'packages')), 212 expect(entrypoint.packageFiles(beneath: path.join(root, 'packages')),
213 completion(unorderedEquals([ 213 unorderedEquals([
214 path.join(root, 'packages', 'subfile1.txt'), 214 path.join(root, 'packages', 'subfile1.txt'),
215 path.join(root, 'packages', 'subfile2.txt'), 215 path.join(root, 'packages', 'subfile2.txt'),
216 path.join(root, 'packages', 'subsubdir', 'subsubfile1.txt'), 216 path.join(root, 'packages', 'subsubdir', 'subsubfile1.txt'),
217 path.join(root, 'packages', 'subsubdir', 'subsubfile2.txt') 217 path.join(root, 'packages', 'subsubdir', 'subsubfile2.txt')
218 ]))); 218 ]));
219 }); 219 });
220 }); 220 });
221 }); 221 });
222 } 222 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source/git.dart ('k') | sdk/lib/_internal/pub/test/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698