Files
python-versions/tests/python-tests.ps1
Matthieu Darbois 1e1d9f9032 fix: setup OpenSSL certificates in macos-pkg-setup-template.sh (#189)
The macOS pkg installer does not setup default certificates for OpenSSL.
A script is provided by the macOS pkg installer to setup those using the certifi PyPI package.
Let's run this script as part of the setup template in order to be able to do HTTPS downloads out of the box.
2022-10-03 10:13:05 +02:00

104 lines
3.9 KiB
PowerShell

param (
[semver] [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()]
$Version,
[string] [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()]
$Platform
)
Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
Import-Module (Join-Path $PSScriptRoot "../helpers/common-helpers.psm1")
Import-Module (Join-Path $PSScriptRoot "../builders/python-version.psm1")
BeforeAll {
function Analyze-MissingModules([string] $buildOutputLocation) {
$searchStringStart = "Failed to build these modules:"
$searchStringEnd = "running build_scripts"
$pattern = "$searchStringStart(.*?)$searchStringEnd"
$buildContent = Get-Content -Path $buildOutputLocation
$splitBuiltOutput = $buildContent -split "\n";
### Search for missing modules that are displayed between the search strings
$regexMatch = [regex]::match($SplitBuiltOutput, $Pattern)
if ($regexMatch.Success)
{
$module = $regexMatch.Groups[1].Value.Trim()
Write-Host "Failed missing modules:"
Write-Host $module
if ( ($module -eq "_tkinter") -and ( [semver]"$($Version.Major).$($Version.Minor)" -ge [semver]"3.10" -and $Version.PreReleaseLabel ) ) {
Write-Host "$module $Version ignored"
} else {
return 1
}
}
return 0
}
}
Describe "Tests" {
It "Python version" {
"python --version" | Should -ReturnZeroExitCode
$pythonLocation = (Get-Command "python").Path
$pythonLocation | Should -Not -BeNullOrEmpty
$expectedPath = Join-Path -Path $env:RUNNER_TOOL_CACHE -ChildPath "Python"
$pythonLocation.startsWith($expectedPath) | Should -BeTrue
}
It "Run simple code" {
"python ./sources/simple-test.py" | Should -ReturnZeroExitCode
}
# linux has no display name and no $DISPLAY environment variable - skip tk test
# if (-not (($Platform -match "ubuntu") -or ($Platform -match "linux"))) {
# It "Check if tcl/tk has the same headed and library versions" {
# "python ./sources/tcltk.py" | Should -ReturnZeroExitCode
# }
# }
if (($Version -ge "3.2.0") -and -not ([semver]"$($Version.Major).$($Version.Minor)" -eq [semver]"3.11" -and $Version.PreReleaseLabel)) {
It "Check if sqlite3 module is installed" {
"python ./sources/python-sqlite3.py" | Should -ReturnZeroExitCode
}
}
It "Run pip" {
"pip install requests" | Should -ReturnZeroExitCode
"pip uninstall requests -y" | Should -ReturnZeroExitCode
}
if (IsNixPlatform $Platform) {
It "Check for failed modules in build_output" {
$buildOutputLocation = Join-Path $env:RUNNER_TEMP "build_output.txt"
Analyze-MissingModules $buildOutputLocation | Should -Be 0
}
It "Check if all required python modules are installed" {
"python ./sources/python-modules.py" | Should -ReturnZeroExitCode
}
It "Check if python configuration is correct" {
$nativeVersion = Convert-Version -version $Version
"python ./sources/python-config-test.py $Version $nativeVersion" | Should -ReturnZeroExitCode
}
It "Check if shared libraries are linked correctly" {
"bash ./sources/psutil-install-test.sh" | Should -ReturnZeroExitCode
}
}
# Pyinstaller 3.5 does not support Python 3.8.0. Check issue https://github.com/pyinstaller/pyinstaller/issues/4311
if ($Version -lt "3.8.0" -and $Version.Major -ne "2") {
It "Validate Pyinstaller" {
"pip install pyinstaller" | Should -ReturnZeroExitCode
"pyinstaller --onefile ./sources/simple-test.py" | Should -ReturnZeroExitCode
"./dist/simple-test" | Should -ReturnZeroExitCode
}
}
It "Check urlopen with HTTPS works" {
"python ./sources/python-urlopen-https.py" | Should -ReturnZeroExitCode
}
}