mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-22 12:49:06 +08:00
Fix windows test
This commit is contained in:
parent
32b95825ba
commit
32f538163d
23
packages/cache/__tests__/tar.test.ts
vendored
23
packages/cache/__tests__/tar.test.ts
vendored
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user