Fix windows test

This commit is contained in:
Sampark Sharma 2022-11-21 12:51:07 +00:00 committed by GitHub
parent 32b95825ba
commit 32f538163d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,8 @@ import * as path from 'path'
import { import {
CacheFilename, CacheFilename,
CompressionMethod, CompressionMethod,
GnuTarPathOnWindows GnuTarPathOnWindows,
SystemTarPathOnWindows
} from '../src/internal/constants' } from '../src/internal/constants'
import * as tar from '../src/internal/tar' import * as tar from '../src/internal/tar'
import * as utils from '../src/internal/cacheUtils' import * as utils from '../src/internal/cacheUtils'
@ -179,33 +180,33 @@ test('zstd create tar with windows BSDtar', async () => {
const archiveFolder = getTempDir() const archiveFolder = getTempDir()
const workspace = process.env['GITHUB_WORKSPACE'] const workspace = process.env['GITHUB_WORKSPACE']
const sourceDirectories = ['~/.npm/cache', `${workspace}/dist`] const sourceDirectories = ['~/.npm/cache', `${workspace}/dist`]
const tarFilename = "cache.tar"
await fs.promises.mkdir(archiveFolder, {recursive: true}) await fs.promises.mkdir(archiveFolder, {recursive: true})
await tar.createTar(archiveFolder, sourceDirectories, CompressionMethod.Zstd) await tar.createTar(archiveFolder, sourceDirectories, CompressionMethod.Zstd)
const tarPath = IS_WINDOWS ? GnuTarPathOnWindows : defaultTarPath const tarPath = SystemTarPathOnWindows
// expect(isGnuMock).toHaveBeenCalledTimes(1) expect(isGnuMock).toHaveBeenCalledTimes(1)
expect(execMock).toHaveBeenCalledTimes(1) expect(execMock).toHaveBeenCalledTimes(1)
expect(execMock).toHaveBeenCalledWith( expect(execMock).toHaveBeenCalledWith(
`"${tarPath}"`, `"${tarPath}"`,
[ [
'--posix', '--posix',
'-cf', '-cf',
IS_WINDOWS ? CacheFilename.Zstd.replace(/\\/g, '/') : CacheFilename.Zstd, tarFilename.replace(/\\/g, '/'),
'--exclude', '--exclude',
IS_WINDOWS ? CacheFilename.Zstd.replace(/\\/g, '/') : CacheFilename.Zstd, tarFilename.replace(/\\/g, '/'),
'-P', '-P',
'-C', '-C',
IS_WINDOWS ? workspace?.replace(/\\/g, '/') : workspace, workspace?.replace(/\\/g, '/'),
'--files-from', '--files-from',
'manifest.txt', 'manifest.txt',
'--use-compress-program', "&&",
IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30' "zstd -T0 --long=30 -o",
] CacheFilename.Zstd.replace(/\\/g, '/')
.concat(IS_WINDOWS ? ['--force-local'] : []) ],
.concat(IS_MAC ? ['--delay-directory-restore'] : []),
{ {
cwd: archiveFolder cwd: archiveFolder
} }