From 62a66a8ce9ca7e66b1a421b160a0499ae19e0a9e Mon Sep 17 00:00:00 2001 From: Sampark Sharma Date: Tue, 8 Nov 2022 06:43:28 +0000 Subject: [PATCH] Fix tests --- packages/cache/__tests__/tar.test.ts | 4 ++-- packages/cache/src/internal/cacheUtils.ts | 4 +++- packages/cache/src/internal/tar.ts | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/cache/__tests__/tar.test.ts b/packages/cache/__tests__/tar.test.ts index e4233bc9..31af266e 100644 --- a/packages/cache/__tests__/tar.test.ts +++ b/packages/cache/__tests__/tar.test.ts @@ -92,9 +92,9 @@ test('gzip extract tar', async () => { ) }) -test('gzip extract GNU tar on windows', async () => { +test('gzip extract GNU tar on windows with GNUtar in path', async () => { if (IS_WINDOWS) { - jest.spyOn(fs, 'existsSync').mockReturnValueOnce(false) + jest.spyOn(fs, 'existsSync').mockReturnValue(false) const isGnuMock = jest .spyOn(utils, 'isGnuTarInstalled') diff --git a/packages/cache/src/internal/cacheUtils.ts b/packages/cache/src/internal/cacheUtils.ts index 4dd3a614..e6c09eec 100644 --- a/packages/cache/src/internal/cacheUtils.ts +++ b/packages/cache/src/internal/cacheUtils.ts @@ -119,7 +119,9 @@ export function getCacheFileName(compressionMethod: CompressionMethod): string { export async function isGnuTarInstalled(): Promise { const gnuTar = `${process.env['windir']}\\Program Files\\Git\\usr\\bin\\tar.exe` const versionOutput = await getVersion('tar') - return versionOutput.toLowerCase().includes('gnu tar') || fs.existsSync(gnuTar) + return ( + versionOutput.toLowerCase().includes('gnu tar') || fs.existsSync(gnuTar) + ) } export function assertDefined(name: string, value?: T): T { diff --git a/packages/cache/src/internal/tar.ts b/packages/cache/src/internal/tar.ts index 9d5add77..b650f4d0 100644 --- a/packages/cache/src/internal/tar.ts +++ b/packages/cache/src/internal/tar.ts @@ -16,6 +16,7 @@ async function getTarPath( const systemTar = `${process.env['windir']}\\System32\\tar.exe` const gnuTar = `${process.env['windir']}\\Program Files\\Git\\usr\\bin\\tar.exe` if (existsSync(gnuTar)) { + // Making GNUtar + zstd as default on windows args.push('--force-local') return gnuTar } else if (compressionMethod !== CompressionMethod.Gzip) {