Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Mar 12, 2024
1 parent 3a03786 commit c0474d2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/Chisel/ChiselTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Chisel;
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Global", Justification = "For MSBuild")]
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global", Justification = "For MSBuild")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global", Justification = "For MSBuild")]
[SuppressMessage("ReSharper", "UnusedType.Global", Justification = "For MSBuild")]
public class ChiselTask : Task
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Chisel/DependencyGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal sealed class DependencyGraph
private static Package CreatePackage(LockFileTargetLibrary library)
{
var name = library.Name ?? throw new ArgumentException("The library must have a name", nameof(library));
var version = library.Version?.ToString() ?? throw new ArgumentException("The library must have a version", nameof(library));
var version = library.Version?.ToString() ?? throw new ArgumentException($"The library \"{name}\" must have a version", nameof(library));
var type = library.Type switch
{
"package" => PackageType.Package,
Expand Down
29 changes: 8 additions & 21 deletions tests/Chisel.Tests/ChiseledAppTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -15,23 +14,11 @@
namespace Chisel.Tests;

[Trait("Category", "Integration")]
public sealed class ChiseledAppTests : IDisposable, IClassFixture<TestApp>
public sealed class ChiseledAppTests(ITestOutputHelper outputHelper, TestApp testApp) : IDisposable, IClassFixture<TestApp>
{
private readonly ITestOutputHelper _outputHelper;
private readonly TestApp _testApp;
private readonly AssertionScope _scope;
private readonly AssertionScope _scope = new();

public ChiseledAppTests(ITestOutputHelper outputHelper, TestApp testApp)
{
_outputHelper = outputHelper;
_testApp = testApp;
_scope = new AssertionScope();
}

public void Dispose()
{
_scope.Dispose();
}
public void Dispose() => _scope.Dispose();

public static readonly TheoryData<PublishMode> PublishModeData = new(Enum.GetValues<PublishMode>());

Expand Down Expand Up @@ -60,7 +47,7 @@ public async Task RunTestApp(PublishMode publishMode)
stdOut.Should().Contain("");
stdErr.Should().BeEmpty();

await Verifier.VerifyFile(_testApp.IntermediateOutputPath.File("TestApp.Chisel.gv"))
await Verifier.VerifyFile(testApp.IntermediateOutputPath.File("TestApp.Chisel.gv"))
.UseTextForParameters(OperatingSystem.IsWindows() ? "windows" : "non-windows")
.DisableRequireUniquePrefix();
}
Expand All @@ -70,13 +57,13 @@ private async Task<(string StdOut, string StdErr)> RunTestAppAsync(PublishMode p
var stdOutBuilder = new StringBuilder();
var stdErrBuilder = new StringBuilder();

var command = Cli.Wrap(_testApp.GetExecutablePath(publishMode))
var command = Cli.Wrap(testApp.GetExecutablePath(publishMode))
.WithArguments(args)
.WithValidation(CommandResultValidation.None)
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdOutBuilder))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stdErrBuilder));

_outputHelper.WriteLine(command.ToString());
outputHelper.WriteLine(command.ToString());

var stopwatch = Stopwatch.StartNew();
var result = await command.ExecuteAsync();
Expand All @@ -85,8 +72,8 @@ private async Task<(string StdOut, string StdErr)> RunTestAppAsync(PublishMode p
var stdOut = stdOutBuilder.ToString().Trim();
var stdErr = stdErrBuilder.ToString().Trim();

_outputHelper.WriteLine($"⌚ Executed in {executionTime} ms");
_outputHelper.WriteLine(stdOut);
outputHelper.WriteLine($"⌚ Executed in {executionTime} ms");
outputHelper.WriteLine(stdOut);

if (result.ExitCode != 0)
{
Expand Down
8 changes: 3 additions & 5 deletions tests/Chisel.Tests/Support/TestApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -100,17 +99,16 @@ private async Task PublishAsync(PublishMode publishMode)

var outputDirectory = publishDirectory.SubDirectory(publishMode.ToString());

var publishArgsBase = new[] {
var publishArgs = new[] {
"publish",
"--no-restore",
"--configuration", "Release",
"--output", outputDirectory.FullName,
$"-p:PublishSingleFile={publishMode is PublishMode.SingleFile}",
};
var publishSingleFile = $"-p:PublishSingleFile={publishMode is PublishMode.SingleFile}";
var publishArgs = publishArgsBase.Append(publishSingleFile).ToArray();
await RunDotnetAsync(_workingDirectory, publishArgs);

var executableFileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "TestApp.exe" : "TestApp";
var executableFileName = OperatingSystem.IsWindows() ? "TestApp.exe" : "TestApp";
var executableFile = outputDirectory.File(executableFileName);
executableFile.Exists.Should().BeTrue();
var dlls = executableFile.Directory!.EnumerateFiles("*.dll");
Expand Down

0 comments on commit c0474d2

Please sign in to comment.