mirror of https://github.com/aminya/setup-cpp
Merge pull request #94 from aminya/python-test
This commit is contained in:
commit
af7919aa41
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,37 @@
|
||||||
|
import { setupPython } from "../python"
|
||||||
|
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
|
import { getVersion } from "../../default_versions"
|
||||||
|
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
||||||
|
import { isGitHubCI } from "../../utils/env/isci"
|
||||||
|
|
||||||
|
jest.setTimeout(300000)
|
||||||
|
describe("setup-python", () => {
|
||||||
|
let directory: string
|
||||||
|
beforeAll(async () => {
|
||||||
|
directory = await setupTmpDir("python")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should setup python in GitHub Actions", async () => {
|
||||||
|
if (isGitHubCI()) {
|
||||||
|
const installInfo = await setupPython(
|
||||||
|
getVersion("python", "true", await ubuntuVersion()),
|
||||||
|
directory,
|
||||||
|
process.arch
|
||||||
|
)
|
||||||
|
|
||||||
|
await testBin("python", ["--version"], installInfo?.binDir)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should setup python via system", async () => {
|
||||||
|
process.env.CI = "false"
|
||||||
|
|
||||||
|
const installInfo = await setupPython(getVersion("python", "true", await ubuntuVersion()), directory, process.arch)
|
||||||
|
|
||||||
|
await testBin("python", ["--version"], installInfo?.binDir)
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await cleanupTmpDir("python")
|
||||||
|
}, 100000)
|
||||||
|
})
|
|
@ -6,6 +6,9 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import { isGitHubCI } from "../utils/env/isci"
|
import { isGitHubCI } from "../utils/env/isci"
|
||||||
import { warning, info } from "../utils/io/io"
|
import { warning, info } from "../utils/io/io"
|
||||||
import { isArch } from "../utils/env/isArch"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
import which from "which"
|
||||||
|
import { InstallationInfo } from "../utils/setup/setupBin"
|
||||||
|
import { dirname, join } from "path"
|
||||||
|
|
||||||
export async function setupPython(version: string, setupDir: string, arch: string) {
|
export async function setupPython(version: string, setupDir: string, arch: string) {
|
||||||
if (!isGitHubCI()) {
|
if (!isGitHubCI()) {
|
||||||
|
@ -21,8 +24,12 @@ export async function setupPython(version: string, setupDir: string, arch: strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
export async function setupPythonViaSystem(
|
||||||
export async function setupPythonViaSystem(version: string, setupDir: string, _arch: string) {
|
version: string,
|
||||||
|
setupDir: string,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_arch: string
|
||||||
|
): Promise<InstallationInfo> {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
if (setupDir) {
|
if (setupDir) {
|
||||||
|
@ -30,11 +37,15 @@ export async function setupPythonViaSystem(version: string, setupDir: string, _a
|
||||||
} else {
|
} else {
|
||||||
await setupChocoPack("python3", version)
|
await setupChocoPack("python3", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding the bin dir to the path
|
// Adding the bin dir to the path
|
||||||
|
const pythonBinPath =
|
||||||
|
which.sync("python3.exe", { nothrow: true }) ??
|
||||||
|
which.sync("python.exe", { nothrow: true }) ??
|
||||||
|
join(setupDir, "python.exe")
|
||||||
|
const pythonSetupDir = dirname(pythonBinPath)
|
||||||
/** The directory which the tool is installed to */
|
/** The directory which the tool is installed to */
|
||||||
await activateWinPython(setupDir)
|
await activateWinPython(pythonSetupDir)
|
||||||
return { installDir: setupDir, binDir: setupDir }
|
return { installDir: pythonSetupDir, binDir: pythonSetupDir }
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
return setupBrewPack("python3", version)
|
return setupBrewPack("python3", version)
|
||||||
|
|
Loading…
Reference in New Issue