:white-check-mark: update tests for most of the k renames
This commit is contained in:
Родитель
e58c4dada8
Коммит
e760ecb53a
|
@ -18,7 +18,7 @@ namespace HelloK {
|
|||
"\x1b[33m/_/ |_/___/_/ \x1b[37m(_)\x1b[34m_/|_/___/ /_/ \x1b[39m";
|
||||
|
||||
AnsiConsole.Output.WriteLine(art);
|
||||
AnsiConsole.Output.WriteLine("K is sane!");
|
||||
AnsiConsole.Output.WriteLine("Runtime is sane!");
|
||||
AnsiConsole.Output.WriteLine("\x1b[30mRuntime Framework: \x1b[39m " + _env.RuntimeFramework.ToString());
|
||||
#if ASPNETCORE50
|
||||
AnsiConsole.Output.WriteLine("\x1b[30mRuntime: \x1b[39m Microsoft CoreCLR");
|
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.22410.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "HelloK", "HelloK.kproj", "{0EF87869-3442-40AA-A0E6-089CD385F7D0}"
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestApp", "TestApp.kproj", "{0EF87869-3442-40AA-A0E6-089CD385F7D0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version": "0.0.1-*",
|
||||
"description": "Quick app to exercise a few K things",
|
||||
"description": "Quick app to exercise a few .NET things",
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" },
|
||||
"Microsoft.Framework.CommandLineUtils": { "version": "1.0.0-*", "type": "build" }
|
|
@ -1,7 +1,7 @@
|
|||
#Requires -Version 3
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Runs the tests for kvm
|
||||
Runs the tests for dotnetsdk
|
||||
|
||||
.PARAMETER PesterPath
|
||||
The path to the root of the Pester (https://github.com/pester/Pester) module (optional)
|
||||
|
@ -15,8 +15,8 @@
|
|||
.PARAMETER TestsPath
|
||||
The path to the folder containing Tests to run (optional)
|
||||
|
||||
.PARAMETER KvmPath
|
||||
The path to the kvm.ps1 script to test (optional)
|
||||
.PARAMETER DotNetSdkPath
|
||||
The path to the dotnetsdk.ps1 script to test (optional)
|
||||
|
||||
.PARAMETER TestName
|
||||
The name of a specific test to run (optional)
|
||||
|
@ -44,7 +44,7 @@ param(
|
|||
[string]$PesterRef = "master",
|
||||
[string]$PesterRepo = "https://github.com/pester/Pester",
|
||||
[string]$TestsPath = $null,
|
||||
[string]$KvmPath = $null,
|
||||
[string]$DotNetSdkPath = $null,
|
||||
[string]$TestName = $null,
|
||||
[string]$TestWorkingDir = $null,
|
||||
[string]$TestAppsDir = $null,
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# "Constants"
|
||||
$packageManagerName = "kpm"
|
||||
|
||||
function Write-Banner {
|
||||
param($Message)
|
||||
|
||||
|
@ -18,39 +21,39 @@ function Remove-EnvVar($var) {
|
|||
}
|
||||
}
|
||||
|
||||
function GetKresOnPath {
|
||||
param($kreHome)
|
||||
if(!$kreHome) {
|
||||
$kreHome = $env:USER_KRE_PATH
|
||||
function GetRuntimesOnPath {
|
||||
param($dotnetHome)
|
||||
if(!$dotnetHome) {
|
||||
$dotnetHome = $env:USER_DOTNET_PATH
|
||||
}
|
||||
|
||||
if($env:PATH) {
|
||||
$paths = $env:PATH.Split(";")
|
||||
if($paths) {
|
||||
@($paths | Where { $_.StartsWith("$kreHome\packages") })
|
||||
@($paths | Where { $_.StartsWith("$dotnetHome\packages") })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GetActiveKrePath {
|
||||
param($kreHome)
|
||||
GetKresOnPath $kreHome | Select -First 1
|
||||
function GetActiveRuntimePath {
|
||||
param($dotnetHome)
|
||||
GetRuntimesOnPath $dotnetHome | Select -First 1
|
||||
}
|
||||
|
||||
function GetActiveKreName {
|
||||
param($kreHome)
|
||||
if(!$kreHome) {
|
||||
$kreHome = $env:USER_KRE_PATH
|
||||
function GetActiveRuntimeName {
|
||||
param($dotnetHome)
|
||||
if(!$dotnetHome) {
|
||||
$dotnetHome = $env:USER_DOTNET_PATH
|
||||
}
|
||||
$activeKre = GetActiveKrePath $kreHome
|
||||
$activeKre = GetActiveRuntimePath $dotnetHome
|
||||
if($activeKre) {
|
||||
$activeKre.Replace("$kreHome\packages\", "").Replace("\bin", "")
|
||||
$activeKre.Replace("$dotnetHome\packages\", "").Replace("\bin", "")
|
||||
}
|
||||
}
|
||||
|
||||
function GetKreName {
|
||||
param($clr, $arch, $ver = $TestKreVersion)
|
||||
"KRE-$clr-$arch.$ver"
|
||||
"DotNet-$clr-$arch.$ver"
|
||||
}
|
||||
|
||||
# Borrowed from kvm itself, but we can't really use that one so unfortunately we have to use copy-pasta :)
|
||||
|
|
|
@ -4,7 +4,7 @@ param(
|
|||
[string]$PesterRef = "anurse/teamcity",
|
||||
[string]$PesterRepo = "https://github.com/anurse/Pester",
|
||||
[string]$TestsPath = $null,
|
||||
[string]$KvmPath = $null,
|
||||
[string]$DotNetSdkPath = $null,
|
||||
[string]$TestName = $null,
|
||||
[string]$TestWorkingDir = $null,
|
||||
[string]$TestAppsDir = $null,
|
||||
|
@ -29,27 +29,29 @@ if(!$RunningInNewPowershell) {
|
|||
# Set defaults
|
||||
if(!$PesterPath) { $PesterPath = Join-Path $PSScriptRoot ".pester" }
|
||||
if(!$TestsPath) { $TestsPath = Join-Path $PSScriptRoot "tests" }
|
||||
if(!$KvmPath) { $KvmPath = Convert-Path (Join-Path $PSScriptRoot "../../src/kvm.ps1") }
|
||||
if(!$DotNetSdkPath) { $DotNetSdkPath = Convert-Path (Join-Path $PSScriptRoot "../../src/dotnetsdk.ps1") }
|
||||
if(!$TestWorkingDir) { $TestWorkingDir = Join-Path $PSScriptRoot "testwork" }
|
||||
if(!$TestAppsDir) { $TestAppsDir = Convert-Path (Join-Path $PSScriptRoot "../apps") }
|
||||
|
||||
# Configure the KREs we're going to use in testing. The actual KRE doesn't matter since we're only testing
|
||||
# that KVM can find it, download it and unpack it successfully. We do run an app in the KRE to do that sanity
|
||||
# Configure the Runtimes we're going to use in testing. The actual runtime doesn't matter since we're only testing
|
||||
# that dotnetsdk can find it, download it and unpack it successfully. We do run an app in the runtime to do that sanity
|
||||
# test, but all we care about in these tests is that the app executes.
|
||||
$env:KRE_FEED = "https://www.myget.org/F/aspnetmaster/api/v2"
|
||||
$TestKreVersion = "1.0.0-beta1"
|
||||
#
|
||||
# Yes, some of these still refer to "KRE" packages. That is by design for now.
|
||||
$env:DOTNET_FEED = "https://www.myget.org/F/aspnetmaster/api/v2"
|
||||
$TestDotNetVersion = "1.0.0-beta1"
|
||||
$specificNupkgUrl = "https://www.myget.org/F/aspnetmaster/api/v2/package/KRE-CLR-x86/1.0.0-alpha4"
|
||||
$specificNupkgHash = "B84347C335A5AFD24B2A08F031BF7CBEC58581D407C82D4C208AA2FD633B066C"
|
||||
$specificNupkgName = "KRE-CLR-x86.1.0.0-alpha4.nupkg"
|
||||
$specificNuPkgFxName = "Asp.Net,Version=v5.0"
|
||||
|
||||
# Set up context
|
||||
$kvm = $KvmPath
|
||||
$dotnetsdk = $DotNetSdkPath
|
||||
|
||||
# Create test working directory
|
||||
if(Test-Path "$TestWorkingDir\kre") {
|
||||
if(Test-Path "$TestWorkingDir\.dotnet") {
|
||||
Write-Banner "Wiping old test working area"
|
||||
del -rec -for "$TestWorkingDir\kre"
|
||||
del -rec -for "$TestWorkingDir\.dotnet"
|
||||
}
|
||||
|
||||
if(!(Test-Path $TestWorkingDir)) {
|
||||
|
@ -65,42 +67,42 @@ if($Debug) {
|
|||
$DebugPreference = "Continue"
|
||||
}
|
||||
|
||||
# Unset KRE_HOME for the test
|
||||
$oldKreHome = $env:KRE_HOME
|
||||
Remove-EnvVar KRE_HOME
|
||||
# Unset DOTNET_HOME for the test
|
||||
$oldKreHome = $env:DOTNET_HOME
|
||||
Remove-EnvVar DOTNET_HOME
|
||||
|
||||
# Unset KRE_TRACE for the test
|
||||
Remove-EnvVar KRE_TRACE
|
||||
# Unset DOTNET_TRACE for the test
|
||||
Remove-EnvVar DOTNET_TRACE
|
||||
|
||||
# Unset PATH for the test
|
||||
Remove-EnvVar PATH
|
||||
|
||||
# Set up the user/global install directories to be inside the test work area
|
||||
$env:USER_KRE_PATH = "$TestWorkingDir\kre\user"
|
||||
mkdir $env:USER_KRE_PATH | Out-Null
|
||||
$env:USER_DOTNET_PATH = "$TestWorkingDir\.dotnet\user"
|
||||
mkdir $env:USER_DOTNET_PATH | Out-Null
|
||||
|
||||
$env:GLOBAL_KRE_PATH = "$TestWorkingDir\kre\global"
|
||||
mkdir $env:GLOBAL_KRE_PATH | Out-Null
|
||||
$env:GLOBAL_DOTNET_PATH = "$TestWorkingDir\.dotnet\global"
|
||||
mkdir $env:GLOBAL_DOTNET_PATH | Out-Null
|
||||
|
||||
# Helper function to run kvm and capture stuff.
|
||||
$kvmout = $null
|
||||
$kvmexit = $null
|
||||
function runkvm {
|
||||
$kvmout = $null
|
||||
& $kvm -Proxy:$Proxy -AssumeElevated -OutputVariable kvmout -Quiet @args -ErrorVariable kvmerr -ErrorAction SilentlyContinue
|
||||
$kvmexit = $LASTEXITCODE
|
||||
# Helper function to run dotnetsdk and capture stuff.
|
||||
$dotnetsdkout = $null
|
||||
$dotnetsdkexit = $null
|
||||
function rundotnetsdk {
|
||||
$dotnetsdkout = $null
|
||||
& $dotnetsdk -Proxy:$Proxy -AssumeElevated -OutputVariable dotnetsdkout -Quiet @args -ErrorVariable dotnetsdkerr -ErrorAction SilentlyContinue
|
||||
$dotnetsdkexit = $LASTEXITCODE
|
||||
|
||||
if($Debug) {
|
||||
$kvmout | Write-CommandOutput kvm
|
||||
$dotnetsdkout | Write-CommandOutput dotnetsdk
|
||||
}
|
||||
|
||||
# Push the values up a scope
|
||||
Set-Variable kvmout $kvmout -Scope 1
|
||||
Set-Variable kvmexit $kvmexit -Scope 1
|
||||
Set-Variable kvmerr $kvmerr -Scope 1
|
||||
Set-Variable dotnetsdkout $dotnetsdkout -Scope 1
|
||||
Set-Variable dotnetsdkexit $dotnetsdkexit -Scope 1
|
||||
Set-Variable dotnetsdkerr $dotnetsdkerr -Scope 1
|
||||
}
|
||||
|
||||
# Fetch a nupkg to use for the 'kvm install <path to nupkg>' scenario
|
||||
# Fetch a nupkg to use for the 'dotnetsdk install <path to nupkg>' scenario
|
||||
Write-Banner "Fetching test prerequisites"
|
||||
|
||||
$downloadDir = Join-Path $TestWorkingDir "downloads"
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
# Ensure a Runtime has been installed (if the other tests ran first, we're good)
|
||||
rundotnetsdk install $TestKreVersion -arch "x86" -r "CLR"
|
||||
|
||||
$notRealRuntimeVersion = "0.0.1-notarealruntime"
|
||||
|
||||
$kreName = GetRuntimeName "CLR" "x86"
|
||||
$notRealKreName = GetRuntimeName "CLR" "x86" $notRealRuntimeVersion
|
||||
|
||||
$testAlias = "alias_test_" + [Guid]::NewGuid().ToString("N")
|
||||
$testDefaultAlias = "alias_testDefault_" + [Guid]::NewGuid().ToString("N")
|
||||
$notRealAlias = "alias_notReal_" + [Guid]::NewGuid().ToString("N")
|
||||
$bogusAlias = "alias_bogus_" + [Guid]::NewGuid().ToString("N")
|
||||
|
||||
Describe "dotnetsdk-ps1 alias" -Tag "dotnetsdk-alias" {
|
||||
Context "When defining an alias for a Runtime that exists" {
|
||||
rundotnetsdk alias $testAlias $TestKreVersion -x86 -r CLR
|
||||
|
||||
It "writes the alias file" {
|
||||
"$env:USER_DOTNET_PATH\alias\$testAlias.txt" | Should Exist
|
||||
"$env:USER_DOTNET_PATH\alias\$testAlias.txt" | Should ContainExactly $kreName
|
||||
}
|
||||
}
|
||||
|
||||
Context "When defining an alias for a Runtime with no arch or clr parameters" {
|
||||
rundotnetsdk alias $testDefaultAlias $TestKreVersion
|
||||
|
||||
It "writes the x86/CLR variant to the alias file" {
|
||||
"$env:USER_DOTNET_PATH\alias\$testDefaultAlias.txt" | Should Exist
|
||||
"$env:USER_DOTNET_PATH\alias\$testDefaultAlias.txt" | Should ContainExactly $kreName
|
||||
}
|
||||
}
|
||||
|
||||
Context "When defining an alias for a Runtime that does not exist" {
|
||||
rundotnetsdk alias $notRealAlias $notRealRuntimeVersion -x86 -r CLR
|
||||
|
||||
It "writes the alias file" {
|
||||
"$env:USER_DOTNET_PATH\alias\$notRealAlias.txt" | Should Exist
|
||||
"$env:USER_DOTNET_PATH\alias\$notRealAlias.txt" | Should ContainExactly $notRealKreName
|
||||
}
|
||||
}
|
||||
|
||||
Context "When displaying an alias" {
|
||||
rundotnetsdk alias $testAlias
|
||||
It "outputs the value of the alias" {
|
||||
$dotnetsdkout[0] | Should Be "Alias '$testAlias' is set to $kreName"
|
||||
}
|
||||
}
|
||||
|
||||
Context "When given an non-existant alias" {
|
||||
rundotnetsdk alias $bogusAlias
|
||||
|
||||
It "outputs an error" {
|
||||
$dotnetsdkout[0] | Should Be "Alias '$bogusAlias' does not exist"
|
||||
}
|
||||
|
||||
It "returns a non-zero exit code" {
|
||||
$dotnetsdkexit | Should Not Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context "When displaying all aliases" {
|
||||
$allAliases = rundotnetsdk alias | Out-String
|
||||
|
||||
It "lists all aliases in the alias files" {
|
||||
dir "$env:USER_DOTNET_PATH\alias\*.txt" | ForEach-Object {
|
||||
$alias = [Regex]::Escape([IO.Path]::GetFileNameWithoutExtension($_.Name))
|
||||
$val = [Regex]::Escape((Get-Content $_))
|
||||
|
||||
# On some consoles, the value of the alias gets cut off, so don't require it in the assertion.
|
||||
$allAliases | Should Match ".*$alias.*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "dotnetsdk-ps1 unalias" -Tag "dotnetsdk-alias" {
|
||||
Context "When removing an alias that does not exist" {
|
||||
rundotnetsdk unalias $bogusAlias
|
||||
|
||||
It "outputs an error" {
|
||||
$dotnetsdkout[0] | Should Be "Cannot remove alias, '$bogusAlias' is not a valid alias name"
|
||||
}
|
||||
|
||||
It "returns a non-zero exit code" {
|
||||
$dotnetsdkexit | Should Not Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context "When removing an alias that does exist" {
|
||||
rundotnetsdk unalias $testAlias
|
||||
|
||||
It "removes the alias file" {
|
||||
"$env:USER_DOTNET_PATH\alias\$testAlias.txt" | Should Not Exist
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
$crossgenned=@("mscorlib") # List of assemblies to check native images for on CoreCLR
|
||||
|
||||
function DefineInstallTests($clr, $arch, [switch]$global, [switch]$noNative) {
|
||||
$runtimeHome = $env:USER_DOTNET_PATH
|
||||
$contextName = "for user"
|
||||
$alias = "install_test_$arch_$clr"
|
||||
|
||||
if($global) {
|
||||
$contextName = "globally"
|
||||
$alias = "global_$alias"
|
||||
$runtimeHome = $env:GLOBAL_DOTNET_PATH
|
||||
}
|
||||
|
||||
if($clr -eq "CoreCLR") {
|
||||
$fxName = "Asp.NetCore,Version=v5.0"
|
||||
} else {
|
||||
$fxName = "Asp.Net,Version=v5.0"
|
||||
}
|
||||
|
||||
$runtimeName = GetRuntimeName $clr $arch
|
||||
$runtimeRoot = "$runtimeHome\runtimes\$runtimeName"
|
||||
|
||||
$nativeText = ""
|
||||
if($noNative) {
|
||||
$nativeText = " (without building native images)"
|
||||
}
|
||||
|
||||
Context "When installing $clr on $arch $contextName$nativeText" {
|
||||
It "downloads and unpacks a KRE" {
|
||||
if($global) {
|
||||
rundotnetsdk install $TestDotNetVersion -arch $arch -r $clr -a $alias -global
|
||||
} elseif($noNative) {
|
||||
rundotnetsdk install $TestDotNetVersion -arch $arch -r $clr -a $alias -nonative
|
||||
} else {
|
||||
rundotnetsdk install $TestDotNetVersion -arch $arch -r $clr -a $alias
|
||||
}
|
||||
}
|
||||
|
||||
It "installs the KRE into the user directory" {
|
||||
$runtimeRoot | Should Exist
|
||||
}
|
||||
|
||||
if($clr -eq "CoreCLR") {
|
||||
if($noNative) {
|
||||
It "did not crossgen native assemblies" {
|
||||
$crossgenned | ForEach-Object { "$runtimeRoot\bin\$_.ni.dll" } | Should Not Exist
|
||||
}
|
||||
} else {
|
||||
It "crossgenned native assemblies" {
|
||||
$crossgenned | ForEach-Object { "$runtimeRoot\bin\$_.ni.dll" } | Should Exist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "can restore packages for the HelloK sample" {
|
||||
pushd "$TestAppsDir\TestApp"
|
||||
try {
|
||||
& "$runtimeRoot\bin\$PackageManagerName" restore
|
||||
} finally {
|
||||
popd
|
||||
}
|
||||
}
|
||||
|
||||
It "can run the HelloK sample" {
|
||||
pushd "$TestAppsDir\TestApp"
|
||||
try {
|
||||
$output = & "$runtimeRoot\bin\$RuntimeExecutableName" run
|
||||
$LASTEXITCODE | Should Be 0
|
||||
$fullOutput = [String]::Join("`r`n", $output)
|
||||
|
||||
$fullOutput | Should Match "Runtime is sane!"
|
||||
$fullOutput | Should Match "Runtime Framework:\s+$fxName"
|
||||
} finally {
|
||||
popd
|
||||
}
|
||||
}
|
||||
|
||||
It "assigned the requested alias" {
|
||||
"$env:USER_DOTNET_PATH\alias\$alias.txt" | Should Exist
|
||||
"$env:USER_DOTNET_PATH\alias\$alias.txt" | Should ContainExactly $runtimeName
|
||||
}
|
||||
|
||||
It "uses the new Runtime" {
|
||||
GetActiveRuntimeName $runtimeHome | Should Be "$runtimeName"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "dotnetsdk-ps1 install" -Tag "dotnetsdk-install" {
|
||||
try {
|
||||
DefineInstallTests "CLR" "x86"
|
||||
DefineInstallTests "CLR" "amd64"
|
||||
DefineInstallTests "CoreCLR" "x86" -noNative
|
||||
DefineInstallTests "CoreCLR" "amd64"
|
||||
DefineInstallTests "CLR" "x86" -global
|
||||
|
||||
Context "When installing a non-existant Runtime version" {
|
||||
rundotnetsdk install "0.0.1-thisisnotarealruntime"
|
||||
|
||||
It "returns a non-zero exit code" {
|
||||
$dotnetsdkexit | Should Not Be 0
|
||||
}
|
||||
|
||||
It "throws a 404 error" {
|
||||
$dotnetsdkerr[0].Exception.Message | Should Be 'Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found."'
|
||||
}
|
||||
}
|
||||
|
||||
Context "When no architecture is specified" {
|
||||
rundotnetsdk install $TestDotNetVersion -r CLR
|
||||
$runtimeName = GetRuntimeName -clr CLR -arch x86
|
||||
|
||||
It "uses x86" {
|
||||
$dotnetsdkout[0] | Should Be "$runtimeName already installed."
|
||||
}
|
||||
}
|
||||
|
||||
Context "When no clr is specified" {
|
||||
rundotnetsdk install $TestDotNetVersion -arch x86
|
||||
$runtimeName = GetRuntimeName -clr CLR -arch x86
|
||||
|
||||
It "uses Desktop CLR" {
|
||||
$dotnetsdkout[0] | Should Be "$runtimeName already installed."
|
||||
}
|
||||
}
|
||||
|
||||
Context "When neither architecture nor clr is specified" {
|
||||
rundotnetsdk install $TestDotNetVersion
|
||||
$runtimeName = GetRuntimeName -clr CLR -arch x86
|
||||
|
||||
It "uses x86/Desktop" {
|
||||
$dotnetsdkout[0] | Should Be "$runtimeName already installed."
|
||||
}
|
||||
}
|
||||
|
||||
Context "When installing latest" {
|
||||
$previous = @(dir "$env:USER_DOTNET_PATH\packages" | select -ExpandProperty Name)
|
||||
It "downloads a runtime" {
|
||||
rundotnetsdk install latest -arch x86 -r CLR
|
||||
}
|
||||
# TODO: Check that it actually installed the latest?
|
||||
}
|
||||
|
||||
Context "When installing an already-installed runtime" {
|
||||
# Clear active KRE
|
||||
rundotnetsdk use none
|
||||
|
||||
$runtimeName = GetRuntimeName "CLR" "x86"
|
||||
$runtimePath = "$env:USER_DOTNET_PATH\packages\$runtimeName"
|
||||
It "ensures the runtime is installed" {
|
||||
rundotnetsdk install $TestDotNetVersion -x86 -r "CLR"
|
||||
$dotnetsdkout[0] | Should Match "$runtimeName already installed"
|
||||
$runtimePath | Should Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "When installing a specific nupkg" {
|
||||
$name = [IO.Path]::GetFileNameWithoutExtension($specificNupkgName)
|
||||
$runtimeRoot = "$env:USER_DOTNET_PATH\packages\$name"
|
||||
|
||||
It "unpacks the runtime" {
|
||||
rundotnetsdk install $specificNupkgPath
|
||||
}
|
||||
|
||||
It "installs the runtime into the user directory" {
|
||||
$runtimeRoot | Should Exist
|
||||
}
|
||||
|
||||
It "did not assign an alias" {
|
||||
dir "$env:USER_DOTNET_PATH\alias\*.txt" | ForEach-Object {
|
||||
$_ | Should Not Contain $name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
# Clean the global directory
|
||||
del -rec -for $env:GLOBAL_DOTNET_PATH
|
||||
}
|
||||
}
|
|
@ -1,87 +1,87 @@
|
|||
# Ensure some KREs have been installed (if the other tests ran first, we're good)
|
||||
runkvm install $TestKreVersion -arch "x86" -r "CLR"
|
||||
rundotnetsdk install $TestDotNetVersion -arch "x86" -r "CLR"
|
||||
|
||||
$notRealKreVersion = "0.0.1-notarealkre"
|
||||
$notRealRuntimeVersion = "0.0.1-notarealkre"
|
||||
|
||||
$kreName = GetKreName "CLR" "x86"
|
||||
$notRealKreName = GetKreName "CLR" "x86" $notRealKreVersion
|
||||
$runtimeName = GetKreName "CLR" "x86"
|
||||
$notRealRuntimeName = GetKreName "CLR" "x86" $notRealRuntimeVersion
|
||||
|
||||
$testAlias = "use_test_" + [Guid]::NewGuid().ToString("N")
|
||||
$notRealAlias = "use_notReal_" + [Guid]::NewGuid().ToString("N")
|
||||
$bogusAlias = "use_bogus_" + [Guid]::NewGuid().ToString("N")
|
||||
|
||||
runkvm alias $testAlias $TestKreVersion -arch "x86" -r "CLR"
|
||||
runkvm use none
|
||||
rundotnetsdk alias $testAlias $TestDotNetVersion -arch "x86" -r "CLR"
|
||||
rundotnetsdk use none
|
||||
|
||||
Describe "kvm-ps1 use" -Tag "kvm-use" {
|
||||
Context "When use-ing without a runtime or architecture" {
|
||||
runkvm use $TestKreVersion
|
||||
$kreName = GetKreName -clr CLR -arch x86
|
||||
Describe "dotnetsdk-ps1 use" -Tag "dotnetsdk-use" {
|
||||
Context "When use-ing without a clr or architecture" {
|
||||
rundotnetsdk use $TestDotNetVersion
|
||||
$runtimeName = GetKreName -clr CLR -arch x86
|
||||
|
||||
It "uses x86/CLR variant" {
|
||||
GetActiveKreName | Should Be $kreName
|
||||
GetActiveKreName | Should Be $runtimeName
|
||||
}
|
||||
|
||||
runkvm use none
|
||||
rundotnetsdk use none
|
||||
}
|
||||
|
||||
Context "When use-ing a KRE" {
|
||||
runkvm use $TestKreVersion
|
||||
$kreName = GetKreName -clr CLR -arch x86
|
||||
Context "When use-ing a runtime" {
|
||||
rundotnetsdk use $TestDotNetVersion
|
||||
$runtimeName = GetKreName -clr CLR -arch x86
|
||||
|
||||
It "puts K on the PATH" {
|
||||
$cmd = Get-Command k -ErrorAction SilentlyContinue
|
||||
$cmd | Should Not BeNullOrEmpty
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$kreName\bin\k.cmd")
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$runtimeName\bin\k.cmd")
|
||||
}
|
||||
|
||||
It "puts kpm on the PATH" {
|
||||
$cmd = Get-Command kpm -ErrorAction SilentlyContinue
|
||||
$cmd | Should Not BeNullOrEmpty
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$kreName\bin\kpm.cmd")
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$runtimeName\bin\kpm.cmd")
|
||||
}
|
||||
|
||||
It "puts klr on the PATH" {
|
||||
$cmd = Get-Command klr -ErrorAction SilentlyContinue
|
||||
$cmd | Should Not BeNullOrEmpty
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$kreName\bin\klr.exe")
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$runtimeName\bin\klr.exe")
|
||||
}
|
||||
|
||||
runkvm use none
|
||||
rundotnetsdk use none
|
||||
}
|
||||
|
||||
Context "When use-ing an alias" {
|
||||
# Sanity check assumptions
|
||||
Get-Command k -ErrorAction SilentlyContinue | Should BeNullOrEmpty
|
||||
|
||||
runkvm use $testAlias
|
||||
rundotnetsdk use $testAlias
|
||||
|
||||
It "puts K on the PATH" {
|
||||
$cmd = Get-Command k -ErrorAction SilentlyContinue
|
||||
$cmd | Should Not BeNullOrEmpty
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$kreName\bin\k.cmd")
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$runtimeName\bin\k.cmd")
|
||||
}
|
||||
|
||||
It "puts kpm on the PATH" {
|
||||
$cmd = Get-Command kpm -ErrorAction SilentlyContinue
|
||||
$cmd | Should Not BeNullOrEmpty
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$kreName\bin\kpm.cmd")
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$runtimeName\bin\kpm.cmd")
|
||||
}
|
||||
|
||||
It "puts klr on the PATH" {
|
||||
$cmd = Get-Command klr -ErrorAction SilentlyContinue
|
||||
$cmd | Should Not BeNullOrEmpty
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$kreName\bin\klr.exe")
|
||||
$cmd.Definition | Should Be (Convert-Path "$env:USER_KRE_PATH\packages\$runtimeName\bin\klr.exe")
|
||||
}
|
||||
}
|
||||
|
||||
Context "When use-ing 'none'" {
|
||||
runkvm use $TestKreVersion
|
||||
rundotnetsdk use $TestDotNetVersion
|
||||
|
||||
runkvm use none
|
||||
rundotnetsdk use none
|
||||
|
||||
It "removes the KRE from the PATH" {
|
||||
GetKresOnPath | Should BeNullOrEmpty
|
||||
GetRuntimesOnPath | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "removes K from the PATH" {
|
||||
|
@ -99,15 +99,15 @@ Describe "kvm-ps1 use" -Tag "kvm-use" {
|
|||
|
||||
Context "When use-ing a non-existant version" {
|
||||
It "should throw an error" {
|
||||
runkvm use $notRealKreVersion
|
||||
$kvmerr[0].Exception.Message | Should Be "Cannot find $notRealKreName, do you need to run 'kvm install $notRealKreVersion'?"
|
||||
rundotnetsdk use $notRealRuntimeVersion
|
||||
$dotnetsdkerr[0].Exception.Message | Should Be "Cannot find $notRealRuntimeName, do you need to run 'dotnetsdk install $notRealRuntimeVersion'?"
|
||||
}
|
||||
}
|
||||
|
||||
Context "When use-ing a non-existant alias" {
|
||||
It "should throw an error" {
|
||||
runkvm use "bogus_alias_that_does_not_exist"
|
||||
$kvmerr[0].Exception.Message | Should Be "Cannot find KRE-CLR-x86.bogus_alias_that_does_not_exist, do you need to run 'kvm install bogus_alias_that_does_not_exist'?"
|
||||
rundotnetsdk use "bogus_alias_that_does_not_exist"
|
||||
$dotnetsdkerr[0].Exception.Message | Should Be "Cannot find DotNet-CLR-x86.bogus_alias_that_does_not_exist, do you need to run 'dotnetsdk install bogus_alias_that_does_not_exist'?"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
# Ensure a KRE has been installed (if the other tests ran first, we're good)
|
||||
runkvm install $TestKreVersion -arch "x86" -r "CLR"
|
||||
|
||||
$notRealKreVersion = "0.0.1-notarealkre"
|
||||
|
||||
$kreName = GetKreName "CLR" "x86"
|
||||
$notRealKreName = GetKreName "CLR" "x86" $notRealKreVersion
|
||||
|
||||
$testAlias = "alias_test_" + [Guid]::NewGuid().ToString("N")
|
||||
$testDefaultAlias = "alias_testDefault_" + [Guid]::NewGuid().ToString("N")
|
||||
$notRealAlias = "alias_notReal_" + [Guid]::NewGuid().ToString("N")
|
||||
$bogusAlias = "alias_bogus_" + [Guid]::NewGuid().ToString("N")
|
||||
|
||||
Describe "kvm-ps1 alias" -Tag "kvm-alias" {
|
||||
Context "When defining an alias for a KRE that exists" {
|
||||
runkvm alias $testAlias $TestKreVersion -x86 -r CLR
|
||||
|
||||
It "writes the alias file" {
|
||||
"$env:USER_KRE_PATH\alias\$testAlias.txt" | Should Exist
|
||||
"$env:USER_KRE_PATH\alias\$testAlias.txt" | Should ContainExactly $kreName
|
||||
}
|
||||
}
|
||||
|
||||
Context "When defining an alias for a KRE with no arch or clr parameters" {
|
||||
runkvm alias $testDefaultAlias $TestKreVersion
|
||||
|
||||
It "writes the x86/CLR variant to the alias file" {
|
||||
"$env:USER_KRE_PATH\alias\$testDefaultAlias.txt" | Should Exist
|
||||
"$env:USER_KRE_PATH\alias\$testDefaultAlias.txt" | Should ContainExactly $kreName
|
||||
}
|
||||
}
|
||||
|
||||
Context "When defining an alias for a KRE that does not exist" {
|
||||
runkvm alias $notRealAlias $notRealKreVersion -x86 -r CLR
|
||||
|
||||
It "writes the alias file" {
|
||||
"$env:USER_KRE_PATH\alias\$notRealAlias.txt" | Should Exist
|
||||
"$env:USER_KRE_PATH\alias\$notRealAlias.txt" | Should ContainExactly $notRealKreName
|
||||
}
|
||||
}
|
||||
|
||||
Context "When displaying an alias" {
|
||||
runkvm alias $testAlias
|
||||
It "outputs the value of the alias" {
|
||||
$kvmout[0] | Should Be "Alias '$testAlias' is set to $kreName"
|
||||
}
|
||||
}
|
||||
|
||||
Context "When given an non-existant alias" {
|
||||
runkvm alias $bogusAlias
|
||||
|
||||
It "outputs an error" {
|
||||
$kvmout[0] | Should Be "Alias '$bogusAlias' does not exist"
|
||||
}
|
||||
|
||||
It "returns a non-zero exit code" {
|
||||
$kvmexit | Should Not Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context "When displaying all aliases" {
|
||||
$allAliases = runkvm alias | Out-String
|
||||
|
||||
It "lists all aliases in the alias files" {
|
||||
dir "$env:USER_KRE_PATH\alias\*.txt" | ForEach-Object {
|
||||
$alias = [Regex]::Escape([IO.Path]::GetFileNameWithoutExtension($_.Name))
|
||||
$val = [Regex]::Escape((Get-Content $_))
|
||||
|
||||
# On some consoles, the value of the alias gets cut off, so don't require it in the assertion.
|
||||
$allAliases | Should Match ".*$alias.*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "kvm-ps1 unalias" -Tag "kvm-alias" {
|
||||
Context "When removing an alias that does not exist" {
|
||||
runkvm unalias $bogusAlias
|
||||
|
||||
It "outputs an error" {
|
||||
$kvmout[0] | Should Be "Cannot remove alias, '$bogusAlias' is not a valid alias name"
|
||||
}
|
||||
|
||||
It "returns a non-zero exit code" {
|
||||
$kvmexit | Should Not Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context "When removing an alias that does exist" {
|
||||
runkvm unalias $testAlias
|
||||
|
||||
It "removes the alias file" {
|
||||
"$env:USER_KRE_PATH\alias\$testAlias.txt" | Should Not Exist
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,180 +0,0 @@
|
|||
$crossgenned=@("mscorlib") # List of assemblies to check native images for on CoreCLR
|
||||
|
||||
function DefineInstallTests($clr, $arch, [switch]$global, [switch]$noNative) {
|
||||
$kreHome = $env:USER_KRE_PATH
|
||||
$contextName = "for user"
|
||||
$alias = "install_test_$arch_$clr"
|
||||
|
||||
if($global) {
|
||||
$contextName = "globally"
|
||||
$alias = "global_$alias"
|
||||
$kreHome = $env:GLOBAL_KRE_PATH
|
||||
}
|
||||
|
||||
if($clr -eq "CoreCLR") {
|
||||
$fxName = "Asp.NetCore,Version=v5.0"
|
||||
} else {
|
||||
$fxName = "Asp.Net,Version=v5.0"
|
||||
}
|
||||
|
||||
$kreName = GetKreName $clr $arch
|
||||
$kreRoot = "$kreHome\packages\$kreName"
|
||||
|
||||
$nativeText = ""
|
||||
if($noNative) {
|
||||
$nativeText = " (without building native images)"
|
||||
}
|
||||
|
||||
Context "When installing $clr on $arch $contextName$nativeText" {
|
||||
It "downloads and unpacks a KRE" {
|
||||
if($global) {
|
||||
runkvm install $TestKreVersion -arch $arch -r $clr -a $alias -global
|
||||
} elseif($noNative) {
|
||||
runkvm install $TestKreVersion -arch $arch -r $clr -a $alias -nonative
|
||||
} else {
|
||||
runkvm install $TestKreVersion -arch $arch -r $clr -a $alias
|
||||
}
|
||||
}
|
||||
|
||||
It "installs the KRE into the user directory" {
|
||||
$kreRoot | Should Exist
|
||||
}
|
||||
|
||||
if($clr -eq "CoreCLR") {
|
||||
if($noNative) {
|
||||
It "did not crossgen native assemblies" {
|
||||
$crossgenned | ForEach-Object { "$kreRoot\bin\$_.ni.dll" } | Should Not Exist
|
||||
}
|
||||
} else {
|
||||
It "crossgenned native assemblies" {
|
||||
$crossgenned | ForEach-Object { "$kreRoot\bin\$_.ni.dll" } | Should Exist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "can restore packages for the HelloK sample" {
|
||||
pushd "$TestAppsDir\HelloK"
|
||||
try {
|
||||
& "$kreRoot\bin\kpm.cmd" restore
|
||||
} finally {
|
||||
popd
|
||||
}
|
||||
}
|
||||
|
||||
It "can run the HelloK sample" {
|
||||
pushd "$TestAppsDir\HelloK"
|
||||
try {
|
||||
$output = & "$kreRoot\bin\k.cmd" run
|
||||
$LASTEXITCODE | Should Be 0
|
||||
$fullOutput = [String]::Join("`r`n", $output)
|
||||
|
||||
$fullOutput | Should Match "K is sane!"
|
||||
$fullOutput | Should Match "Runtime Framework:\s+$fxName"
|
||||
} finally {
|
||||
popd
|
||||
}
|
||||
}
|
||||
|
||||
It "assigned the requested alias" {
|
||||
"$env:USER_KRE_PATH\alias\$alias.txt" | Should Exist
|
||||
"$env:USER_KRE_PATH\alias\$alias.txt" | Should ContainExactly $kreName
|
||||
}
|
||||
|
||||
It "uses the new KRE" {
|
||||
GetActiveKreName $kreHome | Should Be "$kreName"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "kvm-ps1 install" -Tag "kvm-install" {
|
||||
try {
|
||||
DefineInstallTests "CLR" "x86"
|
||||
DefineInstallTests "CLR" "amd64"
|
||||
DefineInstallTests "CoreCLR" "x86" -noNative
|
||||
DefineInstallTests "CoreCLR" "amd64"
|
||||
DefineInstallTests "CLR" "x86" -global
|
||||
|
||||
Context "When installing a non-existant KRE version" {
|
||||
runkvm install "0.0.1-thisisnotarealKRE"
|
||||
|
||||
It "returns a non-zero exit code" {
|
||||
$kvmexit | Should Not Be 0
|
||||
}
|
||||
|
||||
It "throws a 404 error" {
|
||||
$kvmerr[0].Exception.Message | Should Be 'Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found."'
|
||||
}
|
||||
}
|
||||
|
||||
Context "When no architecture is specified" {
|
||||
runkvm install $TestKreVersion -r CLR
|
||||
$kreName = GetKreName -clr CLR -arch x86
|
||||
|
||||
It "uses x86" {
|
||||
$kvmout[0] | Should Be "$kreName already installed."
|
||||
}
|
||||
}
|
||||
|
||||
Context "When no runtime is specified" {
|
||||
runkvm install $TestKreVersion -arch x86
|
||||
$kreName = GetKreName -clr CLR -arch x86
|
||||
|
||||
It "uses CLR" {
|
||||
$kvmout[0] | Should Be "$kreName already installed."
|
||||
}
|
||||
}
|
||||
|
||||
Context "When neither architecture no runtime is specified" {
|
||||
runkvm install $TestKreVersion
|
||||
$kreName = GetKreName -clr CLR -arch x86
|
||||
|
||||
It "uses x86/CLR" {
|
||||
$kvmout[0] | Should Be "$kreName already installed."
|
||||
}
|
||||
}
|
||||
|
||||
Context "When installing latest" {
|
||||
$previous = @(dir "$env:USER_KRE_PATH\packages" | select -ExpandProperty Name)
|
||||
It "downloads a KRE" {
|
||||
runkvm install latest -arch x86 -r CLR
|
||||
}
|
||||
# TODO: Check that it actually installed the latest?
|
||||
}
|
||||
|
||||
Context "When installing an already-installed KRE" {
|
||||
# Clear active KRE
|
||||
runkvm use none
|
||||
|
||||
$kreName = GetKreName "CLR" "x86"
|
||||
$krePath = "$env:USER_KRE_PATH\packages\$kreName"
|
||||
It "ensures the KRE is installed" {
|
||||
runkvm install $TestKreVersion -x86 -r "CLR"
|
||||
$kvmout[0] | Should Match "$kreName already installed"
|
||||
$krePath | Should Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "When installing a specific nupkg" {
|
||||
$name = [IO.Path]::GetFileNameWithoutExtension($specificNupkgName)
|
||||
$kreRoot = "$env:USER_KRE_PATH\packages\$name"
|
||||
|
||||
It "unpacks the KRE" {
|
||||
runkvm install $specificNupkgPath
|
||||
}
|
||||
|
||||
It "installs the KRE into the user directory" {
|
||||
$kreRoot | Should Exist
|
||||
}
|
||||
|
||||
It "did not assign an alias" {
|
||||
dir "$env:USER_KRE_PATH\alias\*.txt" | ForEach-Object {
|
||||
$_ | Should Not Contain $name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
# Clean the global directory
|
||||
del -rec -for $env:GLOBAL_KRE_PATH
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче