Skip to content

Commit

Permalink
consume lessio and libmspack4n as nuget packages. switches to xunit. f…
Browse files Browse the repository at this point in the history
…ixes #65. fixes #62. part of #61. fixes #60
  • Loading branch information
activescott committed May 28, 2016
1 parent 2e20132 commit 5a43f50
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 61 deletions.
20 changes: 11 additions & 9 deletions src/.build/lessmsi.msbuild
Expand Up @@ -27,14 +27,15 @@
</ItemGroup>

<ItemGroup>
<DeployFiles Include="$(RootDir)\..\bin\Release\AddWindowsExplorerShortcut.exe"></DeployFiles>
<DeployFiles Include="$(RootDir)\..\bin\Release\lessmsi.core.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\..\bin\Release\lessmsi.exe"></DeployFiles>
<DeployFiles Include="$(RootDir)\..\bin\Release\lessmsi.exe.config"></DeployFiles>
<DeployFiles Include="$(RootDir)\..\bin\Release\lessmsi-gui.exe"></DeployFiles>
<DeployFiles Include="$(RootDir)\..\bin\Release\lessmsi-gui.exe.config"></DeployFiles>
<DeployFiles Include="$(RootDir)\..\lib\libmspackn.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\..\lib\mspack.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\ExplorerShortcutHelper\bin\Release\AddWindowsExplorerShortcut.exe"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Core\bin\Release\lessmsi.core.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Cli\bin\Release\lessmsi.exe"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Cli\bin\Release\lessmsi.exe.config"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Gui\bin\Release\lessmsi-gui.exe"></DeployFiles>
<DeployFiles Include="$(RootDir)\LessMsi.Gui\bin\Release\lessmsi-gui.exe.config"></DeployFiles>
<DeployFiles Include="$(RootDir)\packages\libmspack4n.0.8.0\lib\net40\libmspackn.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\packages\libmspack4n.0.8.0\build\x86\mspack.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\packages\LessIO.0.3.0\lib\net40\LessIO.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\..\lib\wix.dll"></DeployFiles>
<DeployFiles Include="$(RootDir)\..\lib\wixcab.dll"></DeployFiles>
</ItemGroup>
Expand Down Expand Up @@ -112,7 +113,8 @@
SourceFiles="%(DeployFiles.FullPath)"
DestinationFolder="$(TheDeployDir)"
/>
</Target>

</Target>

