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
31 changes: 17 additions & 14 deletions PowerShellGitHubDev.psm1
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Use the .NET Core APIs to determine the current platform; if a runtime
# exception is thrown, we are on FullCLR, not .NET Core.
#
# TODO: use PowerShell to check OS when available
# TODO: import Microsoft.PowerShell.Platform instead
try {
$Runtime = [System.Runtime.InteropServices.RuntimeInformation]
$OSPlatform = [System.Runtime.InteropServices.OSPlatform]
$Linux = $Runtime::IsOSPlatform($OSPlatform::Linux)
$OSX = $Runtime::IsOSPlatform($OSPlatform::OSX)
$Windows = $Runtime::IsOSPlatform($OSPlatform::Windows)

$IsCore = $true
$IsLinux = $Runtime::IsOSPlatform($OSPlatform::Linux)
$IsOSX = $Runtime::IsOSPlatform($OSPlatform::OSX)
$IsWindows = $Runtime::IsOSPlatform($OSPlatform::Windows)
} catch [System.Management.Automation.RuntimeException] {
$Linux = $false
$OSX = $false
$Windows = $true
$IsCore = $false
$IsLinux = $false
$IsOSX = $false
$IsWindows = $true
}

function Start-PSBuild
Expand All @@ -32,15 +35,15 @@ function Start-PSBuild
dotnet restore $PSScriptRoot
}

if ($Linux -Or $OSX) {
$InstallCommand = if ($Linux) { "apt-get" } elseif ($OSX) { "brew" }
if ($IsLinux -Or $IsOSX) {
$InstallCommand = if ($IsLinux) { "apt-get" } elseif ($IsOSX) { "brew" }
foreach ($Dependency in "cmake", "g++") {
if (-Not (Get-Command $Dependency -ErrorAction SilentlyContinue)) {
throw "Build dependency '$Dependency' not found in PATH! Run '$InstallCommand install $Dependency'"
}
}

$Ext = if ($Linux) { "so" } elseif ($OSX) { "dylib" }
$Ext = if ($IsLinux) { "so" } elseif ($IsOSX) { "dylib" }
$Native = "$PSScriptRoot/src/libpsl-native"
$Lib = "$Native/src/libpsl-native.$Ext"
Write-Host "Building $Lib"
Expand All @@ -61,8 +64,8 @@ function Start-PSBuild
Write-Host "Building PowerShell"

$Configuration =
if ($Linux -Or $OSX) { "Linux" }
elseif ($Windows) { "Debug" }
if ($IsLinux -Or $IsOSX) { "Linux" }
elseif ($IsWindows) { "Debug" }

dotnet publish -o $Output -c $Configuration -f "netstandardapp1.5" $Top
}
Expand All @@ -77,7 +80,7 @@ function Start-PSPackage
[int]$Iteration = 1
)

if ($Windows) { throw "Building Windows packages is not yet supported!" }
if ($IsWindows) { throw "Building Windows packages is not yet supported!" }

