Skip to content

Commit 33c1f2d

Browse files
committed
Fixing execution policy so test automation works
1 parent f8b9b88 commit 33c1f2d

10 files changed

Lines changed: 243 additions & 228 deletions

File tree

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ test_script:
4040
$env:CoreOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Publish))
4141
Write-Host -Foreground Green 'Run CoreCLR tests'
4242
$testResultsFile = "$pwd\TestsResults.xml"
43-
& ("$env:CoreOutput\powershell.exe") -noprofile -noninteractive -c "Invoke-Pester test/powershell -Tag 'CI' -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFile"
43+
& ("$env:CoreOutput\powershell.exe") -noprofile -noninteractive -c "Set-ExecutionPolicy -Scope Process Unrestricted; Invoke-Pester test/powershell -Tag 'CI' -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFile"
4444
4545
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
4646
#
4747
# FullCLR
4848
$env:FullOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -FullCLR))
4949
Write-Host -Foreground Green 'Run FullCLR tests'
5050
$testResultsFileFullCLR = "$pwd\TestsResults.FullCLR.xml"
51-
Start-DevPowerShell -FullCLR -NoNewWindow -ArgumentList '-noprofile', '-noninteractive' -Command "Invoke-Pester test/fullCLR -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFileFullCLR"
51+
Start-DevPowerShell -FullCLR -NoNewWindow -ArgumentList '-noprofile', '-noninteractive' -Command "Set-ExecutionPolicy -Scope Process Unrestricted; Invoke-Pester test/fullCLR -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFileFullCLR"
5252
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFileFullCLR))
5353
#
5454
# Fail the build, if tests failed

build.psm1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function Start-PSBuild {
271271
$nativeResourcesFolder = $_
272272
Get-ChildItem $nativeResourcesFolder -Filter "*.mc" | % {
273273
$command = @"
274-
cmd.exe /C cd /d "(Get-Location)" "&" "$($vcVarsPath)\vcvarsall.bat" "$NativeHostArch" "&" "$mcexe" -o -d -c -U $($_.FullName) -h "$nativeResourcesFolder" -r "$nativeResourcesFolder"
274+
cmd.exe /C cd /d "(Get-Location)" "&" "$($vcVarsPath)\vcvarsall.bat" "$NativeHostArch" "&" mc.exe -o -d -c -U $($_.FullName) -h "$nativeResourcesFolder" -r "$nativeResourcesFolder"
275275
"@
276276
log " Executing mc.exe Command: $command"
277277
Start-NativeExecution { Invoke-Expression -Command:$command }
@@ -526,6 +526,7 @@ function Start-PSPester {
526526
[string[]]$Tag = "CI",
527527
[string]$Path = "$PSScriptRoot/test/powershell"
528528
)
529+
529530
$tagString = "-outputFormat ${OutputFormat} -outputFile ${outputFile} "
530531
if ( ! $DisableExit ) { $tagString += " -EnableExit" }
531532
if ( $ExcludeTag -and ($ExcludeTag -ne "")) { $tagString += " -ExcludeTag @('" + (${ExcludeTag} -join "','") + "')" }
@@ -537,7 +538,7 @@ function Start-PSPester {
537538

538539
Write-Verbose "Import-Module '$moduleDir'; Invoke-Pester $tagString $Path"
539540
$powershellexe = get-psoutput
540-
& $powershell -noprofile -c "Set-ExecutionPolicy Unrestricted; Import-Module '$moduleDir'; Invoke-Pester $tagString $Path"
541+
& $powershell -noprofile -c "Set-ExecutionPolicy -Scope Process Unrestricted; Import-Module '$moduleDir'; Invoke-Pester $tagString $Path"
541542
if ($LASTEXITCODE -ne 0) {
542543
throw "$LASTEXITCODE Pester tests failed"
543544
}

src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceSecurity.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ private IntPtr GetMainWindowHandle()
170170
// APIs
171171
private bool PromptUsingConsole()
172172
{
173-
#if CORECLR // on Nano there is no other way to prompt except by using console
173+
#if CORECLR
174+
// on Nano there is no other way to prompt except by using console
174175
return true;
175176
#else
176-
PropertyAccessor propertyAccessor = PropertyAccessorFactory.GetPropertyAccessor();
177177
Exception exception = null;
178-
bool promptUsingConsole = propertyAccessor.GetConsolePrompting(ref exception);
178+
bool promptUsingConsole = ConfigPropertyAccessor.Instance.GetConsolePrompting(ref exception);
179179
if (null != exception)
180180
{
181181
s_tracer.TraceError("Could not read CredUI registry key: " + exception.Message);

0 commit comments

Comments
 (0)