mirror of https://github.com/actions/toolkit
Fix tests
parent
1f3371766a
commit
187781e273
|
@ -98,7 +98,7 @@ test('zstd extract tar with windows BSDtar', async () => {
|
||||||
tarFilename.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
tarFilename.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'&&',
|
'&&',
|
||||||
`"${tarPath}"`,
|
`${tarPath}`,
|
||||||
'-xf',
|
'-xf',
|
||||||
tarFilename.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
tarFilename.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'-P',
|
'-P',
|
||||||
|
@ -336,7 +336,7 @@ test('zstd list tar with windows BSDtar', async () => {
|
||||||
tarFilename.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
tarFilename.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'&&',
|
'&&',
|
||||||
`"${tarPath}"`,
|
`${tarPath}`,
|
||||||
'-tf',
|
'-tf',
|
||||||
tarFilename.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
tarFilename.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'-P'
|
'-P'
|
||||||
|
|
|
@ -141,7 +141,8 @@ function getWorkingDirectory(): string {
|
||||||
|
|
||||||
// Common function for extractTar and listTar to get the compression method
|
// Common function for extractTar and listTar to get the compression method
|
||||||
async function getCompressionProgram(
|
async function getCompressionProgram(
|
||||||
compressionMethod: CompressionMethod
|
compressionMethod: CompressionMethod,
|
||||||
|
archivePath: string
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
// -d: Decompress.
|
// -d: Decompress.
|
||||||
// unzstd is equivalent to 'zstd -d'
|
// unzstd is equivalent to 'zstd -d'
|
||||||
|
@ -159,7 +160,7 @@ async function getCompressionProgram(
|
||||||
? [
|
? [
|
||||||
'zstd -d --long=30 -o',
|
'zstd -d --long=30 -o',
|
||||||
tarFile,
|
tarFile,
|
||||||
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'&&'
|
'&&'
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
|
@ -171,7 +172,7 @@ async function getCompressionProgram(
|
||||||
? [
|
? [
|
||||||
'zstd -d -o',
|
'zstd -d -o',
|
||||||
tarFile,
|
tarFile,
|
||||||
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'&&'
|
'&&'
|
||||||
]
|
]
|
||||||
: ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']
|
: ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']
|
||||||
|
@ -188,12 +189,18 @@ export async function listTar(
|
||||||
const BSD_TAR_ZSTD =
|
const BSD_TAR_ZSTD =
|
||||||
tarPath === SystemTarPathOnWindows &&
|
tarPath === SystemTarPathOnWindows &&
|
||||||
compressionMethod !== CompressionMethod.Gzip
|
compressionMethod !== CompressionMethod.Gzip
|
||||||
const compressionArgs = await getCompressionProgram(compressionMethod)
|
const compressionArgs = await getCompressionProgram(
|
||||||
|
compressionMethod,
|
||||||
|
archivePath
|
||||||
|
)
|
||||||
const tarArgs = await getTarArgs(compressionMethod, 'list', archivePath)
|
const tarArgs = await getTarArgs(compressionMethod, 'list', archivePath)
|
||||||
// TODO: Add a test for BSD tar on windows
|
// TODO: Add a test for BSD tar on windows
|
||||||
if (BSD_TAR_ZSTD) {
|
if (BSD_TAR_ZSTD) {
|
||||||
const command = compressionArgs[0]
|
const command = compressionArgs[0]
|
||||||
const args = compressionArgs.slice(1).concat([tarPath]).concat(tarArgs)
|
const args = compressionArgs
|
||||||
|
.slice(1)
|
||||||
|
.concat([tarPath])
|
||||||
|
.concat(tarArgs)
|
||||||
await execCommand(command, args)
|
await execCommand(command, args)
|
||||||
} else {
|
} else {
|
||||||
const args = tarArgs.concat(compressionArgs)
|
const args = tarArgs.concat(compressionArgs)
|
||||||
|
@ -213,10 +220,16 @@ export async function extractTar(
|
||||||
compressionMethod !== CompressionMethod.Gzip
|
compressionMethod !== CompressionMethod.Gzip
|
||||||
await io.mkdirP(workingDirectory)
|
await io.mkdirP(workingDirectory)
|
||||||
const tarArgs = await getTarArgs(compressionMethod, 'extract', archivePath)
|
const tarArgs = await getTarArgs(compressionMethod, 'extract', archivePath)
|
||||||
const compressionArgs = await getCompressionProgram(compressionMethod)
|
const compressionArgs = await getCompressionProgram(
|
||||||
|
compressionMethod,
|
||||||
|
archivePath
|
||||||
|
)
|
||||||
if (BSD_TAR_ZSTD) {
|
if (BSD_TAR_ZSTD) {
|
||||||
const command = compressionArgs[0]
|
const command = compressionArgs[0]
|
||||||
const args = compressionArgs.slice(1).concat([tarPath]).concat(tarArgs)
|
const args = compressionArgs
|
||||||
|
.slice(1)
|
||||||
|
.concat([tarPath])
|
||||||
|
.concat(tarArgs)
|
||||||
await execCommand(command, args)
|
await execCommand(command, args)
|
||||||
} else {
|
} else {
|
||||||
const args = tarArgs.concat(compressionArgs)
|
const args = tarArgs.concat(compressionArgs)
|
||||||
|
|
Loading…
Reference in New Issue