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

Side by Side Diff: test/discovery_test.dart

Issue 2857383002: Fix write to sink after close in test code. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « pubspec.yaml ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 package_config.discovery_test; 5 library package_config.discovery_test;
6 6
7 import "dart:async"; 7 import "dart:async";
8 import "dart:io"; 8 import "dart:io";
9 import "package:test/test.dart"; 9 import "package:test/test.dart";
10 import "package:package_config/packages.dart"; 10 import "package:package_config/packages.dart";
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 var path = request.uri.path; 283 var path = request.uri.path;
284 if (path.startsWith('/')) path = path.substring(1); 284 if (path.startsWith('/')) path = path.substring(1);
285 if (path.endsWith('/')) path = path.substring(0, path.length - 1); 285 if (path.endsWith('/')) path = path.substring(0, path.length - 1);
286 var parts = path.split('/'); 286 var parts = path.split('/');
287 var fileOrDir = description; 287 var fileOrDir = description;
288 for (int i = 0; i < parts.length; i++) { 288 for (int i = 0; i < parts.length; i++) {
289 fileOrDir = fileOrDir[parts[i]]; 289 fileOrDir = fileOrDir[parts[i]];
290 if (fileOrDir == null) { 290 if (fileOrDir == null) {
291 request.response.statusCode = 404; 291 request.response.statusCode = 404;
292 request.response.close(); 292 request.response.close();
293 return;
293 } 294 }
294 } 295 }
295 request.response.write(fileOrDir); 296 request.response.write(fileOrDir);
296 request.response.close(); 297 request.response.close();
297 }); 298 });
298 }); 299 });
299 }); 300 });
300 tearDown(() => serverSub.cancel()); 301 tearDown(() => serverSub.cancel());
301 test(name, () => httpTest(uri)); 302 test(name, () => httpTest(uri));
302 }); 303 });
303 } 304 }
304 305
305 void generalTest(String name, Map description, Future action(Uri location)) { 306 void generalTest(String name, Map description, Future action(Uri location)) {
306 fileTest(name, description, action); 307 fileTest(name, description, action);
307 httpTest(name, description, action); 308 httpTest(name, description, action);
308 } 309 }
309 310
310 void _createFiles(Directory target, Map description) { 311 void _createFiles(Directory target, Map description) {
311 description.forEach((name, content) { 312 description.forEach((name, content) {
312 if (content is Map) { 313 if (content is Map) {
313 Directory subDir = new Directory(path.join(target.path, name)); 314 Directory subDir = new Directory(path.join(target.path, name));
314 subDir.createSync(); 315 subDir.createSync();
315 _createFiles(subDir, content); 316 _createFiles(subDir, content);
316 } else { 317 } else {
317 File file = new File(path.join(target.path, name)); 318 File file = new File(path.join(target.path, name));
318 file.writeAsStringSync(content, flush: true); 319 file.writeAsStringSync(content, flush: true);
319 } 320 }
320 }); 321 });
321 } 322 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698