| Index: pkg/analyzer_cli/test/utils.dart
|
| diff --git a/pkg/analyzer_cli/test/utils.dart b/pkg/analyzer_cli/test/utils.dart
|
| index 85fa759e16b72da7fac74e1ae24dd2acf1bc107c..3e61ed24fe62dd05849429d147c80ec464fabb2f 100644
|
| --- a/pkg/analyzer_cli/test/utils.dart
|
| +++ b/pkg/analyzer_cli/test/utils.dart
|
| @@ -4,6 +4,7 @@
|
|
|
| library analyzer_cli.test.utils;
|
|
|
| +import 'dart:async';
|
| import 'dart:io';
|
| import 'dart:mirrors';
|
|
|
| @@ -52,4 +53,31 @@ dynamic withTempDir(fn(String path)) {
|
| }
|
| }
|
|
|
| +/// Creates a temporary directory and passes its path to [fn]. Once [fn]
|
| +/// completes, the temporary directory and all its contents will be deleted.
|
| +///
|
| +/// Returns the return value of [fn].
|
| +Future<dynamic> withTempDirAsync(Future<dynamic> fn(String path)) async {
|
| + var tempDir = (await Directory.systemTemp.createTemp('analyzer_')).path;
|
| + try {
|
| + return await fn(tempDir);
|
| + } finally {
|
| + await new Directory(tempDir).delete(recursive: true);
|
| + }
|
| +}
|
| +
|
| +/// Recursively copy the specified [src] directory (or file)
|
| +/// to the specified destination path.
|
| +Future<Null> recursiveCopy(FileSystemEntity src, String dstPath) async {
|
| + if (src is Directory) {
|
| + await (new Directory(dstPath)).create(recursive: true);
|
| + for (FileSystemEntity entity in src.listSync()) {
|
| + await recursiveCopy(
|
| + entity, pathos.join(dstPath, pathos.basename(entity.path)));
|
| + }
|
| + } else if (src is File) {
|
| + await src.copy(dstPath);
|
| + }
|
| +}
|
| +
|
| class _TestUtils {}
|
|
|