mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Add integration test project
This commit is contained in:
13
Squirrel.sln
13
Squirrel.sln
@@ -26,11 +26,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squirrel.CommandLine.Tests"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7AC3A776-B582-4B65-9D03-BD52332B5CA3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrel.Packaging.Windows", "src\Squirrel.Packaging.Windows\Squirrel.Packaging.Windows.csproj", "{E35039C8-1F98-48EB-B7D5-08E33DF061A7}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squirrel.Packaging.Windows", "src\Squirrel.Packaging.Windows\Squirrel.Packaging.Windows.csproj", "{E35039C8-1F98-48EB-B7D5-08E33DF061A7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrel.Packaging.OSX", "src\Squirrel.Packaging.OSX\Squirrel.Packaging.OSX.csproj", "{3382BCB7-657E-4E7B-A2B9-D65AA4DA073B}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squirrel.Packaging.OSX", "src\Squirrel.Packaging.OSX\Squirrel.Packaging.OSX.csproj", "{3382BCB7-657E-4E7B-A2B9-D65AA4DA073B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrel.Deployment", "src\Squirrel.Deployment\Squirrel.Deployment.csproj", "{D19EA72C-E7AE-4A7B-924A-E7550901A49C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squirrel.Deployment", "src\Squirrel.Deployment\Squirrel.Deployment.csproj", "{D19EA72C-E7AE-4A7B-924A-E7550901A49C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squirrel.Integration.Tests", "test\Squirrel.Integration.Tests\Squirrel.Integration.Tests.csproj", "{1A20C135-05FA-4FBA-BC53-5E6E75E136B0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -70,6 +72,10 @@ Global
|
||||
{D19EA72C-E7AE-4A7B-924A-E7550901A49C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D19EA72C-E7AE-4A7B-924A-E7550901A49C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D19EA72C-E7AE-4A7B-924A-E7550901A49C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1A20C135-05FA-4FBA-BC53-5E6E75E136B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1A20C135-05FA-4FBA-BC53-5E6E75E136B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1A20C135-05FA-4FBA-BC53-5E6E75E136B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1A20C135-05FA-4FBA-BC53-5E6E75E136B0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -77,6 +83,7 @@ Global
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{98AEB048-E27D-42F4-9440-505B7F78BAFD} = {7AC3A776-B582-4B65-9D03-BD52332B5CA3}
|
||||
{519EAB50-47B8-425F-8B20-AB9548F220B4} = {7AC3A776-B582-4B65-9D03-BD52332B5CA3}
|
||||
{1A20C135-05FA-4FBA-BC53-5E6E75E136B0} = {7AC3A776-B582-4B65-9D03-BD52332B5CA3}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {68CA987A-9BAB-4C75-8EEB-4596BA6BBD07}
|
||||
|
||||
@@ -11,6 +11,10 @@ path = "src/setup.rs"
|
||||
name = "update"
|
||||
path = "src/update.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "testapp"
|
||||
path = "src/testapp.rs"
|
||||
|
||||
[profile.release]
|
||||
opt-level = "z" # optimize for size
|
||||
lto = true # link-time optimization
|
||||
|
||||
16
src/Rust/src/testapp.rs
Normal file
16
src/Rust/src/testapp.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use anyhow::Result;
|
||||
use std::{fs::OpenOptions, io::Write};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
// Join the arguments with a space
|
||||
let line = args.join(" ") + "\n";
|
||||
|
||||
// Open "args.txt" for appending
|
||||
let mut file = OpenOptions::new().create(true).append(true).open("args.txt")?;
|
||||
|
||||
// Write the line to the file
|
||||
file.write_all(line.as_bytes())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -10,14 +10,14 @@ public class HelperFile
|
||||
|
||||
static HelperFile()
|
||||
{
|
||||
AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "wix");
|
||||
|
||||
#if DEBUG
|
||||
AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "build", "publish");
|
||||
AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "build", "Release", "squirrel", "tools");
|
||||
AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor");
|
||||
AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor", "wix");
|
||||
#endif
|
||||
// AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "wix");
|
||||
|
||||
//#if DEBUG
|
||||
// AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "build", "publish");
|
||||
// AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "build", "Release", "squirrel", "tools");
|
||||
// AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor");
|
||||
// AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor", "wix");
|
||||
//#endif
|
||||
}
|
||||
|
||||
public HelperFile(ILogger logger)
|
||||
@@ -25,6 +25,10 @@ public class HelperFile
|
||||
Log = logger;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
public static string FindTestFile(string toFind) => FindHelperFile(toFind, throwWhenNotFound: true);
|
||||
#endif
|
||||
|
||||
public static void AddSearchPath(params string[] pathParts)
|
||||
{
|
||||
AddSearchPath(Path.Combine(pathParts));
|
||||
@@ -97,7 +101,7 @@ public class ProcessFailedException : Exception
|
||||
public string Command { get; }
|
||||
public string StdOutput { get; }
|
||||
|
||||
public ProcessFailedException(string command, string stdOutput)
|
||||
public ProcessFailedException(string command, string stdOutput)
|
||||
: base($"Command failed:\n{command}\n\nOutput was:\n{stdOutput}")
|
||||
{
|
||||
Command = command;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
@@ -21,6 +22,11 @@ namespace Squirrel.NuGet
|
||||
public static readonly string PackageReferenceFile = "packages.config";
|
||||
public static readonly string MirroringReferenceFile = "mirroring.config";
|
||||
|
||||
public static bool IsDirectory(this ZipArchiveEntry entry)
|
||||
{
|
||||
return entry.FullName.EndsWith("/") || entry.FullName.EndsWith("\\") || String.IsNullOrEmpty(entry.Name);
|
||||
}
|
||||
|
||||
public static void ThrowIfInvalidNugetId(string id)
|
||||
{
|
||||
if (!IsValidNuGetId(id))
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace Squirrel.NuGet
|
||||
{
|
||||
public static class ZipExtensions
|
||||
{
|
||||
public static bool IsDirectory(this ZipArchiveEntry entry)
|
||||
{
|
||||
return entry.FullName.EndsWith("/") || entry.FullName.EndsWith("\\") || String.IsNullOrEmpty(entry.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: InternalsVisibleTo("Squirrel.Tests, PublicKey=" + SNK.SHA1)]
|
||||
[assembly: InternalsVisibleTo("Squirrel.Integration.Tests, PublicKey=" + SNK.SHA1)]
|
||||
[assembly: InternalsVisibleTo("Squirrel, PublicKey=" + SNK.SHA1)]
|
||||
[assembly: InternalsVisibleTo("Squirrel.Deployment, PublicKey=" + SNK.SHA1)]
|
||||
[assembly: InternalsVisibleTo("Squirrel.Packaging, PublicKey=" + SNK.SHA1)]
|
||||
|
||||
9
test/Squirrel.Integration.Tests/GlobalUsings.cs
Normal file
9
test/Squirrel.Integration.Tests/GlobalUsings.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
global using System;
|
||||
global using System.Collections.Generic;
|
||||
global using System.IO;
|
||||
global using System.Linq;
|
||||
global using System.Threading.Tasks;
|
||||
global using Microsoft.Extensions.Logging;
|
||||
//global using Microsoft.Extensions.Logging.Abstractions;
|
||||
global using Xunit;
|
||||
global using Xunit.Abstractions;
|
||||
22
test/Squirrel.Integration.Tests/Init.cs
Normal file
22
test/Squirrel.Integration.Tests/Init.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Squirrel.Packaging;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
[assembly: Xunit.TestFramework("Squirrel.Integration.Tests.TestsInit", "Squirrel.Integration.Tests")]
|
||||
|
||||
namespace Squirrel.Integration.Tests
|
||||
{
|
||||
public class TestsInit : XunitTestFramework
|
||||
{
|
||||
public TestsInit(IMessageSink messageSink)
|
||||
: base(messageSink)
|
||||
{
|
||||
var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location.Replace("file:///", ""));
|
||||
var projectdir = Path.Combine(baseDir, "..", "..", "..", "..", "..");
|
||||
HelperFile.AddSearchPath(Path.Combine(projectdir, "src\\Rust\\target\\debug"));
|
||||
HelperFile.AddSearchPath(Path.Combine(projectdir, "vendor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using Xunit;
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: CollectionBehavior(MaxParallelThreads=1, DisableTestParallelization=true)]
|
||||
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<IsTest>true</IsTest>
|
||||
<NoWarn>$(NoWarn);CS1998,xUnit2015,xUnit2017,xUnit2005,xUnit2009,xUnit2013,xUnit2004;CA2007</NoWarn>
|
||||
<SignAssembly>True</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\Squirrel.snk</AssemblyOriginatorKeyFile>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5" PrivateAssets="All" />
|
||||
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
|
||||
<PackageReference Include="Divergic.Logging.Xunit" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Squirrel.Packaging.Windows\Squirrel.Packaging.Windows.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
78
test/Squirrel.Integration.Tests/WindowsPackTests.cs
Normal file
78
test/Squirrel.Integration.Tests/WindowsPackTests.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
using System.Xml.Linq;
|
||||
using NuGet.Packaging;
|
||||
using Squirrel.Compression;
|
||||
using Squirrel.Packaging;
|
||||
using Squirrel.Packaging.Windows.Commands;
|
||||
|
||||
namespace Squirrel.Integration.Tests;
|
||||
|
||||
public class WindowsPackTests
|
||||
{
|
||||
private readonly ITestOutputHelper _output;
|
||||
|
||||
public WindowsPackTests(ITestOutputHelper output)
|
||||
{
|
||||
_output = output;
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void PackCommandBuildsValidPackageMostOptions()
|
||||
{
|
||||
Skip.IfNot(SquirrelRuntimeInfo.IsWindows);
|
||||
|
||||
using var logger = _output.BuildLoggerFor<WindowsPackTests>();
|
||||
|
||||
using var _1 = Utility.GetTempDirectory(out var tmpOutput);
|
||||
using var _2 = Utility.GetTempDirectory(out var tmpReleaseDir);
|
||||
using var _3 = Utility.GetTempDirectory(out var unzipDir);
|
||||
|
||||
var exe = "testapp.exe";
|
||||
var id = "Test.Squirrel-App";
|
||||
var version = "1.0.0";
|
||||
|
||||
File.Copy(HelperFile.FindTestFile(exe), Path.Combine(tmpOutput, exe));
|
||||
File.Copy(HelperFile.FindTestFile("testapp.pdb"), Path.Combine(tmpOutput, "testapp.pdb"));
|
||||
|
||||
var options = new WindowsPackOptions {
|
||||
EntryExecutableName = exe,
|
||||
ReleaseDir = new DirectoryInfo(tmpReleaseDir),
|
||||
PackId = id,
|
||||
PackVersion = version,
|
||||
TargetRuntime = RID.Parse("win10.0.19043-x64"),
|
||||
Runtimes = "net6",
|
||||
PackAuthors = "author",
|
||||
PackTitle = "Test Squirrel App",
|
||||
PackDirectory = tmpOutput,
|
||||
IncludePdb = true,
|
||||
};
|
||||
|
||||
var runner = new WindowsPackCommandRunner(logger);
|
||||
runner.Pack(options);
|
||||
|
||||
var nupkgPath = Path.Combine(tmpReleaseDir, $"{id}-{version}-win-x64-full.nupkg");
|
||||
|
||||
Assert.True(File.Exists(nupkgPath));
|
||||
|
||||
EasyZip.ExtractZipToDirectory(logger, nupkgPath, unzipDir);
|
||||
|
||||
// does nuspec exist and is it valid
|
||||
var nuspecPath = Path.Combine(unzipDir, $"{id}.nuspec");
|
||||
Assert.True(File.Exists(nuspecPath));
|
||||
var xml = XDocument.Load(nuspecPath);
|
||||
|
||||
Assert.Equal(id, xml.Root.ElementsNoNamespace("metadata").Single().ElementsNoNamespace("id").Single().Value);
|
||||
Assert.Equal(version, xml.Root.ElementsNoNamespace("metadata").Single().ElementsNoNamespace("version").Single().Value);
|
||||
Assert.Equal(exe, xml.Root.ElementsNoNamespace("metadata").Single().ElementsNoNamespace("mainExe").Single().Value);
|
||||
Assert.Equal("Test Squirrel App", xml.Root.ElementsNoNamespace("metadata").Single().ElementsNoNamespace("title").Single().Value);
|
||||
Assert.Equal("author", xml.Root.ElementsNoNamespace("metadata").Single().ElementsNoNamespace("authors").Single().Value);
|
||||
Assert.Equal("x64", xml.Root.ElementsNoNamespace("metadata").Single().ElementsNoNamespace("machineArchitecture").Single().Value);
|
||||
Assert.Equal("net6.0-x64-desktop", xml.Root.ElementsNoNamespace("metadata").Single().ElementsNoNamespace("runtimeDependencies").Single().Value);
|
||||
Assert.Equal("win", xml.Root.ElementsNoNamespace("metadata").Single().ElementsNoNamespace("os").Single().Value);
|
||||
Assert.Equal("10.0.19043", xml.Root.ElementsNoNamespace("metadata").Single().ElementsNoNamespace("osMinVersion").Single().Value);
|
||||
|
||||
// check for other files
|
||||
Assert.True(File.Exists(Path.Combine(unzipDir, "lib", "squirrel", "testapp.exe")));
|
||||
Assert.True(File.Exists(Path.Combine(unzipDir, "lib", "squirrel", "testapp.pdb")));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user