Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .vsts-ci/linux-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ stages:
jobs:
- template: templates/ci-build.yml
parameters:
pool: ubuntu-16.04
pool: ubuntu-20.04
jobName: linux_build
displayName: linux Build

Expand All @@ -56,7 +56,7 @@ stages:
jobs:
- job: linux_test
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-20.04
displayName: Linux Test

steps:
Expand Down Expand Up @@ -149,7 +149,7 @@ stages:
- job: CodeCovTestPackage
displayName: CodeCoverage and Test Packages
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-20.04
steps:
- pwsh: |
Import-Module .\tools\ci.psm1
Expand Down
16 changes: 8 additions & 8 deletions .vsts-ci/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ stages:
jobs:
- template: templates/ci-build.yml
parameters:
pool: ubuntu-16.04
pool: ubuntu-20.04
jobName: linux_build
displayName: linux Build

Expand All @@ -62,42 +62,42 @@ stages:
- template: templates/nix-test.yml
parameters:
name: Linux
pool: ubuntu-16.04
pool: ubuntu-20.04
purpose: UnelevatedPesterTests
tagSet: CI

- template: templates/nix-test.yml
parameters:
name: Linux
pool: ubuntu-16.04
pool: ubuntu-20.04
purpose: ElevatedPesterTests
tagSet: CI

- template: templates/nix-test.yml
parameters:
name: Linux
pool: ubuntu-16.04
pool: ubuntu-20.04
purpose: UnelevatedPesterTests
tagSet: Others

- template: templates/nix-test.yml
parameters:
name: Linux
pool: ubuntu-16.04
pool: ubuntu-20.04
purpose: ElevatedPesterTests
tagSet: Others

- template: templates/verify-xunit.yml
parameters:
pool: ubuntu-16.04
pool: ubuntu-20.04

- stage: PackageLinux
displayName: Package Linux
dependsOn: ["BuildLinux"]
jobs:
- template: linux/templates/packaging.yml
parameters:
pool: ubuntu-16.04
pool: ubuntu-20.04

- stage: CodeCovTestPackage
displayName: CodeCoverage and Test Packages
Expand All @@ -106,7 +106,7 @@ stages:
- job: CodeCovTestPackage
displayName: CodeCoverage and Test Packages
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-20.04
steps:
- pwsh: |
Import-Module .\tools\ci.psm1
Expand Down
2 changes: 1 addition & 1 deletion .vsts-ci/linux/templates/packaging.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
pool: 'ubuntu-16.04'
pool: 'ubuntu-20.04'
parentJobs: []
name: 'Linux'

Expand Down
2 changes: 1 addition & 1 deletion .vsts-ci/misc-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
displayName: Markdown and Common Tests

pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-20.04

variables:
- name: repoPath
Expand Down
12 changes: 12 additions & 0 deletions .vsts-ci/templates/nix-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ jobs:
continueOnError: true

- pwsh: |
Import-Module .\build.psm1 -Force
$environment = Get-EnvironmentInformation
$isUbuntu20 = $environment.IsUbuntu -and $environment.IsUbuntu20
if ($isUbuntu20) {
$env:LC_ALL='en_US.UTF-8'
$env:LANG='en_US.UTF-8'
sudo locale-gen $LANG
sudo update-locale
}

