tests now run clean on Windows and Linux

This commit is contained in:
James Truher committed 2016-07-20 12:10:12 -07:00
1 parent 2674564542
commit b680b48160
4 files changed
+29 -22

No files matched your search

@@ -673,7 +673,7 @@ Describe 'Type building' -Tags "DRT" {
Describe 'RuntimeType created for TypeDefinitionAst' {
It 'can make cast to the right RuntimeType in two different contexts' {
It 'can make cast to the right RuntimeType in two different contexts' -pending {
$ssfe = [System.Management.Automation.Runspaces.SessionStateFunctionEntry]::new("foo", @'
class Base
@@ -689,7 +689,7 @@ class Derived : Base
[Derived]::new().foo()
'@)
$iss = [System.Management.Automation.Runspaces.initialsessionstate]::CreateDefault()
$iss = [System.Management.Automation.Runspaces.initialsessionstate]::CreateDefault2()
$iss.Commands.Add($ssfe)
$ps = [powershell]::Create($iss)
@@ -745,7 +745,7 @@ namespace Foo
}
'@
It 'doesn''t allow protected methods access outside of inheritance chain' {
It 'doesn''t allow protected methods access outside of inheritance chain' -pending {
$a = [scriptblock]::Create(@'
class A
{
@@ -1,4 +1,6 @@
Describe 'using module' -Tags "DRT" {
Describe 'using module' -Tags "CI" {
BeforeAll {
$originalPSMODULEPATH = $env:PSMODULEPATH
Import-Module $PSScriptRoot\..\LanguageTestSupport.psm1
@@ -26,15 +28,17 @@ Describe 'using module' -Tags "DRT" {
}
}
$originalPSMODULEPATH = $env:PSMODULEPATH
}
try {
AfterAll {
$env:PSMODULEPATH = $originalPSMODULEPATH
}
It 'Import-Module has ImplementedAssembly, when classes are present in the module' {
# Create modules in TestDrive:\
New-TestModule -Name Foo -Content 'class Foo { [string] GetModuleName() { return "Foo" } }'
New-TestModule -Manifest -Name FooWithManifest -Content 'class Foo { [string] GetModuleName() { return "FooWithManifest" } }'
It 'Import-Module has ImplementedAssembly, when classes are present in the module' {
$module = Import-Module Foo -PassThru
try {
$module.ImplementingAssembly | Should Not Be $null
@@ -206,7 +210,6 @@ New-Object Foo
$err[0].ErrorId | Should Be 'ModuleNotFoundDuringParse'
}
It "report an error about misformatted module specification" {
$err = Get-ParseResults "using module @{ Foo = 'Foo' }"
$err.Count | Should Be 1
@@ -299,8 +302,10 @@ using module FooWithManifest
}
Context 'using use the latest version of module after Import-Module -Force' {
BeforeAll {
New-TestModule -Name Foo -Content 'class Foo { [string] GetModuleName() { return "Foo2" } }'
Import-Module Foo -Force
}
It "can use class from another module as a base class with using module" {
$moduleName = [scriptblock]::Create(@"
using module Foo
@@ -312,10 +317,12 @@ using module Foo
}
Context 'Side by side' {
BeforeAll {
# Add side-by-side module
$newVersion = '3.4.5'
New-TestModule -Manifest -Name FooWithManifest -Content 'class Foo { [string] GetModuleName() { return "Foo230" } }' -Version '2.3.0'
New-TestModule -Manifest -Name FooWithManifest -Content 'class Foo { [string] GetModuleName() { return "Foo345" } }' -Version '3.4.5' -ModulePathPrefix 'Modules2'
}
# 'using module' behavior must be alligned with Import-Module.
# Import-Module does the following:
@@ -356,11 +363,12 @@ using module @{ModuleName = 'FooWithManifest'; RequiredVersion = '3.4.5'}
}
Context 'Use module with runtime error' {
BeforeAll {
New-TestModule -Name ModuleWithRuntimeError -Content @'
class Foo { [string] GetModuleName() { return "ModuleWithRuntimeError" } }
throw 'error'
'@
}
It "handles runtime errors in imported module" {
$err = Get-RuntimeError @"
@@ -404,20 +412,13 @@ function foo()
}
}
# this is a setup for Context "Module by path"
New-TestModule -Name FooForPaths -Content 'class Foo { [string] GetModuleName() { return "FooForPaths" } }'
} finally {
$env:PSMODULEPATH = $originalPSMODULEPATH
}
# here we are back to normal $env:PSMODULEPATH, but all modules are there
Context "Module by path" {
It 'use non-modified PSMODULEPATH' {
$env:PSMODULEPATH | Should Be $originalPSMODULEPATH
}
BeforeAll {
# this is a setup for Context "Module by path"
New-TestModule -Name FooForPaths -Content 'class Foo { [string] GetModuleName() { return "FooForPaths" } }'
$env:PSMODULEPATH = $originalPSMODULEPATH
new-item -type directory -Force TestDrive:\FooRelativeConsumer
Set-Content -Path "${TestDrive}\FooRelativeConsumer\FooRelativeConsumer.ps1" -Value @'
@@ -431,6 +432,11 @@ using module FooForPaths
class Bar : Foo {}
[Bar]::new()
'@
}
It 'use non-modified PSMODULEPATH' {
$env:PSMODULEPATH | Should Be $originalPSMODULEPATH
}
It "can be accessed by relative path" {
$barObject = & TestDrive:\FooRelativeConsumer\FooRelativeConsumer.ps1
@@ -1,3 +1,4 @@
$powershellexe = (get-process -id $PID).mainmodule.filename
Describe "Clone array" -Tags "CI" {
It "Cast in target expr" {
@@ -38,7 +39,7 @@ Describe "MSFT:3309783" -Tags "CI" {
It "Run in another process" {
# For a reliable test, we must run this in a new process because an earlier binding in this process
# could mask the bug/fix.
powershell -noprofile -command "[psobject] | % FullName" | Should Be System.Management.Automation.PSObject
& $powershellexe -noprofile -command "[psobject] | % FullName" | Should Be System.Management.Automation.PSObject
}
It "Run in current process" {
@@ -101,7 +102,7 @@ Describe "Hashtable key property syntax" -Tags "CI" {
It "In different process" {
# So also run in a fresh process
$bytes = [System.Text.Encoding]::Unicode.GetBytes($script)
powershell -noprofile -encodedCommand ([Convert]::ToBase64String($bytes)) | Should Be Hello
& $powershellexe -noprofile -encodedCommand ([Convert]::ToBase64String($bytes)) | Should Be Hello
}
}