Skip to content

Commit bb1c3b9

Browse files
committed
add tests for executable file
1 parent b910f85 commit bb1c3b9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/core/src/test/shared/utilities/testUtils.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
import assert from 'assert'
6-
import { envWithNewPath, readEnv, setEnv } from '../../testUtil'
6+
import { createExecutableFile, createTestWorkspaceFolder, envWithNewPath, readEnv, setEnv } from '../../testUtil'
7+
import path from 'path'
8+
import { ChildProcess } from '../../../shared/utilities/processUtils'
9+
import { fs } from '../../../shared'
710

811
describe('envWithNewPath', function () {
912
it('gives current path with new PATH', function () {
@@ -23,3 +26,18 @@ describe('writeEnv', function () {
2326
assert.deepStrictEqual(readEnv(), originalEnv)
2427
})
2528
})
29+
30+
describe('createExecutableFile', function () {
31+
it('creates a file that can be executes in a child process', async function () {
32+
const tempDir = await createTestWorkspaceFolder()
33+
const filePath = path.join(tempDir.uri.fsPath, 'exec')
34+
await createExecutableFile(filePath, '')
35+
36+
const proc = new ChildProcess(filePath)
37+
const result = await proc.run()
38+
assert.ok(result)
39+
assert.ok(result.exitCode === 0)
40+
41+
await fs.delete(tempDir.uri, { force: true, recursive: true })
42+
})
43+
})

0 commit comments

Comments
 (0)