Skip to content

Commit

Permalink
More cross-platform test fixes
Browse files Browse the repository at this point in the history
Use a better RID for tests that depend only only running for certain RIDs.

Attempt to include lamp lib for MacOS SoX.

Include coverlet in AED.Test

Work done for #196
  • Loading branch information
atruskie committed Mar 26, 2020
1 parent 9e78583 commit 3c50c3c
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 22 deletions.
7 changes: 5 additions & 2 deletions build/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ parameters:
- rid: win-arm64
pool: windows-latest
configurations: [release]
continueOnError: true # not yet ready for release
unsupportedAzurePipelinesPlatform: true
- rid: linux-x64
pool: ubuntu-latest
configurations: [debug, release]
- rid: linux-musl-x64
pool: ubuntu-latest
configurations: [release]
unsupportedAzurePipelinesPlatform: true
- rid: linux-arm
pool: ubuntu-latest
configurations: [release]
unsupportedAzurePipelinesPlatform: true
- rid: linux-arm64
pool: ubuntu-latest
configurations: [release]
unsupportedAzurePipelinesPlatform: true
- rid: osx-x64
pool: macos-latest
configurations: [debug, release]
Expand All @@ -31,7 +34,7 @@ jobs:
- ${{ each configuration in platform.configurations }}:
- job:
displayName: Build ${{ format('{0}_{1}_{2}', platform.rid, platform.pool, configuration) }}
continueOnError: ${{ coalesce(platform.continueOnError, 'false') }}
continueOnError: ${{ coalesce(platform.unsupportedAzurePipelinesPlatform, 'false') }}
pool:
vmImage: ${{ platform.pool }}

Expand Down
3 changes: 3 additions & 0 deletions lib/audio-utils/osx-x64/sox/libmp3lame.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions tests/AED.Test/AED.Test.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
<PackageReference Include="FsCheck.Xunit" Version="3.0.0-alpha4" />
<PackageReference Include="FsUnit.xUnit" Version="3.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164">
<PackageReference Include="coverlet.collector" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Acoustics.Shared.FSharp\Acoustics.Shared.FSharp.fsproj" />
Expand Down
4 changes: 0 additions & 4 deletions tests/Acoustics.Test/Acoustics.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-unstable0024" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-unstable0702" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-unstable0421" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\AnalysisBase\AnalysisBase.csproj" />
Expand Down
50 changes: 44 additions & 6 deletions tests/Acoustics.Test/AnalysisPrograms/MainEntryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,23 @@ namespace Acoustics.Test.AnalysisPrograms
using global::AnalysisPrograms;
using global::AnalysisPrograms.Production.Arguments;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using static Acoustics.Shared.AppConfigHelper;

