mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-14 01:55:45 +00:00
Only run downloader tests on windows and linux since macos CI runs on arm which builds are not available for
This commit is contained in:
parent
07253b4b49
commit
3be446880a
3 changed files with 58 additions and 2 deletions
13
FFMpegCore.Extensions.Downloader/Enums/EnumExtensions.cs
Normal file
13
FFMpegCore.Extensions.Downloader/Enums/EnumExtensions.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
namespace FFMpegCore.Extensions.Downloader.Enums;
|
||||||
|
|
||||||
|
public static class EnumExtensions
|
||||||
|
{
|
||||||
|
public static TEnum[] GetFlags<TEnum>(this TEnum input) where TEnum : Enum
|
||||||
|
{
|
||||||
|
return Enum.GetValues(input.GetType())
|
||||||
|
.Cast<Enum>()
|
||||||
|
.Where(input.HasFlag)
|
||||||
|
.Cast<TEnum>()
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
using FFMpegCore.Extensions.Downloader;
|
using FFMpegCore.Extensions.Downloader;
|
||||||
using FFMpegCore.Extensions.Downloader.Enums;
|
using FFMpegCore.Extensions.Downloader.Enums;
|
||||||
|
using FFMpegCore.Test.Utilities;
|
||||||
|
|
||||||
namespace FFMpegCore.Test;
|
namespace FFMpegCore.Test;
|
||||||
|
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class DownloaderTests
|
public class DownloaderTests
|
||||||
{
|
{
|
||||||
[TestMethod]
|
[OsSpecificTestMethod(OsPlatforms.Windows | OsPlatforms.Linux)]
|
||||||
public async Task GetSpecificVersionTest()
|
public async Task GetSpecificVersionTest()
|
||||||
{
|
{
|
||||||
var binaries = await FFMpegDownloader.DownloadFFMpegSuite(FFMpegVersions.V6_1);
|
var binaries = await FFMpegDownloader.DownloadFFMpegSuite(FFMpegVersions.V6_1);
|
||||||
|
|
@ -20,7 +21,7 @@ public class DownloaderTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[OsSpecificTestMethod(OsPlatforms.Windows | OsPlatforms.Linux)]
|
||||||
public async Task GetAllLatestSuiteTest()
|
public async Task GetAllLatestSuiteTest()
|
||||||
{
|
{
|
||||||
var binaries = await FFMpegDownloader.DownloadFFMpegSuite();
|
var binaries = await FFMpegDownloader.DownloadFFMpegSuite();
|
||||||
|
|
|
||||||
42
FFMpegCore.Test/Utilities/OsSpecificTestMethod.cs
Normal file
42
FFMpegCore.Test/Utilities/OsSpecificTestMethod.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using FFMpegCore.Extensions.Downloader.Enums;
|
||||||
|
|
||||||
|
namespace FFMpegCore.Test.Utilities;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
internal enum OsPlatforms : ushort
|
||||||
|
{
|
||||||
|
Windows,
|
||||||
|
Linux,
|
||||||
|
MacOS
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class OsSpecificTestMethod : TestMethodAttribute
|
||||||
|
{
|
||||||
|
private readonly IEnumerable<OSPlatform> _supportedOsPlatforms;
|
||||||
|
|
||||||
|
public OsSpecificTestMethod(OsPlatforms supportedOsPlatforms, [CallerFilePath] string callerFilePath = "",
|
||||||
|
[CallerLineNumber] int callerLineNumber = -1) : base(callerFilePath, callerLineNumber)
|
||||||
|
{
|
||||||
|
_supportedOsPlatforms = supportedOsPlatforms.GetFlags()
|
||||||
|
.Select(flag => OSPlatform.Create(flag.ToString().ToUpperInvariant()))
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<TestResult[]> ExecuteAsync(ITestMethod testMethod)
|
||||||
|
{
|
||||||
|
if (_supportedOsPlatforms.Any(RuntimeInformation.IsOSPlatform))
|
||||||
|
{
|
||||||
|
return await base.ExecuteAsync(testMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
var message = $"Test only executed on specific platforms: {string.Join(", ", _supportedOsPlatforms.Select(platform => platform.ToString()))}";
|
||||||
|
{
|
||||||
|
return
|
||||||
|
[
|
||||||
|
new TestResult { Outcome = UnitTestOutcome.Inconclusive, TestFailureException = new AssertInconclusiveException(message) }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue