diff --git a/.gitignore b/.gitignore index 4fadda2b4..5cb3f652b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ YamlDotNet/Properties/AssemblyInfo.Generated.cs /YamlDotNet/Properties/AssemblyInfo.cs BenchmarkDotNet.Artifacts +/YamlDotNet.AotTest/exitcode.txt diff --git a/YamlDotNet.AotTest/Program.cs b/YamlDotNet.AotTest/Program.cs index b67fd82e4..3e963a1ca 100644 --- a/YamlDotNet.AotTest/Program.cs +++ b/YamlDotNet.AotTest/Program.cs @@ -12,11 +12,10 @@ class Program static int Main(string[] args) { Console.WriteLine(); - Console.WriteLine("---------------------------------------------------------------------------------"); + Console.WriteLine("\x1b[37m---------------------------------------------------------------------------------"); Console.WriteLine(); - Console.ForegroundColor = ConsoleColor.White; - Console.WriteLine(" Running AOT tests..."); + Console.WriteLine("\x1b[97m Running AOT tests..."); Console.WriteLine(); TryDeserialize("DictionaryNodeDeserializer", "myDictionary: { winners: 3 }"); @@ -25,13 +24,11 @@ static int Main(string[] args) TrySerialize("TraverseGenericDictionary", new GenericTestDictionary { { 1, 2 } }); Console.WriteLine(); - Console.ForegroundColor = ConsoleColor.White; - Console.WriteLine(" {0} test succeeded, {1} tests failed", succeededTestCount, failedTestCount); + Console.WriteLine(" \x1b[93m{0}\x1b[97m test succeeded, \x1b[93m{1}\x1b[97m tests failed", succeededTestCount, failedTestCount); - Console.ForegroundColor = ConsoleColor.Gray; - Console.WriteLine(); - Console.WriteLine("---------------------------------------------------------------------------------"); Console.WriteLine(); + Console.WriteLine("\x1b[37m---------------------------------------------------------------------------------"); + Console.WriteLine("\x1b[0m"); return failedTestCount; } @@ -59,16 +56,13 @@ private static void TryDeserialize(string testName, string yaml) private static void PerformTest(string testName, Action act) { - Console.ForegroundColor = ConsoleColor.Gray; - Console.Write(" "); + Console.Write("\x1b[37m "); Console.Write(testName.PadRight(70)); try { act(); - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine("[success]"); - Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine("\x1b[92m[success]\x1b[37m"); ++succeededTestCount; } catch (Exception ex) @@ -80,19 +74,17 @@ private static void PerformTest(string testName, Action act) if (current is ExecutionEngineException) #pragma warning restore CS0618 // Type or member is obsolete { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("[failure]"); - Console.ForegroundColor = ConsoleColor.Yellow; - Console.Write(" "); + Console.WriteLine("\x1b[91m[failure]"); + Console.Write("\x1b[93m "); Console.WriteLine(current.Message); - Console.ForegroundColor = ConsoleColor.Gray; + Console.Write("\x1b[37m"); ++failedTestCount; return; } current = current.InnerException; } - Console.ForegroundColor = ConsoleColor.Red; + Console.Write("\x1b[91m"); throw; } } diff --git a/YamlDotNet.AotTest/run.sh b/YamlDotNet.AotTest/run.sh index db5199a58..e5aed9622 100755 --- a/YamlDotNet.AotTest/run.sh +++ b/YamlDotNet.AotTest/run.sh @@ -1,19 +1,7 @@ #!/bin/sh -apt-get update -apt-get install --no-install-recommends -y mono-runtime - -mono --aot=full /usr/lib/mono/4.5/mscorlib.dll -mono --aot=full /usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll -mono --aot=full /usr/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll -mono --aot=full /usr/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll -mono --aot=full /usr/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll -mono --aot=full /usr/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll -mono --aot=full /usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll -mono --aot=full /usr/lib/mono/gac/System.Numerics/4.0.0.0__b77a5c561934e089/System.Numerics.dll - -mono --aot=full YamlDotNet.AotTest/bin/Release/net45/YamlDotNet.dll -mono --aot=full YamlDotNet.AotTest/bin/Release/net45/YamlDotNet.AotTest.exe - -mono --full-aot YamlDotNet.AotTest/bin/Release/net45/YamlDotNet.AotTest.exe +mono --aot=full ./bin/Release/net45/YamlDotNet.dll && \ + mono --aot=full ./bin/Release/net45/YamlDotNet.AotTest.exe && \ + mono --full-aot ./bin/Release/net45/YamlDotNet.AotTest.exe +echo $? > exitcode.txt diff --git a/tools/aot/Dockerfile b/tools/aot/Dockerfile new file mode 100644 index 000000000..d673aa7df --- /dev/null +++ b/tools/aot/Dockerfile @@ -0,0 +1,10 @@ +FROM mono:6.12-slim + +RUN mono --aot=full /usr/lib/mono/4.5/mscorlib.dll && \ + mono --aot=full /usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll && \ + mono --aot=full /usr/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll && \ + mono --aot=full /usr/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll && \ + mono --aot=full /usr/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll && \ + mono --aot=full /usr/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll && \ + mono --aot=full /usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll && \ + mono --aot=full /usr/lib/mono/gac/System.Numerics/4.0.0.0__b77a5c561934e089/System.Numerics.dll diff --git a/tools/aot/build.ps1 b/tools/aot/build.ps1 new file mode 100644 index 000000000..5e577bae4 --- /dev/null +++ b/tools/aot/build.ps1 @@ -0,0 +1,2 @@ + +docker build . -t "aaubry/mono-aot" diff --git a/tools/build/BuildDefinition.cs b/tools/build/BuildDefinition.cs index 1939c0300..aa2971337 100644 --- a/tools/build/BuildDefinition.cs +++ b/tools/build/BuildDefinition.cs @@ -1,4 +1,5 @@ using Bullseye; +using SimpleExec; using System; using System.Collections.Generic; using System.Globalization; @@ -105,9 +106,23 @@ public static SuccessfulUnitTests UnitTest(Options options, SuccessfulBuild _) return default; } - public static SuccessfulAotTests AotTest(SuccessfulBuild _) + public static SuccessfulAotTests AotTest(Options options, SuccessfulBuild _) { - Run("wsl", $"--user root YamlDotNet.AotTest/run.sh", BasePath); + var testsDir = Path.Combine(BasePath, "YamlDotNet.AotTest"); + + try + { + Run("docker", $"run --rm -v {testsDir}:/build -w /build aaubry/mono-aot bash ./run.sh"); + } + catch (NonZeroExitCodeException ex) when (options.Host == Host.Appveyor && ex.ExitCode == -1) + { + // Appveyor fails with exit code -1 for some reason... + var realExitCode = int.Parse(File.ReadAllLines(Path.Combine(testsDir, "exitcode.txt")).First(), CultureInfo.InvariantCulture); + if (realExitCode != 0) + { + throw new NonZeroExitCodeException(realExitCode); + } + } return default; }