locale

Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
$options = (Get-PSOptions)
Expand Down
25 changes: 22 additions & 3 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,13 @@ function Start-PSPester {

if ($Unelevate)
{
$outputBufferFilePath = [System.IO.Path]::GetTempFileName()
if ($environment.IsWindows) {
$outputBufferFilePath = [System.IO.Path]::GetTempFileName()
}
else {
# Azure DevOps agents do not have Temp folder setup on Ubuntu 20.04, hence using HOME directory
$outputBufferFilePath = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
Comment thread
adityapatwardhan marked this conversation as resolved.
Resolved
}
}

$command += "Invoke-Pester "
Expand Down Expand Up @@ -1305,7 +1311,14 @@ function Start-PSPester {

$PSFlags = @("-noprofile")
if (-not [string]::IsNullOrEmpty($ExperimentalFeatureName)) {
$configFile = [System.IO.Path]::GetTempFileName()

if ($environment.IsWindows) {
$configFile = [System.IO.Path]::GetTempFileName()
}
else {
$configFile = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
}

$configFile = [System.IO.Path]::ChangeExtension($configFile, ".json")

## Create the config.json file to enable the given experimental feature.
Expand Down Expand Up @@ -1384,7 +1397,13 @@ function Start-PSPester {
{
if ($PassThru.IsPresent)
{
$passThruFile = [System.IO.Path]::GetTempFileName()
if ($environment.IsWindows) {
$passThruFile = [System.IO.Path]::GetTempFileName()
}
else {
$passThruFile = Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())
}

try
{
$command += "| Export-Clixml -Path '$passThruFile' -Force"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ Describe "Custom type conversion in parameter binding" -Tags 'Feature' {
}
}
'@
$asmFile = [System.IO.Path]::GetTempFileName() + ".dll"
if ($IsWindows) {
$asmFile = [System.IO.Path]::GetTempFileName() + ".dll"
}
else {
$asmFile = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName() + ".dll"))
}

Add-Type -TypeDefinition $code -OutputAssembly $asmFile

## Helper function to execute script
Expand Down
14 changes: 12 additions & 2 deletions test/powershell/Language/Scripting/ScriptHelp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ Describe 'get-help HelpFunc1' -Tags "Feature" {
Describe 'get-help file' -Tags "CI" {
BeforeAll {
try {
$tmpfile = [IO.Path]::ChangeExtension([IO.Path]::GetTempFileName(), "ps1")
if ($IsWindows) {
$tmpfile = [IO.Path]::ChangeExtension([IO.Path]::GetTempFileName(), "ps1")
}
else {
$tmpfile = Join-Path $env:HOME $([IO.Path]::ChangeExtension([IO.Path]::GetRandomFileName(), "ps1"))
}
} catch {
return
}
Expand Down Expand Up @@ -233,7 +238,12 @@ Describe 'get-help file' -Tags "CI" {
Describe 'get-help other tests' -Tags "CI" {
BeforeAll {
try {
$tempFile = [IO.Path]::ChangeExtension([IO.Path]::GetTempFileName(), "ps1")
if ($IsWindows) {
$tempFile = [IO.Path]::ChangeExtension([IO.Path]::GetTempFileName(), "ps1")
}
else {
$tempFile = Join-Path $env:HOME $([IO.Path]::ChangeExtension([IO.Path]::GetRandomFileName(), "ps1"))
}
} catch {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ Describe "Test-Connection" -tags "CI" {
{ Test-Connection "fakeHost" -Count 1 -ErrorAction Stop } |
Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand"
# Error code = 11001 - Host not found.
if ((Get-PlatformInfo).Platform -match "raspbian") {
$platform = Get-PlatformInfo
if ($platform.Platform -match "raspbian" -or ( $platform.Platform -match 'ubuntu' -and $platform.Version -eq '20.04')) {
$code = 11
} elseif (!$IsWindows) {
$code = -131073
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ public class SMAAttributeTest$guid : PSCmdlet

## The assembly files cannot be removed once they are loaded, unless the current PowerShell session exits.
## If we use $TestDrive here, then Pester will try to remove them afterward and result in errors.
$TempPath = [System.IO.Path]::GetTempFileName()
if ($IsWindows) {
$TempPath = [System.IO.Path]::GetTempFileName()
}
else {
$TempPath = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
}

if (Test-Path $TempPath) { Remove-Item -Path $TempPath -Force -Recurse }
New-Item -Path $TempPath -ItemType Directory -Force > $null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,14 @@ set-psbreakpoint -command foo
}

It "Fail to set psbreakpoints when script is a file of wrong type" {
$tempFile = [System.IO.Path]::GetTempFileName()

if ($IsWindows) {
$tempFile = [System.IO.Path]::GetTempFileName()
}
else {
$tempFile = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
}

$ErrorActionPreference = "Stop"
{
Set-PSBreakpoint -Script $tempFile -Line 1
Expand Down
9 changes: 8 additions & 1 deletion test/powershell/engine/Basic/Assembly.LoadFrom.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ Describe "Assembly.LoadFrom Validation Test" -Tags "CI" {

## The assembly files cannot be removed once they are loaded, unless the current PowerShell session exits.
## If we use $TestDrive here, then Pester will try to remove them afterward and result in errors.
$TempPath = [System.IO.Path]::GetTempFileName()

if ($IsWindows) {
$TempPath = [System.IO.Path]::GetTempFileName()
}
else {
$TempPath = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
}

if (Test-Path $TempPath) { Remove-Item -Path $TempPath -Force -Recurse }
New-Item -Path $TempPath -ItemType Directory -Force > $null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ Describe "Can load a native assembly" -Tags "CI" {
BeforeAll {
## The assembly files cannot be removed once they are loaded, unless the current PowerShell session exits.
## If we use $TestDrive here, then Pester will try to remove them afterward and result in errors.
$TempPath = [System.IO.Path]::GetTempFileName()
if ($IsWindows) {
$TempPath = [System.IO.Path]::GetTempFileName()
}
else {
$TempPath = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
}

if (Test-Path $TempPath) { Remove-Item -Path $TempPath -Force -Recurse }
New-Item -Path $TempPath -ItemType Directory -Force > $null

Expand Down
3 changes: 2 additions & 1 deletion test/powershell/engine/Remoting/PSSession.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSS
if (
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8')
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04')
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8"
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Describe "New-PSSession basic test" -Tag @("CI") {
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') -or
($IsMacOS)
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS"
Expand All @@ -33,6 +34,7 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') -or
($IsMacOS)
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS"
Expand All @@ -56,6 +58,7 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') -or
($IsMacOS)
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS"
Expand Down
2 changes: 1 addition & 1 deletion test/tools/Modules/WebListener/WebListener.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function Start-WebListener
[int]$HttpPort = 8083,

[ValidateRange(1,65535)]
[int]$HttpsPort = 8084,
[int]$HttpsPort = 9084,

[ValidateRange(1,65535)]
[int]$Tls11Port = 8085,
Expand Down
10 changes: 5 additions & 5 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1351,21 +1351,21 @@ function New-AfterScripts
Write-Verbose -Message "AfterScript Distribution: $Distribution" -Verbose

if ($Environment.IsRedHatFamily) {
$AfterInstallScript = [io.path]::GetTempFileName()
$AfterRemoveScript = [io.path]::GetTempFileName()
$AfterInstallScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
$AfterRemoveScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
$packagingStrings.RedHatAfterInstallScript -f "$Link", $Destination | Out-File -FilePath $AfterInstallScript -Encoding ascii
$packagingStrings.RedHatAfterRemoveScript -f "$Link", $Destination | Out-File -FilePath $AfterRemoveScript -Encoding ascii
}
elseif ($Environment.IsDebianFamily -or $Environment.IsSUSEFamily) {
$AfterInstallScript = [io.path]::GetTempFileName()
$AfterRemoveScript = [io.path]::GetTempFileName()
$AfterInstallScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
$AfterRemoveScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
$packagingStrings.UbuntuAfterInstallScript -f "$Link", $Destination | Out-File -FilePath $AfterInstallScript -Encoding ascii
$packagingStrings.UbuntuAfterRemoveScript -f "$Link", $Destination | Out-File -FilePath $AfterRemoveScript -Encoding ascii
}
elseif ($Environment.IsMacOS) {
# NOTE: The macos pkgutil doesn't support uninstall actions so we did not implement it.
# Handling uninstall can be done in Homebrew so we'll take advantage of that in the brew formula.
$AfterInstallScript = [io.path]::GetTempFileName()
$AfterInstallScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()))
$packagingStrings.MacOSAfterInstallScript -f "$Link" | Out-File -FilePath $AfterInstallScript -Encoding ascii
}

Expand Down