From f18502da97a0fda907bbfc98f8e3342a415532d9 Mon Sep 17 00:00:00 2001 From: Bob Nystrom <rnystrom@google.com> Date: Wed, 15 Mar 2017 16:04:02 -0700 Subject: [PATCH] Get the Mac tests passing again with the mtree stuff in tar. --- lib/src/io.dart | 9 ++++++++- test/descriptor/tar.dart | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/src/io.dart b/lib/src/io.dart index b17d8e6e..66b3621e 100644 --- a/lib/src/io.dart +++ b/lib/src/io.dart @@ -1060,6 +1060,8 @@ ByteStream createTarGz(List contents, {String baseDir}) { // The ustar format doesn't support large UIDs. We don't care about // preserving ownership anyway, so we just set them to "pub". + // TODO(rnystrom): This assumes contents does not contain any + // directories. var mtreeHeader = "#mtree\n/set uname=pub gname=pub type=file\n"; // We need a newline at the end, otherwise the last file would get @@ -1067,7 +1069,12 @@ ByteStream createTarGz(List contents, {String baseDir}) { stdin = mtreeHeader + contents.join("\n") + "\n"; } - var process = await startProcess("tar", args); + // Setting the working directory should be unnecessary since we pass an + // explicit base directory to tar. However, on Mac when using an mtree + // input file, relative paths in the mtree file are interpreted as + // relative to the current working directory, not the "--directory" + // argument. + var process = await startProcess("tar", args, workingDir: baseDir); process.stdin.add(UTF8.encode(stdin)); process.stdin.close(); return process.stdout; diff --git a/test/descriptor/tar.dart b/test/descriptor/tar.dart index 03cf2a06..5c16509e 100644 --- a/test/descriptor/tar.dart +++ b/test/descriptor/tar.dart @@ -23,8 +23,8 @@ class TarFileDescriptor extends DirectoryDescriptor return await withTempDir((tempDir) async { await Future.wait(contents.map((entry) => entry.create(tempDir))); - var createdContents = - listDir(tempDir, recursive: true, includeHidden: true); + var createdContents = listDir(tempDir, + recursive: true, includeHidden: true, includeDirs: false); var bytes = await createTarGz(createdContents, baseDir: tempDir).toBytes(); -- GitLab