From ea9856079f362753e8dc557c7ff97d2991a6a2a0 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Thu, 17 Nov 2022 08:53:46 +0000 Subject: [PATCH] Fix tar tests --- packages/cache/__tests__/tar.test.ts | 19 ++++++++++--------- packages/cache/src/internal/tar.ts | 8 ++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/cache/__tests__/tar.test.ts b/packages/cache/__tests__/tar.test.ts index 31f9bd5e..ec214181 100644 --- a/packages/cache/__tests__/tar.test.ts +++ b/packages/cache/__tests__/tar.test.ts @@ -149,17 +149,17 @@ test('zstd create tar', async () => { `"${tarPath}"`, [ '--posix', - '--use-compress-program', - IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30', - '-cf', - IS_WINDOWS ? CacheFilename.Zstd.replace(/\\/g, '/') : CacheFilename.Zstd, '--exclude', IS_WINDOWS ? CacheFilename.Zstd.replace(/\\/g, '/') : CacheFilename.Zstd, '-P', '-C', IS_WINDOWS ? workspace?.replace(/\\/g, '/') : workspace, '--files-from', - 'manifest.txt' + 'manifest.txt', + '--use-compress-program', + IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30', + '-cf', + IS_WINDOWS ? CacheFilename.Zstd.replace(/\\/g, '/') : CacheFilename.Zstd ] .concat(IS_WINDOWS ? ['--force-local'] : []) .concat(IS_MAC ? ['--delay-directory-restore'] : []), @@ -187,16 +187,16 @@ test('gzip create tar', async () => { `"${tarPath}"`, [ '--posix', - '-z', - '-cf', - IS_WINDOWS ? CacheFilename.Gzip.replace(/\\/g, '/') : CacheFilename.Gzip, '--exclude', IS_WINDOWS ? CacheFilename.Gzip.replace(/\\/g, '/') : CacheFilename.Gzip, '-P', '-C', IS_WINDOWS ? workspace?.replace(/\\/g, '/') : workspace, '--files-from', - 'manifest.txt' + 'manifest.txt', + '-z', + '-cf', + IS_WINDOWS ? CacheFilename.Gzip.replace(/\\/g, '/') : CacheFilename.Gzip, ] .concat(IS_WINDOWS ? ['--force-local'] : []) .concat(IS_MAC ? ['--delay-directory-restore'] : []), @@ -281,3 +281,4 @@ test('gzip list tar', async () => { {cwd: undefined} ) }) + diff --git a/packages/cache/src/internal/tar.ts b/packages/cache/src/internal/tar.ts index 2cabe3b4..450cde3b 100644 --- a/packages/cache/src/internal/tar.ts +++ b/packages/cache/src/internal/tar.ts @@ -69,13 +69,12 @@ async function getCompressionProgram(compressionMethod: CompressionMethod): Prom return [ '--use-compress-program', IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30', - '-tf' ] case CompressionMethod.ZstdWithoutLong: if (BSD_TAR_ZSTD) { return ['a'] // auto-detect compression } - return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd', '-tf'] + return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd'] default: return ['-z'] } @@ -87,6 +86,7 @@ export async function listTar( ): Promise { const args = [ ...(await getCompressionProgram(compressionMethod)), + '-tf', archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P' ] @@ -101,8 +101,8 @@ export async function extractTar( const workingDirectory = getWorkingDirectory() await io.mkdirP(workingDirectory) const args = [ - '-xf', ...(await getCompressionProgram(compressionMethod)), + '-xf', archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', @@ -153,7 +153,7 @@ export async function createTar( } return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt', '-cf'] default: - return ['-z'] + return ['-z', '-cf'] } } const args = [