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

Unified Diff: utils/tests/pub/descriptor/tar.dart

Issue 12437022: Use scheduled_test for Pub tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: re-upload Created 7 years, 9 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/tests/pub/descriptor/git.dart ('k') | utils/tests/pub/dev_dependency_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/descriptor/tar.dart
diff --git a/utils/tests/pub/descriptor/tar.dart b/utils/tests/pub/descriptor/tar.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ef9b1f320dfef4a2f780fa213dca16f33cb84e95
--- /dev/null
+++ b/utils/tests/pub/descriptor/tar.dart
@@ -0,0 +1,53 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library descriptor.tar;
+
+import 'dart:io';
+import 'dart:async';
+
+import '../../../../pkg/pathos/lib/path.dart' as path;
+import '../../../../pkg/scheduled_test/lib/scheduled_test.dart';
+import '../../../../pkg/scheduled_test/lib/descriptor.dart';
+
+import '../../../pub/io.dart';
+import '../../../pub/utils.dart';
+
+/// Describes a tar file and its contents.
+class TarFileDescriptor extends DirectoryDescriptor {
+ TarFileDescriptor(String name, List<Descriptor> contents)
+ : super(name, contents);
+
+ /// Creates the files and directories within this tar file, then archives
+ /// them, compresses them, and saves the result to [parentDir].
+ Future<String> create([String parent]) => schedule(() {
+ if (parent == null) parent = defaultRoot;
+ return withTempDir((tempDir) {
+ return Future.wait(contents.map((entry) {
+ return entry.create(tempDir);
+ })).then((_) {
+ return listDir(tempDir, recursive: true, includeHiddenFiles: true);
+ }).then((createdContents) {
+ return createTarGz(createdContents, baseDir: tempDir).toBytes();
+ }).then((bytes) {
+ var file = path.join(parent, name);
+ writeBinaryFile(file, bytes);
+ return file;
+ });
+ });
+ }, 'creating tar file:\n${describe()}');
+
+ /// Validates that the `.tar.gz` file at [path] contains the expected
+ /// contents.
+ Future validate([String parent]) {
+ throw "TODO(nweiz): implement this";
+ }
+
+ Stream<List<int>> read() {
+ return new Stream<List<int>>.fromFuture(withTempDir((tempDir) {
+ return create(tempDir).then((_) =>
+ readBinaryFile(path.join(tempDir, name)));
+ }));
+ }
+}
« no previous file with comments | « utils/tests/pub/descriptor/git.dart ('k') | utils/tests/pub/dev_dependency_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698