<Target Name="Zip" DependsOnTargets="Deploy">
<!-- see https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Zip.cs -->
Expand Down
8 changes: 4 additions & 4 deletions src/LessMsi.Core/LessMsi.Core.csproj
Expand Up @@ -35,12 +35,12 @@
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="LessIO, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LessIO.0.2.0\lib\net40\LessIO.dll</HintPath>
<Reference Include="LessIO, Version=0.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LessIO.0.3.0\lib\net40\LessIO.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="libmspackn, Version=0.7.0.0, Culture=neutral, processorArchitecture=x86">
<HintPath>..\packages\libmspack4n.0.7.0\lib\net40\libmspackn.dll</HintPath>
<Reference Include="libmspackn, Version=0.8.0.0, Culture=neutral, processorArchitecture=x86">
<HintPath>..\packages\libmspack4n.0.8.0\lib\net40\libmspackn.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="wix">
Expand Down
4 changes: 2 additions & 2 deletions src/LessMsi.Core/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LessIO" version="0.2.0" targetFramework="net40" />
<package id="libmspack4n" version="0.7.0" targetFramework="net40" />
<package id="LessIO" version="0.3.0" targetFramework="net40" />
<package id="libmspack4n" version="0.8.0" targetFramework="net40" />
<package id="MSBuildTasks" version="1.4.0.128" targetFramework="net40" />
</packages>
2 changes: 0 additions & 2 deletions src/LessMsi.sln
Expand Up @@ -23,8 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{691765
.build\lessmsi.nuspec = .build\lessmsi.nuspec
.build\MSBuild.Community.Tasks.dll = .build\MSBuild.Community.Tasks.dll
.build\MSBuild.Community.Tasks.targets = .build\MSBuild.Community.Tasks.targets
.build\zipfile.msbuild.targets = .build\zipfile.msbuild.targets
.build\zipfile.test.msbuild = .build\zipfile.test.msbuild
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LessMsi.Core", "LessMsi.Core\LessMsi.Core.csproj", "{1FD916F2-1DF6-42F6-9AD4-83565FBF8E5C}"
Expand Down
36 changes: 20 additions & 16 deletions src/Lessmsi.Tests/CommandLineExtractTests.cs
@@ -1,59 +1,63 @@
using System;
using System.Diagnostics;
using LessIO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;

namespace LessMsi.Tests
{
[TestClass]
// We use Test Collections to prevent files get locked by seperate threads: http://xunit.github.io/docs/running-tests-in-parallel.html
[Collection("NUnit - 2.5.2.9222.msi")] // Since almost all of these use nunit we just put the whole class in the nunit collection.
public class CommandLineExtractTests : TestBase
{
[TestMethod]
[Fact]
public void Extract1Arg()
{
var commandLine = "x TestFiles\\MsiInput\\NUnit-2.5.2.9222.msi";
TestExtraction(commandLine, GetTestName(), "NUnit-2.5.2.9222", false);
}

[TestMethod]
[Fact]
public void Extract2Args()
{
var commandLine = "x TestFiles\\MsiInput\\NUnit-2.5.2.9222.msi Ex2Args\\";
TestExtraction(commandLine, GetTestName(), "Ex2Args", false);
}

[TestMethod]
[Fact]
public void Extract3Args()
{
var commandLine = "x TestFiles\\MsiInput\\NUnit-2.5.2.9222.msi Ex3\\ \"cs-money.build\" \"requiresMTA.html\"";
TestExtraction(commandLine, GetTestName(), "Ex3", false);
}

[TestMethod]
[Fact]
public void ExtractCompatibility1Arg()
{
var commandLine = @"/x TestFiles\MsiInput\NUnit-2.5.2.9222.msi";
TestExtraction(commandLine, GetTestName(), "NUnit-2.5.2.9222", false);
}

[TestMethod]
[Fact]
public void ExtractCompatibility2Args()
{
var commandLine = @"/x TestFiles\\MsiInput\\NUnit-2.5.2.9222.msi ExtractCompatibility2Args\";
TestExtraction(commandLine, GetTestName(), "ExtractCompatibility2Args", false);
}

[TestMethod, ExpectedException(typeof(ExitCodeException))]
[Fact]
public void BackwardCompatibilityParserNoMsiSpecifiedParser()
{
var commandLine = "/x";

string consoleOutput;
var exitCode = RunCommandLine(commandLine, out consoleOutput);
Assert.AreEqual(3, exitCode);
}
Assert.Throws(typeof(ExitCodeException), () =>
{
var exitCode = RunCommandLine(commandLine, out consoleOutput);
Assert.Equal(3, exitCode);
});
}

[TestMethod]
[Fact]
public void List()
{
var expectedOutput = @"Property,Value
Expand Down Expand Up @@ -100,16 +104,16 @@ public void List()

string consoleOutput;
RunCommandLine("l -t Property TestFiles\\MsiInput\\NUnit-2.5.2.9222.msi", out consoleOutput);
Assert.AreEqual(expectedOutput, consoleOutput);
Assert.Equal(expectedOutput, consoleOutput);
}

[TestMethod]
[Fact]
public void Version()
{
var expectedOutput = "2.5.2.9222" + Environment.NewLine;
string consoleOutput;
RunCommandLine("v TestFiles\\MsiInput\\NUnit-2.5.2.9222.msi", out consoleOutput);
Assert.AreEqual(expectedOutput, consoleOutput);
Assert.Equal(expectedOutput, consoleOutput);
}

#region Helpers
Expand Down Expand Up @@ -141,7 +145,7 @@ private void TestExtraction(string commandLineArguments, string testName, string
exitCode = base.RunCommandLineInProccess(commandLineArguments);
else
exitCode = base.RunCommandLine(commandLineArguments, out consoleOutput);
Assert.AreEqual(0, exitCode, "Exit code indicates error");
Assert.Equal(0, exitCode);
var actualEntries = FileEntryGraph.GetActualEntries(actualOutDir.FullPathString, "Actual Entries");
var actualEntriesFile = GetActualOutputFile(testName);
actualEntries.Save(actualEntriesFile);
Expand Down
31 changes: 29 additions & 2 deletions src/Lessmsi.Tests/LessMsi.Tests.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
Expand All @@ -10,12 +11,14 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LessMsi.Tests</RootNamespace>
<AssemblyName>LessMsi.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -26,6 +29,7 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\Release\</OutputPath>
Expand All @@ -35,20 +39,36 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="LessIO, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LessIO.0.2.0\lib\net40\LessIO.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.XML" />
<Reference Include="wix, Version=2.0.2110.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\wix.dll</HintPath>
</Reference>
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
Expand All @@ -58,6 +78,7 @@
<Compile Include="FileEntry.cs" />
<Compile Include="FileEntryGraph.cs" />
<Compile Include="MiscTests.cs" />
<Compile Include="MiscTestsNUnit.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestBase.cs" />
</ItemGroup>
Expand Down Expand Up @@ -90,6 +111,12 @@ xcopy /Y /S "$(ProjectDir)TestFiles" "$(TargetDir)TestFiles"</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="'$(OS)' == 'Windows_NT'" />
<Import Project="$(SolutionDir)\.nuget\NuGet.mono.targets" Condition="'$(OS)' == 'mono'" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<!-- 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">
Expand Down
28 changes: 10 additions & 18 deletions src/Lessmsi.Tests/MiscTests.cs
@@ -1,17 +1,17 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;

namespace LessMsi.Tests
{
[TestClass]

public class MiscTests : TestBase
{
[TestMethod]
[Fact]
public void InputPathWithSpace()
{
ExtractAndCompareToMaster("Path With Spaces\\spaces example.msi");
}

[TestMethod]
[Fact]
public void LongExtractionPath()
{
var msiFileName = "python-2.7.3.msi";
Expand All @@ -25,19 +25,13 @@ public void LongExtractionPath()
var actualFileEntries = ExtractFilesFromMsi(msiFileName, null, outputDir, returnFileEntryGraph);
}

[TestMethod]
public void NUnit()
{
ExtractAndCompareToMaster("NUnit-2.5.2.9222.msi");
}

/// <summary>
/// Related to issue 28 (http://code.google.com/p/lessmsi/issues/detail?id=28).
/// Where GUI extracted files differ from console extracted files.
/// Seems console is probably right. If I don't pass in the file list from the GUI it matches GUI. So probably in GUI am doing something wrong.
/// Negative: It seems they're both wrong. A dictionary/hashtable used in Wixtracts was using caseinsinitive lookups on MsiFile.File entries and in python msi some entries were differing only by case.
/// </summary>
[TestMethod]
[Fact]
public void Python()
{
ExtractAndCompareToMaster("python-2.7.3.msi");
Expand All @@ -46,7 +40,7 @@ public void Python()
/// <summary>
/// This is from issue 37 (http://code.google.com/p/lessmsi/issues/detail?id=37). Basically if you only checked some files in the UI this occured. Lame that I didn't have a test for it!
/// </summary>
[TestMethod]
[Fact]
public void ExtractOnlySomeFiles()
{
var msiFileName = "ExtractOnlySomeFiles.msi";
Expand All @@ -59,7 +53,7 @@ public void ExtractOnlySomeFiles()
/// <summary>
/// This test is for github issue 4: https://github.com/activescott/lessmsi/issues/4
/// </summary>
[TestMethod]
[Fact]
public void ExtractFromExternalCab()
{
ExtractAndCompareToMaster("msi_with_external_cab.msi");
Expand All @@ -71,8 +65,7 @@ public void ExtractFromExternalCab()
/// Actually many of them do, but this one ends up with such long paths that it causes an exception:
/// "Error: System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters."
/// </summary>
[TestMethod]
[Ignore]//(@"This one demonstrates a problem were paths are screwed up. Note that the output path ends up being SourceDir\SlikSvn\bin\Windows\winsxs\... and it should be just \windows\winsxs\...")]
[Fact(Skip=@"This one demonstrates a problem were paths are screwed up. Note that the output path ends up being SourceDir\SlikSvn\bin\Windows\winsxs\... and it should be just \windows\winsxs\...")]
public void SlikSvn()
{
ExtractAndCompareToMaster("Slik-Subversion-1.6.6-x64.msi");
Expand All @@ -82,8 +75,7 @@ public void SlikSvn()
/// from http://code.google.com/p/lessmsi/issues/detail?id=1
///
/// </summary>
[TestMethod]
[Ignore]//("This seems to have to do with the fact that the two CABs in there are merged cabs. MSVBVM60.dll is split across the cabs and I can get it out now with merging supported, but the olepro32.dll file is in disk2.cab and I can't get out with libmspack. Neither can totalcommander. -scott")]
[Fact(Skip = "This seems to have to do with the fact that the two CABs in there are merged cabs. MSVBVM60.dll is split across the cabs and I can get it out now with merging supported, but the olepro32.dll file is in disk2.cab and I can't get out with libmspack. Neither can totalcommander. -scott")]
public void VBRuntime()
{
ExtractAndCompareToMaster("VBRuntime.msi");
Expand All @@ -93,7 +85,7 @@ public void VBRuntime()
/// from https://github.com/activescott/lessmsi/issues/49
///
/// </summary>
[TestMethod]
[Fact]
public void EmptyCabinetFieldInMediaTable()
{
ExtractAndCompareToMaster("X86 Debuggers And Tools-x86_en-us.msi");
Expand Down
15 changes: 15 additions & 0 deletions src/Lessmsi.Tests/MiscTestsNUnit.cs
@@ -0,0 +1,15 @@
using Xunit;

namespace LessMsi.Tests
{
// We use Test Collections to prevent files get locked by seperate threads: http://xunit.github.io/docs/running-tests-in-parallel.html
[Collection("NUnit - 2.5.2.9222.msi")]
public class MiscTestsNunit : TestBase
{
[Fact]
public void NUnit()
{
ExtractAndCompareToMaster("NUnit-2.5.2.9222.msi");
}
}
}
1 change: 1 addition & 0 deletions src/Lessmsi.Tests/Properties/AssemblyInfo.cs
Expand Up @@ -29,3 +29,4 @@
// associated with an assembly.
[assembly: AssemblyTitle("Lessmsi.Tests")]
[assembly: AssemblyDescription("")]
[assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)] // Disable other files get locked by seperate threads: http://xunit.github.io/docs/running-tests-in-parallel.html

0 comments on commit 5a43f50

Please sign in to comment.