if (-Not (Get-Command "fpm" -ErrorAction SilentlyContinue)) {
throw "Build dependency 'fpm' not found in PATH! See: https://github.com/jordansissel/fpm"
Expand All @@ -91,7 +94,7 @@ function Start-PSPackage
chmod -R go=u "$PSScriptRoot/bin"

# Decide package output type
$Output = if ($Linux) { "deb" } elseif ($OSX) { "osxpkg" }
$Output = if ($IsLinux) { "deb" } elseif ($IsOSX) { "osxpkg" }

# Use Git tag if not given a version
if (-Not($Version)) {
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ test_script:
#
# CoreCLR
$testResultsFile = ".\TestsResults.xml"
.\bin\powershell.exe --noprofile -c "Invoke-Pester test/powershell -OutputFormat NUnitXml -OutputFile $testResultsFile"
.\bin\powershell.exe --noprofile -c "Import-Module .\bin\Modules\Microsoft.PowerShell.Platform; Invoke-Pester test/powershell -OutputFormat NUnitXml -OutputFile $testResultsFile"
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
#
# FullCLR
Import-Module .\PowerShellGitHubDev.psm1
$testResultsFile = ".\TestsResults.FullCLR.xml"
Start-DevPSGitHub -binDir $pwd\binFull -NoNewWindow -ArgumentList '-command', "Import-Module .\bin\Modules\Pester; Invoke-Pester test/fullCLR -OutputFormat NUnitXml -OutputFile $testResultsFile"
Start-DevPSGitHub -binDir $pwd\binFull -NoNewWindow -ArgumentList '-command', "Import-Module .\bin\Modules\Pester; Import-Module .\bin\Modules\Microsoft.PowerShell.Platform; Invoke-Pester test/fullCLR -OutputFormat NUnitXml -OutputFile $testResultsFile"
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
#
# Fail the build, if tests failed
Expand Down
2 changes: 1 addition & 1 deletion pester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

test -x bin/powershell || { echo >&2 "No bin/powershell, please run './build.sh'"; exit 1; }

./bin/powershell --noprofile -c "Invoke-Pester test/powershell/$1 -OutputFile pester-tests.xml -OutputFormat NUnitXml -EnableExit"
./bin/powershell --noprofile -c "Import-Module Microsoft.PowerShell.Platform; Invoke-Pester test/powershell/$1 -OutputFile pester-tests.xml -OutputFormat NUnitXml -EnableExit"
failed_tests=$?

# XML files are not executable
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Use the .NET Core APIs to determine the current platform; if a runtime
# exception is thrown, we are on FullCLR, not .NET Core.
try {
$Runtime = [System.Runtime.InteropServices.RuntimeInformation]
$OSPlatform = [System.Runtime.InteropServices.OSPlatform]

$IsCore = $true
$IsLinux = $Runtime::IsOSPlatform($OSPlatform::Linux)
$IsOSX = $Runtime::IsOSPlatform($OSPlatform::OSX)
$IsWindows = $Runtime::IsOSPlatform($OSPlatform::Windows)
} catch [System.Management.Automation.RuntimeException] {
$IsCore = $false
$IsLinux = $false
$IsOSX = $false
$IsWindows = $true
}

Export-ModuleMember -Variable IsCore, IsLinux, IsOSX, IsWindows
2 changes: 2 additions & 0 deletions src/Microsoft.PowerShell.Linux.Host/PSL_profile.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
function prompt {
"PS " + $(get-location) + "> "
}

Import-Module Microsoft.PowerShell.Platform
18 changes: 9 additions & 9 deletions test/powershell/Add-Member.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Describe "Add-Member" {

It "should be able to see a newly added member of an object" {
$o = New-Object psobject
Add-Member -InputObject $o -MemberType NoteProperty -Name proppy -Value "superVal"
$o = New-Object psobject
Add-Member -InputObject $o -MemberType NoteProperty -Name proppy -Value "superVal"

$o.proppy | Should Not BeNullOrEmpty
$o.proppy | Should Be "superVal"
$o.proppy | Should Not BeNullOrEmpty
$o.proppy | Should Be "superVal"
}

It "Should be able to add a member to an object that already has a member in it" {
$o = New-Object psobject
Add-Member -InputObject $o -MemberType NoteProperty -Name proppy -Value "superVal"
Add-Member -InputObject $o -MemberType NoteProperty -Name AnotherMember -Value "AnotherValue"
$o = New-Object psobject
Add-Member -InputObject $o -MemberType NoteProperty -Name proppy -Value "superVal"
Add-Member -InputObject $o -MemberType NoteProperty -Name AnotherMember -Value "AnotherValue"

$o.AnotherMember | Should Not BeNullOrEmpty
$o.AnotherMember | Should Be "AnotherValue"
$o.AnotherMember | Should Not BeNullOrEmpty
$o.AnotherMember | Should Be "AnotherValue"
}
}
4 changes: 2 additions & 2 deletions test/powershell/Add-Type.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Describe "Add-Type" {
It -Pending "Should not throw given a simple class definition" {
{ Add-Type -TypeDefinition "public static class foo { }" } | Should Not Throw
It "Should not throw given a simple class definition" {
{ Add-Type -TypeDefinition "public static class foo { }" } | Should Not Throw
}
}
Loading