Running Windows installer tests on Docker.

Cleaning up the Installer tests
- rename project to conform to the rest of the tests
- convert to .xproj
- clean up unused usings
This commit is contained in:
Eric Erhardt 2016-02-19 11:06:21 -06:00
parent 856a077bd1
commit d9adc9214a
14 changed files with 116 additions and 154 deletions

View file

@ -1,63 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{16614B7F-5CA3-45AE-95C2-003AB39CC09F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dotnet.Cli.Msi.Tests</RootNamespace>
<AssemblyName>Dotnet.Cli.Msi.Tests</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="InstallationTests.cs" />
<Compile Include="InstallFixture.cs" />
<Compile Include="MsiManager.cs" />
<Compile Include="PostInstallTests.cs" />
<Compile Include="PostUninstallTests.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<None Include="project.json" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dotnet.Cli.Msi.Tests
{
class Program
{
// A main method is currently required because of https://github.com/dotnet/cli/issues/314
public static void Main(string[] args)
{
return;
}
}
}

View file

@ -1,17 +0,0 @@
{
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"xunit": "2.1.0",
"xunit.runner.console": "2.1.0",
"Microsoft.Deployment.WindowsInstaller": "1.0.0"
},
"frameworks": {
"net46": {
"frameworkAssemblies": {
"System.Runtime": ""
}
}
}
}

View file

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Dotnet.Cli.Msi.Tests

View file

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;
[assembly: CollectionBehavior(DisableTestParallelization = true)]

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.23107" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.23107</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>0B31C336-149D-471A-B7B1-27B0F1E80F83</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Cli.Msi.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

View file

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Win32;
using Microsoft.Win32;
using Xunit;
namespace Dotnet.Cli.Msi.Tests

View file

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Win32;
using Microsoft.Win32;
using Xunit;
namespace Dotnet.Cli.Msi.Tests

View file

@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Dotnet.Cli.Msi.Tests")]
[assembly: AssemblyTitle("Microsoft.DotNet.Cli.Msi.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Dotnet.Cli.Msi.Tests")]
[assembly: AssemblyProduct("Microsoft.DotNet.Cli.Msi.Tests")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View file

@ -1,8 +1,6 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.Linq;
using Microsoft.Win32;
namespace Dotnet.Cli.Msi.Tests
{

View file

@ -0,0 +1,14 @@
{
"dependencies": {
"xunit": "2.1.0",
"xunit.runner.console": "2.1.0",
"Microsoft.Deployment.WindowsInstaller": "1.0.0"
},
"frameworks": {
"net46": {
"frameworkAssemblies": {
"System.Runtime": ""
}
}
}
}

View file

@ -7,23 +7,36 @@ param(
. "$PSScriptRoot\..\..\scripts\common\_common.ps1"
function Test-Administrator
{
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
function CopyInstaller([string]$destination)
{
# Copy both the .msi and the .exe to the testBin directory so
# the tests running in the docker container have access to them.
Copy-Item $inputMsi -Destination:$destination
$BundlePath = [System.IO.Path]::ChangeExtension($inputMsi, "exe")
Copy-Item $BundlePath -Destination:$destination
}
Write-Host "Running tests for MSI installer at $inputMsi.."
function CopyTestXUnitRunner([string]$destination)
{
$XUnitRunnerDir = Join-Path $env:NUGET_PACKAGES xunit.runner.console\2.1.0\tools
Copy-Item $XUnitRunnerDir\xunit.console.exe -Destination:$destination
Copy-Item $XUnitRunnerDir\xunit.runner.utility.desktop.dll -Destination:$destination
}
Write-Host "Running tests for MSI installer at $inputMsi."
if(!(Test-Path $inputMsi))
{
throw "$inputMsi not found"
}
$env:CLI_MSI=$inputMsi
$testDir="$PSScriptRoot\Dotnet.Cli.Msi.Tests"
$testBin="$RepoRoot\artifacts\tests\Dotnet.Cli.Msi.Tests"
$xunitRunner="$env:USERPROFILE\.dnx\packages\xunit.runner.console\2.1.0\tools\xunit.console.exe"
$testName = "Microsoft.DotNet.Cli.Msi.Tests"
$testDir="$PSScriptRoot\$testName"
$testBin="$RepoRoot\artifacts\tests\$testName"
pushd "$Stage2Dir\bin"
@ -48,22 +61,26 @@ try {
{
throw "dotnet publish failed with exit code $LastExitCode."
}
<#
if(-Not (Test-Administrator))
{
Write-Host -ForegroundColor Yellow "Current script testmsi.ps1 is not run as admin."
Write-Host -ForegroundColor Yellow "Executing MSI tests require admin privileges."
Write-Host -ForegroundColor Yellow "Failing silently."
Exit 0
}
& $xunitRunner $testBin\Dotnet.Cli.Msi.Tests.exe | Out-Host
if($LastExitCode -ne 0)
if($env:RunInstallerTestsInDocker)
{
throw "xunit runner failed with exit code $LastExitCode."
CopyInstaller $testBin
CopyTestXUnitRunner $testBin
Write-Host "Running installer tests in Windows Container"
$MsiFileName = [System.IO.Path]::GetFileName($inputMsi)
docker run `
-v "$testBin\:D:" `
-e "CLI_MSI=D:\$MsiFileName" `
windowsservercore `
D:\xunit.console.exe D:\$testName.dll | Out-Host
if($LastExitCode -ne 0)
{
throw "xunit runner failed with exit code $LastExitCode."
}
}
#>
}
finally {
popd