update hash files test
This commit is contained in:
1 parent
2c52de36fd
commit
c74c7fc4ed
3 files changed
+52
-62
No files matched your search
+11
-60
@@ -11,6 +11,11 @@ import * as io from '@actions/io'
|
|||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
const SPAWN_WAIT_FOR_FILE = path.join(
|
||||||
|
__dirname,
|
||||||
|
'scripts',
|
||||||
|
'spawn-wait-for-file.js'
|
||||||
|
)
|
||||||
|
|
||||||
let outstream: stream.Writable
|
let outstream: stream.Writable
|
||||||
let errstream: stream.Writable
|
let errstream: stream.Writable
|
||||||
@@ -365,35 +370,18 @@ describe('@actions/exec', () => {
|
|||||||
fs.writeFileSync(semaphorePath, '')
|
fs.writeFileSync(semaphorePath, '')
|
||||||
|
|
||||||
const nodePath = await io.which('node', true)
|
const nodePath = await io.which('node', true)
|
||||||
const scriptPath = path.join(__dirname, 'scripts', 'wait-for-file.js')
|
|
||||||
const debugList: string[] = []
|
const debugList: string[] = []
|
||||||
const _testExecOptions = getExecOptions()
|
const _testExecOptions = getExecOptions()
|
||||||
_testExecOptions.delay = 500
|
_testExecOptions.delay = 500
|
||||||
_testExecOptions.windowsVerbatimArguments = true
|
|
||||||
_testExecOptions.listeners = {
|
_testExecOptions.listeners = {
|
||||||
debug: (data: string) => {
|
debug: (data: string) => {
|
||||||
debugList.push(data)
|
debugList.push(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let exitCode: number
|
const args = [SPAWN_WAIT_FOR_FILE, `file=${semaphorePath}`]
|
||||||
if (IS_WINDOWS) {
|
|
||||||
const toolName: string = await io.which('cmd.exe', true)
|
|
||||||
const args = [
|
|
||||||
'/D', // Disable execution of AutoRun commands from registry.
|
|
||||||
'/E:ON', // Enable command extensions. Note, command extensions are enabled by default, unless disabled via registry.
|
|
||||||
'/V:OFF', // Disable delayed environment expansion. Note, delayed environment expansion is disabled by default, unless enabled via registry.
|
|
||||||
'/S', // Will cause first and last quote after /C to be stripped.
|
|
||||||
'/C',
|
|
||||||
`"start "" /B "${nodePath}" "${scriptPath}" "file=${semaphorePath}""`
|
|
||||||
]
|
|
||||||
exitCode = await exec.exec(`"${toolName}"`, args, _testExecOptions)
|
|
||||||
} else {
|
|
||||||
const toolName: string = await io.which('bash', true)
|
|
||||||
const args = ['-c', `node '${scriptPath}' 'file=${semaphorePath}' &`]
|
|
||||||
|
|
||||||
exitCode = await exec.exec(`"${toolName}"`, args, _testExecOptions)
|
const exitCode = await exec.exec(`"${nodePath}"`, args, _testExecOptions)
|
||||||
}
|
|
||||||
|
|
||||||
expect(exitCode).toBe(0)
|
expect(exitCode).toBe(0)
|
||||||
expect(
|
expect(
|
||||||
@@ -411,36 +399,19 @@ describe('@actions/exec', () => {
|
|||||||
fs.writeFileSync(semaphorePath, '')
|
fs.writeFileSync(semaphorePath, '')
|
||||||
|
|
||||||
const nodePath = await io.which('node', true)
|
const nodePath = await io.which('node', true)
|
||||||
const scriptPath = path.join(__dirname, 'scripts', 'wait-for-file.js')
|
|
||||||
const debugList: string[] = []
|
const debugList: string[] = []
|
||||||
const _testExecOptions = getExecOptions()
|
const _testExecOptions = getExecOptions()
|
||||||
_testExecOptions.delay = 500
|
_testExecOptions.delay = 500
|
||||||
_testExecOptions.windowsVerbatimArguments = true
|
|
||||||
_testExecOptions.listeners = {
|
_testExecOptions.listeners = {
|
||||||
debug: (data: string) => {
|
debug: (data: string) => {
|
||||||
debugList.push(data)
|
debugList.push(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let toolName: string
|
const args = [SPAWN_WAIT_FOR_FILE, `file=${semaphorePath}`, 'exitCode=123']
|
||||||
let args: string[]
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
toolName = await io.which('cmd.exe', true)
|
|
||||||
args = [
|
|
||||||
'/D', // Disable execution of AutoRun commands from registry.
|
|
||||||
'/E:ON', // Enable command extensions. Note, command extensions are enabled by default, unless disabled via registry.
|
|
||||||
'/V:OFF', // Disable delayed environment expansion. Note, delayed environment expansion is disabled by default, unless enabled via registry.
|
|
||||||
'/S', // Will cause first and last quote after /C to be stripped.
|
|
||||||
'/C',
|
|
||||||
`"start "" /B "${nodePath}" "${scriptPath}" "file=${semaphorePath}"" & exit /b 123`
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
toolName = await io.which('bash', true)
|
|
||||||
args = ['-c', `node '${scriptPath}' 'file=${semaphorePath}' & exit 123`]
|
|
||||||
}
|
|
||||||
|
|
||||||
await exec
|
await exec
|
||||||
.exec(`"${toolName}"`, args, _testExecOptions)
|
.exec(`"${nodePath}"`, args, _testExecOptions)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
throw new Error('Should not have succeeded')
|
throw new Error('Should not have succeeded')
|
||||||
})
|
})
|
||||||
@@ -465,40 +436,20 @@ describe('@actions/exec', () => {
|
|||||||
fs.writeFileSync(semaphorePath, '')
|
fs.writeFileSync(semaphorePath, '')
|
||||||
|
|
||||||
const nodePath = await io.which('node', true)
|
const nodePath = await io.which('node', true)
|
||||||
const scriptPath = path.join(__dirname, 'scripts', 'wait-for-file.js')
|
|
||||||
const debugList: string[] = []
|
const debugList: string[] = []
|
||||||
const _testExecOptions = getExecOptions()
|
const _testExecOptions = getExecOptions()
|
||||||
_testExecOptions.delay = 500
|
_testExecOptions.delay = 500
|
||||||
_testExecOptions.failOnStdErr = true
|
_testExecOptions.failOnStdErr = true
|
||||||
_testExecOptions.windowsVerbatimArguments = true
|
|
||||||
_testExecOptions.listeners = {
|
_testExecOptions.listeners = {
|
||||||
debug: (data: string) => {
|
debug: (data: string) => {
|
||||||
debugList.push(data)
|
debugList.push(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let toolName: string
|
const args = [SPAWN_WAIT_FOR_FILE, `file=${semaphorePath}`, 'stderr=true']
|
||||||
let args: string[]
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
toolName = await io.which('cmd.exe', true)
|
|
||||||
args = [
|
|
||||||
'/D', // Disable execution of AutoRun commands from registry.
|
|
||||||
'/E:ON', // Enable command extensions. Note, command extensions are enabled by default, unless disabled via registry.
|
|
||||||
'/V:OFF', // Disable delayed environment expansion. Note, delayed environment expansion is disabled by default, unless enabled via registry.
|
|
||||||
'/S', // Will cause first and last quote after /C to be stripped.
|
|
||||||
'/C',
|
|
||||||
`"start "" /B "${nodePath}" "${scriptPath}" "file=${semaphorePath}"" & echo hi 1>&2`
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
toolName = await io.which('bash', true)
|
|
||||||
args = [
|
|
||||||
'-c',
|
|
||||||
`node '${scriptPath}' 'file=${semaphorePath}' & echo hi 1>&2`
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
await exec
|
await exec
|
||||||
.exec(`"${toolName}"`, args, _testExecOptions)
|
.exec(`"${nodePath}"`, args, _testExecOptions)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
throw new Error('Should not have succeeded')
|
throw new Error('Should not have succeeded')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
const childProcess = require('child_process')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
function parseArgs() {
|
||||||
|
const result = {}
|
||||||
|
for (const arg of process.argv.slice(2)) {
|
||||||
|
const equalsIndex = arg.indexOf('=')
|
||||||
|
if (equalsIndex === -1) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const key = arg.slice(0, equalsIndex)
|
||||||
|
const value = arg.slice(equalsIndex + 1)
|
||||||
|
result[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
const args = parseArgs()
|
||||||
|
const filePath = args.file
|
||||||
|
if (!filePath) {
|
||||||
|
throw new Error('file is not specified')
|
||||||
|
}
|
||||||
|
|
||||||
|
const waitScript = path.join(__dirname, 'wait-for-file.js')
|
||||||
|
const waitArgs = [waitScript, `file=${filePath}`]
|
||||||
|
const waitProcess = childProcess.spawn(process.execPath, waitArgs, {
|
||||||
|
stdio: 'inherit',
|
||||||
|
detached: false
|
||||||
|
})
|
||||||
|
|
||||||
|
waitProcess.unref()
|
||||||
|
|
||||||
|
if (args.stderr === 'true') {
|
||||||
|
process.stderr.write('hi')
|
||||||
|
}
|
||||||
|
|
||||||
|
const exitCode = args.exitCode ? parseInt(args.exitCode, 10) : 0
|
||||||
|
process.exit(exitCode)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
//first half of © character
|
//first half of © character
|
||||||
process.stdout.write(Buffer.from([0xC2]), (err) => {
|
process.stdout.write(Buffer.from([0xC2]), () => {
|
||||||
//write in the callback so that the second byte is sent separately
|
//write in the callback so that the second byte is sent separately
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
process.stdout.write(Buffer.from([0xA9])) //second half of © character
|
process.stdout.write(Buffer.from([0xA9])) //second half of © character
|
||||||
}, 5000)
|
}, 100)
|
||||||
|
|
||||||
})
|
})
|
||||||
Reference in new issue
Block a user