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

Side by Side Diff: test/descriptor/tar.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 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 | « test/descriptor/packages.dart ('k') | test/implicit_barback_dependency_test.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) 2013, the Dart project authors. Please see the AUTHORS file 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 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:path/path.dart' as path; 7 import 'package:path/path.dart' as path;
8 import 'package:pub/src/io.dart'; 8 import 'package:pub/src/io.dart';
9 import 'package:scheduled_test/scheduled_test.dart'; 9 import 'package:scheduled_test/scheduled_test.dart';
10 import 'package:scheduled_test/descriptor.dart'; 10 import 'package:scheduled_test/descriptor.dart';
11 11
12 12
13 /// Describes a tar file and its contents. 13 /// Describes a tar file and its contents.
14 class TarFileDescriptor extends DirectoryDescriptor 14 class TarFileDescriptor extends DirectoryDescriptor
15 implements ReadableDescriptor { 15 implements ReadableDescriptor {
16 TarFileDescriptor(String name, List<Descriptor> contents) 16 TarFileDescriptor(String name, List<Descriptor> contents)
17 : super(name, contents); 17 : super(name, contents);
18 18
19 /// Creates the files and directories within this tar file, then archives 19 /// Creates the files and directories within this tar file, then archives
20 /// them, compresses them, and saves the result to [parentDir]. 20 /// them, compresses them, and saves the result to [parentDir].
21 Future<String> create([String parent]) => schedule(() { 21 Future<String> create([String parent]) {
22 if (parent == null) parent = defaultRoot; 22 return schedule/*<Future<String>>*/(() async {
23 return withTempDir((tempDir) { 23 if (parent == null) parent = defaultRoot;
24 return Future.wait(contents.map((entry) { 24 return await withTempDir((tempDir) async {
25 return entry.create(tempDir); 25 await Future.wait(contents.map((entry) => entry.create(tempDir)));
26 })).then((_) { 26
27 var createdContents = listDir(tempDir, 27 var createdContents = listDir(tempDir,
28 recursive: true, 28 recursive: true,
29 includeHidden: true); 29 includeHidden: true);
30 return createTarGz(createdContents, baseDir: tempDir).toBytes(); 30 var bytes = await createTarGz(createdContents, baseDir: tempDir)
31 }).then((bytes) { 31 .toBytes();
32
32 var file = path.join(parent, name); 33 var file = path.join(parent, name);
33 writeBinaryFile(file, bytes); 34 writeBinaryFile(file, bytes);
34 return file; 35 return file;
35 }); 36 });
36 }); 37 }, 'creating tar file:\n${describe()}');
37 }, 'creating tar file:\n${describe()}'); 38 }
38 39
39 /// Validates that the `.tar.gz` file at [path] contains the expected 40 /// Validates that the `.tar.gz` file at [path] contains the expected
40 /// contents. 41 /// contents.
41 Future validate([String parent]) { 42 Future validate([String parent]) {
42 throw new UnimplementedError("TODO(nweiz): implement this"); 43 throw new UnimplementedError("TODO(nweiz): implement this");
43 } 44 }
44 45
45 Stream<List<int>> read() { 46 Stream<List<int>> read() {
46 return new Stream<List<int>>.fromFuture(withTempDir((tempDir) { 47 return new Stream<List<int>>.fromFuture(withTempDir((tempDir) {
47 return create(tempDir).then((_) => 48 return create(tempDir).then((_) =>
48 readBinaryFile(path.join(tempDir, name))); 49 readBinaryFile(path.join(tempDir, name)));
49 })); 50 }));
50 } 51 }
51 } 52 }
OLDNEW
« no previous file with comments | « test/descriptor/packages.dart ('k') | test/implicit_barback_dependency_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698