Skip to content

Commit

Permalink
Simplify accessing the IntermediateOutputPath
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Mar 11, 2024
1 parent cf7f515 commit 5c96048
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions tests/Chisel.Tests/ChiseledAppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public async Task RunTestApp(PublishMode publishMode)
stdOut.Should().Contain("");
stdErr.Should().BeEmpty();

var intermediateOutputPath = await _testApp.GetIntermediateOutputPathAsync();
await Verifier.VerifyFile(Path.Combine(intermediateOutputPath, "TestApp.Chisel.gv")).DisableRequireUniquePrefix();
await Verifier.VerifyFile(_testApp.IntermediateOutputPath.File("TestApp.Chisel.gv")).DisableRequireUniquePrefix();
}

private async Task<(string StdOut, string StdErr)> RunTestAppAsync(PublishMode publishMode, params string[] args)
Expand Down
11 changes: 5 additions & 6 deletions tests/Chisel.Tests/Support/TestApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ Task IAsyncLifetime.DisposeAsync()

public string GetExecutablePath(PublishMode publishMode) => _executables[publishMode].FullName;

public async Task<string> GetIntermediateOutputPathAsync()
{
var result = await RunDotnetAsync(_workingDirectory, "build", "--getProperty:IntermediateOutputPath", "--configuration", "Release");
return Path.Combine(_workingDirectory.FullName, result.TrimEnd());
}
public DirectoryInfo IntermediateOutputPath { get; private set; }

private async Task CreateTestAppAsync()
{
Expand Down Expand Up @@ -93,6 +89,9 @@ private async Task RestoreAsync()
"-p:Configuration=Release",
};
await RunDotnetAsync(_workingDirectory, restoreArgs);

var intermediateOutputPath = await RunDotnetAsync(_workingDirectory, "build", "--getProperty:IntermediateOutputPath", "--configuration", "Release");
IntermediateOutputPath = _workingDirectory.SubDirectory(intermediateOutputPath.TrimEnd());
}

private async Task PublishAsync(PublishMode publishMode)
Expand All @@ -112,7 +111,7 @@ private async Task PublishAsync(PublishMode publishMode)
await RunDotnetAsync(_workingDirectory, publishArgs);

var executableFileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "TestApp.exe" : "TestApp";
var executableFile = new FileInfo(Path.Combine(outputDirectory.FullName, executableFileName));
var executableFile = outputDirectory.File(executableFileName);
executableFile.Exists.Should().BeTrue();
var dlls = executableFile.Directory!.EnumerateFiles("*.dll");
if (publishMode == PublishMode.Standard)
Expand Down

0 comments on commit 5c96048

Please sign in to comment.