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

Side by Side Diff: pkg/barback/test/too_many_open_files_test.dart

Issue 808713003: Remove barback from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 library barback.test.too_many_open_files_test;
6
7 import 'dart:async';
8 import 'dart:io';
9
10 import 'package:barback/barback.dart';
11 import 'package:path/path.dart' as pathos;
12 import 'package:unittest/unittest.dart';
13
14 import 'utils.dart';
15
16 main() {
17 initConfig();
18
19 test("handles many simultaneous asset read() calls", () {
20 runOnManyFiles((asset) => asset.read().toList());
21 });
22
23 test("handles many simultaneous asset readToString() calls", () {
24 runOnManyFiles((asset) => asset.readAsString());
25 });
26 }
27
28 runOnManyFiles(Future assetHandler(Asset asset)) {
29 // Make a text file in a temp directory.
30 var tempDir = Directory.systemTemp.createTempSync("barback").path;
31 var filePath = pathos.join(tempDir, "out.txt");
32
33 // Make sure it's large enough to not be read in a single chunk.
34 var contents = new StringBuffer();
35 for (var i = 0; i < 1024; i++) {
36 contents.write(
37 "this is a sixty four character long string that describes itself");
38 }
39
40 new File(filePath).writeAsStringSync(contents.toString());
41
42 var id = new AssetId("myapp", "out.txt");
43
44 // Create a large number of assets, larger than the file descriptor limit
45 // of most machines and start reading from all of them.
46 var futures = [];
47 for (var i = 0; i < 1000; i++) {
48 var asset = new Asset.fromPath(id, filePath);
49 futures.add(assetHandler(asset));
50 }
51
52 expect(Future.wait(futures).whenComplete(() {
53 new Directory(tempDir).delete(recursive: true);
54 }), completes);
55 }
OLDNEW
« no previous file with comments | « pkg/barback/test/stream_replayer_test.dart ('k') | pkg/barback/test/transformer/aggregate_many_to_many.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698