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
17 changes: 17 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,20 @@ Why did `dotnet restore` say `error: Failed to retrieve information from remote
Your `src/windows-build` submodule is probably empty. See "Why is my submodule
empty?" above. This submodule contains a local NuGet feed with packages
necessary for the build. The quick fix is `git submodule update --init`.

Why did my Travis CI build fail with `GITHUB_TOKEN variable is undefined, please provide token`?
================================================================================================

Travis CI uses an encrypted environment variable to authorize with GitHub and
download PowerShell (which it then uses to build and test through the
`build.psm1` module). However, the following caveat applies:

> Encrypted variables are not added to untrusted builds such as pull requests
> coming from another repository.

Thus a pull request made from a fork of the PowerShell repository will not pass
the Travis CI as it will be unable to build. Please instead push your branch to
the upstream PowerShell repository on GitHub (that is,
https://github.com/PowerShell/PowerShell), and issue a new Pull Request. If you
cannot do this, please get in contact with us to obtain the necessary
permissions.
82 changes: 49 additions & 33 deletions test/powershell/Remove-TypeData.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
Describe "Remove-TypeData DRT Unit Tests" -Tags DRT{
It "Remove With Pipe line Input Pass Type Shortcut String" {
{ Update-TypeData -MemberType NoteProperty -MemberName TestNote -Value TestNote -TypeName int } | Should Not Throw
$a = Get-TypeData System.Int32
$a.TypeName | Should Be System.Int32

{ 'int' | Remove-TypeData } | Should Not Throw
}

It "Remove Type File In Initial Session State" {
Describe "Remove-TypeData DRT Unit Tests" -Tags DRT {
BeforeAll {
$XMLFile1 = Join-Path $TestDrive -ChildPath "testFile1.ps1xml"
$XMLFile2 = Join-Path $TestDrive -ChildPath "testFile2.ps1xml"
$content1 = @"
Expand All @@ -23,7 +15,6 @@
</Type>
</Types>
"@

$content2 = @"
<Types>
<Type>
Expand All @@ -37,31 +28,56 @@
</Type>
</Types>
"@

$content1 > $XMLFile1
$content2 > $XMLFile2
Update-TypeData -AppendPath $XMLFile1
Update-TypeData -AppendPath $XMLFile2
$a = 1..3
$a.Yada | Should be 3
$a.Yoda | Should Be 3
Remove-TypeData -Path $XMLFile1
$a.Yada | Should BeNullOrEmpty
$a.Yoda | Should Be 3

#clean up
Remove-TypeData -Path $XMLFile2
}

BeforeEach {
$ps = [powershell]::Create()
$iss = [system.management.automation.runspaces.initialsessionstate]::CreateDefault2()
$rs = [system.management.automation.runspaces.runspacefactory]::CreateRunspace($iss)
$rs.Open()
$ps.Runspace = $rs
}

AfterEach {
$rs.Close()
$ps.Dispose()
}

It "Remove With Pipe line Input Pass Type Shortcut String" {
$null = $ps.AddScript("Update-TypeData -MemberType NoteProperty -MemberName TestNote -Value TestNote -TypeName int").Invoke()
$ps.Commands.Clear()
$null = $ps.AddScript("(Get-TypeData System.Int32).TypeName").Invoke() | Should Be System.Int32
$ps.Commands.Clear()
$null = $ps.AddScript("'int' | Remove-TypeData").Invoke()
$ps.HadErrors | Should be $false
}

It "Remove Type File In Initial Session State" {
# setup
$null = $ps.AddScript("Update-TypeData -AppendPath $XMLFile1").Invoke()
$ps.Commands.Clear()
$null = $ps.AddScript("Update-TypeData -AppendPath $XMLFile2").Invoke()
$ps.Commands.Clear()
$null = $ps.AddScript('$a = 1..3').Invoke()
$ps.Commands.Clear()
# test
$ps.AddScript('$a.Yada').Invoke() | Should be 3
$ps.Commands.Clear()
$ps.AddScript('$a.Yoda').Invoke() | Should Be 3
$ps.Commands.Clear()
$null = $ps.AddScript("Remove-TypeData -Path $XMLFile1").Invoke()
$ps.Commands.Clear()
$ps.AddScript('$a.Yada').Invoke() | Should BeNullOrEmpty
$ps.Commands.Clear()
$ps.AddScript('$a.Yoda').Invoke() | Should Be 3
$ps.Commands.Clear()
}

It "Remove Type File In Initial Session State File Not In Cache" {
try
{
Remove-TypeData -Path "fakefile" -ErrorAction Stop
Throw "OK"
}
catch
{
$_.FullyQualifiedErrorId | Should Be "TypePathException,Microsoft.PowerShell.Commands.RemoveTypeDataCommand"
}
$null = $ps.AddScript("Remove-TypeData -Path fakefile").Invoke()
$ps.HadErrors | Should be $true
$ps.Streams.Error[0].FullyQualifiedErrorID | Should Be "TypePathException,Microsoft.PowerShell.Commands.RemoveTypeDataCommand"
}
}
}
10 changes: 4 additions & 6 deletions test/powershell/Update-TypeData.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Describe "Update-TypeData basic functionality" -Tags DRT{
$testfile = Join-Path -Path $TestDrive -ChildPath $testfilename
$invalidFileExtensionFile = Join-Path -Path $TestDrive -ChildPath "notmshxml"

$xmlContent=@"
$xmlContent=@"
<Types>
<Type>
<Name>AnyName</Name>
Expand All @@ -39,7 +39,7 @@ Describe "Update-TypeData basic functionality" -Tags DRT{
</Type>
</Types>
"@
$xmlContent>$testfile
$xmlContent>$testfile
}

BeforeEach {
Expand All @@ -49,15 +49,13 @@ Describe "Update-TypeData basic functionality" -Tags DRT{
$rs.Open()
$ps.Runspace = $rs
}

AfterEach {
$rs.Close()
$ps.Dispose()
}

#Pester bug:https://github.com/PowerShell/psl-pester/issues/6
It "Update-TypeData with Invalid TypesXml should throw Exception" {

It "Update-TypeData with Invalid TypesXml should throw Exception" {
$null = $ps.AddScript("Update-TypeData -PrependPath $testfile")
$ps.Invoke()
$ps.HadErrors | Should be $true
Expand Down