1
0
Fork 0

Unit test (#236)

pull/237/head
eric sciple 2019-12-03 14:18:54 -05:00 committed by GitHub
parent d98e55434d
commit 211b25966b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 0 deletions

View File

@ -575,6 +575,36 @@ describe('@actions/exec', () => {
}) })
if (IS_WINDOWS) { if (IS_WINDOWS) {
it('Exec roots relative tool path using process.cwd (Windows path separator)', async () => {
let exitCode: number
const command = 'scripts\\print-args-cmd' // let ToolRunner resolve the extension
const execOptions = getExecOptions()
const outStream = new StringStream()
execOptions.outStream = outStream
let output = ''
execOptions.listeners = {
stdout: (data: Buffer) => {
output += data.toString()
}
}
const originalCwd = process.cwd()
try {
process.chdir(__dirname)
exitCode = await exec.exec(`${command} hello world`, [], execOptions)
} catch (err) {
process.chdir(originalCwd)
throw err
}
expect(exitCode).toBe(0)
const toolPath = path.resolve(__dirname, `${command}.cmd`)
expect(outStream.getContents().split(os.EOL)[0]).toBe(
`[command]${process.env.ComSpec} /D /S /C "${toolPath} hello world"`
)
expect(output.trim()).toBe(`args[0]: "hello"${os.EOL}args[1]: "world"`)
})
// Win specific quoting tests // Win specific quoting tests
it('execs .exe with verbatim args (Windows)', async () => { it('execs .exe with verbatim args (Windows)', async () => {
const exePath = process.env.ComSpec const exePath = process.env.ComSpec