[TestClass]
[DoNotParallelize]
public class MainEntryTests
{
[DoNotParallelize]
[TestMethod]
[RuntimeIdentifierSpecificDataTestMethod(RidType.Compiled)]
[TestCategory("UnsupportedAzurePipelinesPlatform")]
[DataRow(WinX64)]
[DataRow(OsxX64)]
[DataRow(LinuxX64)]
[DataRow(LinuxMuslX64)]

//[DataRow(LinuxArm)]
//[DataRow(LinuxArm64)]
//[DataRow(WinArm64)]
public async Task DefaultCliWorks()
{
using var console = new ConsoleRedirector();
Expand All @@ -33,7 +43,16 @@ public async Task DefaultCliWorks()
}

[DoNotParallelize]
[TestMethod]
[RuntimeIdentifierSpecificDataTestMethod(RidType.Compiled)]
[TestCategory("UnsupportedAzurePipelinesPlatform")]
[DataRow(WinX64)]
[DataRow(OsxX64)]
[DataRow(LinuxX64)]
[DataRow(LinuxMuslX64)]

//[DataRow(LinuxArm)]
//[DataRow(LinuxArm64)]
//[DataRow(WinArm64)]
public async Task DefaultHelpWorks()
{
using var console = new ConsoleRedirector();
Expand All @@ -47,7 +66,16 @@ public async Task DefaultHelpWorks()
}

[DoNotParallelize]
[TestMethod]
[RuntimeIdentifierSpecificDataTestMethod(RidType.Compiled)]
[TestCategory("UnsupportedAzurePipelinesPlatform")]
[DataRow(WinX64)]
[DataRow(OsxX64)]
[DataRow(LinuxX64)]
[DataRow(LinuxMuslX64)]

//[DataRow(LinuxArm)]
//[DataRow(LinuxArm64)]
//[DataRow(WinArm64)]
public async Task DefaultVersionWorks()
{
using var console = new ConsoleRedirector();
Expand All @@ -61,13 +89,22 @@ public async Task DefaultVersionWorks()
}

[DoNotParallelize]
[TestMethod]
[RuntimeIdentifierSpecificDataTestMethod(RidType.Compiled)]
[TestCategory("UnsupportedAzurePipelinesPlatform")]
[DataRow(WinX64)]
[DataRow(OsxX64)]
[DataRow(LinuxX64)]
[DataRow(LinuxMuslX64)]

//[DataRow(LinuxArm)]
//[DataRow(LinuxArm64)]
//[DataRow(WinArm64)]
public async Task CheckEnvironmentWorks()
{
using var console = new ConsoleRedirector();
var code = await MainEntry.Main(new[] { "CheckEnvironment" });

Trace.WriteLine(console.Lines);
Trace.WriteLine(console.Lines.Join(Environment.NewLine));

Assert.AreEqual(0, code);

Expand Down Expand Up @@ -146,7 +183,8 @@ public void TestConfigCanBeLoadedWithShortName()
Trace.WriteLine("Output:\n" + output);
Trace.WriteLine("Error:\n" + error);

StringAssert.Contains(output,
StringAssert.Contains(
output,
"!!!IMPORTANT: Executable name is ANALYS~1.EXE and expected name is AnalysisPrograms.exe");
Assert.IsFalse(output.Contains("ReflectionTypeLoadException"), $"Output should not contain `ReflectionTypeLoadException`.");
Assert.IsFalse(error.Contains("ReflectionTypeLoadException"), $"Output should not contain `ReflectionTypeLoadException`.");
Expand Down
6 changes: 3 additions & 3 deletions tests/Acoustics.Test/RuntimesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace Acoustics.Test
[TestCategory("Runtime")]
public class RuntimesTests
{
[RuntimeIdentifierSpecificDataTestMethod]
[RuntimeIdentifierSpecificDataTestMethod(RidType.Compiled)]
[DataRow(WinX64, "win-x64/native/e_sqlite3.dll")]
[DataRow(WinArm64, "win-arm/native/e_sqlite3.dll")]
[DataRow(WinArm64, "win-arm64/native/e_sqlite3.dll")]
[DataRow(OsxX64, "osx-x64/native/libe_sqlite3.dylib")]
[DataRow(LinuxX64, "linux-x64/native/libe_sqlite3.so")]
[DataRow(LinuxMuslX64, "linux-musl-x64/native/libe_sqlite3.so")]
Expand All @@ -44,7 +44,7 @@ public void TestRequiredSqliteLibsCopiedToBuildDir(string rid, string expected)
#pragma warning restore IDE0035, CS0162
}

[RuntimeIdentifierSpecificDataTestMethod]
[RuntimeIdentifierSpecificDataTestMethod(RidType.Compiled)]
[DataRow(WinX64, "win-x64/lib/netstandard2.0/Mono.Posix.NETStandard.dll")]
[DataRow(OsxX64, "osx-x64/lib/netstandard2.0/Mono.Posix.NETStandard.dll")]
[DataRow(LinuxX64, "linux-x64/lib/netstandard2.0/Mono.Posix.NETStandard.dll")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
// <copyright file="RuntimeIdentifierSpecificTestMethod.cs" company="QutEcoacoustics">
// <copyright file="RuntimeIdentifierSpecificDataTestMethod.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>

namespace Acoustics.Test.TestHelpers
{
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

using Acoustics.Shared;
using global::AnalysisPrograms;
using JetBrains.Annotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;

public class RuntimeIdentifierSpecificDataTestMethod : DataTestMethodAttribute
public enum RidType
{
Pseudo,
Compiled,
Actual,
}

public RuntimeIdentifierSpecificDataTestMethod([CanBeNull] string ignoreMessage = null)
public class RuntimeIdentifierSpecificDataTestMethod : DataTestMethodAttribute
{
public RuntimeIdentifierSpecificDataTestMethod(
RidType runtimeIdentifierSource,
[CanBeNull] string ignoreMessage = null)
{
this.RuntimeIdentifierSource = runtimeIdentifierSource;
this.IgnoreMessage = ignoreMessage;
}

public RidType RuntimeIdentifierSource { get; set; }

public string IgnoreMessage { get; }

public override TestResult[] Execute(ITestMethod testMethod)
Expand All @@ -36,7 +48,18 @@ public override TestResult[] Execute(ITestMethod testMethod)
$"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");
}

var actualRid = AppConfigHelper.PseudoRuntimeIdentifier;
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 => compiled,
RidType.Pseudo => pseudo,
_ => throw new InvalidOperationException($"RidType {this.RuntimeIdentifierSource} is not supported"),
};

if (rid != actualRid)
{
Expand Down

0 comments on commit 3c50c3c

Please sign in to comment.