From 3c50c3cfb466eb20705e16a344c4880165674739 Mon Sep 17 00:00:00 2001 From: Anthony Truskinger Date: Thu, 26 Mar 2020 15:26:46 +1000 Subject: [PATCH] More cross-platform test fixes 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 --- build/azure-pipelines-build.yml | 7 ++- lib/audio-utils/osx-x64/sox/libmp3lame.dylib | 3 ++ tests/AED.Test/AED.Test.fsproj | 4 +- tests/Acoustics.Test/Acoustics.Test.csproj | 4 -- .../AnalysisPrograms/MainEntryTests.cs | 50 ++++++++++++++++--- tests/Acoustics.Test/RuntimesTests.cs | 6 +-- ...RuntimeIdentifierSpecificDataTestMethod.cs | 33 ++++++++++-- 7 files changed, 85 insertions(+), 22 deletions(-) create mode 100644 lib/audio-utils/osx-x64/sox/libmp3lame.dylib diff --git a/build/azure-pipelines-build.yml b/build/azure-pipelines-build.yml index 10c7d1f72..b040558b8 100644 --- a/build/azure-pipelines-build.yml +++ b/build/azure-pipelines-build.yml @@ -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] @@ -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 }} diff --git a/lib/audio-utils/osx-x64/sox/libmp3lame.dylib b/lib/audio-utils/osx-x64/sox/libmp3lame.dylib new file mode 100644 index 000000000..c6a0c85e5 --- /dev/null +++ b/lib/audio-utils/osx-x64/sox/libmp3lame.dylib @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7516473ef1424e81848ffb76af4d8e5cc3230d89eb773f07c10cccaf2c64e7e +size 723796 diff --git a/tests/AED.Test/AED.Test.fsproj b/tests/AED.Test/AED.Test.fsproj index 940ca8810..09affca4b 100644 --- a/tests/AED.Test/AED.Test.fsproj +++ b/tests/AED.Test/AED.Test.fsproj @@ -29,12 +29,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/Acoustics.Test/Acoustics.Test.csproj b/tests/Acoustics.Test/Acoustics.Test.csproj index e2be980f2..9551667b1 100644 --- a/tests/Acoustics.Test/Acoustics.Test.csproj +++ b/tests/Acoustics.Test/Acoustics.Test.csproj @@ -32,10 +32,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/tests/Acoustics.Test/AnalysisPrograms/MainEntryTests.cs b/tests/Acoustics.Test/AnalysisPrograms/MainEntryTests.cs index dca1669aa..3714ea9c9 100644 --- a/tests/Acoustics.Test/AnalysisPrograms/MainEntryTests.cs +++ b/tests/Acoustics.Test/AnalysisPrograms/MainEntryTests.cs @@ -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(); @@ -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(); @@ -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(); @@ -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); @@ -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`."); diff --git a/tests/Acoustics.Test/RuntimesTests.cs b/tests/Acoustics.Test/RuntimesTests.cs index 893b7be9a..393af1be5 100644 --- a/tests/Acoustics.Test/RuntimesTests.cs +++ b/tests/Acoustics.Test/RuntimesTests.cs @@ -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")] @@ -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")] diff --git a/tests/Acoustics.Test/TestHelpers/RuntimeIdentifierSpecificDataTestMethod.cs b/tests/Acoustics.Test/TestHelpers/RuntimeIdentifierSpecificDataTestMethod.cs index c96014280..93122c66b 100644 --- a/tests/Acoustics.Test/TestHelpers/RuntimeIdentifierSpecificDataTestMethod.cs +++ b/tests/Acoustics.Test/TestHelpers/RuntimeIdentifierSpecificDataTestMethod.cs @@ -1,4 +1,4 @@ -// +// // 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). // @@ -6,19 +6,31 @@ 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) @@ -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) {