Skip to content

Commit

Permalink
Fix missing rid arguments, add fallback for rid source
Browse files Browse the repository at this point in the history
RID compiled will be empty when a cross platform build is done. Therefore Rid source needs to fall back to a default rid value.

Work done for #196
  • Loading branch information
atruskie committed Mar 27, 2020
1 parent 0358b8c commit c8c8a09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions tests/Acoustics.Test/AnalysisPrograms/MainEntryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MainEntryTests
//[DataRow(LinuxArm)]
//[DataRow(LinuxArm64)]
//[DataRow(WinArm64)]
public async Task DefaultCliWorks()
public async Task DefaultCliWorks(string rid)
{
using var console = new ConsoleRedirector();
var code = await MainEntry.Main(Array.Empty<string>());
Expand All @@ -53,7 +53,7 @@ public async Task DefaultCliWorks()
//[DataRow(LinuxArm)]
//[DataRow(LinuxArm64)]
//[DataRow(WinArm64)]
public async Task DefaultHelpWorks()
public async Task DefaultHelpWorks(string rid)
{
using var console = new ConsoleRedirector();
var code = await MainEntry.Main(new[] { "--help" });
Expand All @@ -76,7 +76,7 @@ public async Task DefaultHelpWorks()
//[DataRow(LinuxArm)]
//[DataRow(LinuxArm64)]
//[DataRow(WinArm64)]
public async Task DefaultVersionWorks()
public async Task DefaultVersionWorks(string rid)
{
using var console = new ConsoleRedirector();
var code = await MainEntry.Main(new[] { "--version" });
Expand All @@ -99,7 +99,7 @@ public async Task DefaultVersionWorks()
//[DataRow(LinuxArm)]
//[DataRow(LinuxArm64)]
//[DataRow(WinArm64)]
public async Task CheckEnvironmentWorks()
public async Task CheckEnvironmentWorks(string rid)
{
using var console = new ConsoleRedirector();
var code = await MainEntry.Main(new[] { "CheckEnvironment" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override TestResult[] Execute(ITestMethod testMethod)
$"The first argument of a {nameof(RuntimeIdentifierSpecificDataTestMethod)} must be a string representing an RID - but we got a null or empty string");
}

if (!AppConfigHelper.WellKnownRuntimeIdentifiers.Contains(rid))
if (this.RuntimeIdentifierSource != RidType.Actual && !AppConfigHelper.WellKnownRuntimeIdentifiers.Contains(rid))
{
throw new ArgumentException(
$"The first argument of a {nameof(RuntimeIdentifierSpecificDataTestMethod)} must be a string representing an RID - but we got <{rid}> which is not one of our well known RIDs");
Expand All @@ -51,18 +51,18 @@ public override TestResult[] Execute(ITestMethod testMethod)
var pseudo = AppConfigHelper.PseudoRuntimeIdentifier;
var actual = AppConfigHelper.RuntimeIdentifier;
var compiled = BuildMetadata.CompiledRuntimeIdentifer;
Trace.WriteLine($"RIDs: Pseudo={pseudo}, Actual={actual}, Compiled={compiled}. Using={this.RuntimeIdentifierSource}.");

var actualRid = this.RuntimeIdentifierSource switch
{
RidType.Actual => actual,
RidType.Compiled => string.IsNullOrEmpty(compiled)
? throw new ArgumentException($"BuildMetadata.CompiledRuntimeIdentifer was null or empty. Cannot use as {nameof(this.RuntimeIdentifierSource)}.")
: compiled,
// compiled will be empty when the --runtime argument is not supplied
RidType.Compiled => string.IsNullOrEmpty(compiled) ? pseudo : compiled,
RidType.Pseudo => pseudo,
_ => throw new InvalidOperationException($"RidType {this.RuntimeIdentifierSource} is not supported"),
};

Trace.WriteLine($"RIDs: Pseudo={pseudo}, Actual={actual}, Compiled={compiled}. Using={this.RuntimeIdentifierSource} which is {actualRid}.");

if (rid != actualRid)
{
var message = $"Test not executed. The current RID <{actualRid}> is not <{rid}>. {this.IgnoreMessage}";
Expand Down

0 comments on commit c8c8a09

Please sign in to comment.