From c4aae602e83947f50a6b692033aadf33b2c018b6 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 21 Jul 2017 18:07:12 +0300 Subject: [PATCH 1/3] Updated dotmemory --- appveyor.yml | 2 +- build.cake | 48 +++++++++++++++---- .../toolproject/tool.csproj | 9 ++++ 3 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 tests/Avalonia.LeakTests/toolproject/tool.csproj diff --git a/appveyor.yml b/appveyor.yml index 529cbbb65f..038028f839 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,7 +27,7 @@ before_build: build_script: - ps: .\build.ps1 -Target "AppVeyor" -Platform "$env:platform" -Configuration "$env:configuration" after_build: -- tools\JetBrains.dotMemoryUnit\tools\dotMemoryUnit.exe -targetExecutable="%xunit20%\xunit.console.x86.exe" -returnTargetExitCode --"tests\Avalonia.LeakTests\bin\Release\Avalonia.LeakTests.dll" +- tests\Avalonia.LeakTests\bin\Release\dotMemoryUnit.exe -targetExecutable="%xunit20%\xunit.console.x86.exe" -returnTargetExitCode --"tests\Avalonia.LeakTests\bin\Release\Avalonia.LeakTests.dll" - "SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%" - pip install codecov - codecov -f "./artifacts/coverage.xml" diff --git a/build.cake b/build.cake index b3822271d4..81390436fd 100644 --- a/build.cake +++ b/build.cake @@ -4,8 +4,8 @@ #addin "nuget:?package=Polly&version=4.2.0" #addin "nuget:?package=NuGet.Core&version=2.12.0" +#tool "nuget:?package=xunit.runner.console&version=2.2.0" #tool "nuget:https://dotnet.myget.org/F/nuget-build/?package=NuGet.CommandLine&version=4.3.0-preview1-3980&prerelease" -#tool "nuget:?package=JetBrains.dotMemoryUnit&version=2.3.20160517.113140" #tool "JetBrains.ReSharper.CommandLineTools" /////////////////////////////////////////////////////////////////////////////// // TOOLS @@ -194,6 +194,7 @@ Task("Run-Net-Core-Unit-Tests") Task("Run-Unit-Tests") .IsDependentOn("Run-Net-Core-Unit-Tests") .IsDependentOn("Build") + .IsDependentOn("Run-Leak-Tests") .WithCriteria(() => !parameters.SkipTests) .Does(() => { @@ -206,13 +207,6 @@ Task("Run-Unit-Tests") .Select(name => MakeAbsolute(File("./tests/" + name + "/bin/" + parameters.DirSuffix + "/" + name + ".dll"))) .ToList(); - if (parameters.IsRunningOnWindows) - { - var leakTests = GetFiles("./tests/Avalonia.LeakTests/bin/" + parameters.DirSuffix + "/*.LeakTests.dll"); - - unitTests.AddRange(leakTests); - } - var toolPath = (parameters.IsPlatformAnyCPU || parameters.IsPlatformX86) ? "./tools/xunit.runner.console/tools/xunit.console.x86.exe" : "./tools/xunit.runner.console/tools/xunit.console.exe"; @@ -365,6 +359,44 @@ Task("Publish-NuGet") Information("Publish-NuGet Task failed, but continuing with next Task..."); }); +Task("Run-Leak-Tests") + .WithCriteria(parameters.IsRunningOnWindows) + .IsDependentOn("Build") + .Does(() => + { + DotNetCoreRestore("tests\\Avalonia.LeakTests\\toolproject\\tool.csproj"); + DotNetBuild("tests\\Avalonia.LeakTests\\toolproject\\tool.csproj", settings => settings.SetConfiguration("Release")); + var report = "tests\\Avalonia.LeakTests\\bin\\Release\\report.xml"; + if(System.IO.File.Exists(report)) + System.IO.File.Delete(report); + var proc = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo + { + FileName="tests\\Avalonia.LeakTests\\toolproject\\bin\\Release\\net461\\dotMemoryUnit.exe", + Arguments="-targetExecutable=\"tools\\xunit.runner.console\\tools\\xunit.console.x86.exe\" -returnTargetExitCode -- tests\\Avalonia.LeakTests\\bin\\Release\\Avalonia.LeakTests.dll -xml tests\\Avalonia.LeakTests\\bin\\Release\\report.xml ", + UseShellExecute = false, + }); + var st = System.Diagnostics.Stopwatch.StartNew(); + while(!proc.HasExited && !System.IO.File.Exists(report)) + { + if(st.Elapsed.TotalSeconds>60) + { + Error("Timed out, probably a bug in dotMemoryUnit"); + proc.Kill(); + throw new Exception("dotMemory issue"); + } + proc.WaitForExit(100); + } + try{ + proc.Kill(); + }catch{} + var doc = System.Xml.Linq.XDocument.Load(report); + if(doc.Root.Descendants("assembly").Any(x=>x.Attribute("failed").Value.ToString() != "0")) + { + throw new Exception("Tests failed"); + } + + }); + Task("Inspect") .WithCriteria(parameters.IsRunningOnWindows) .IsDependentOn("Restore-NuGet-Packages") diff --git a/tests/Avalonia.LeakTests/toolproject/tool.csproj b/tests/Avalonia.LeakTests/toolproject/tool.csproj new file mode 100644 index 0000000000..c9f584be72 --- /dev/null +++ b/tests/Avalonia.LeakTests/toolproject/tool.csproj @@ -0,0 +1,9 @@ + + + net461 + Library + + + + + \ No newline at end of file From 1da031881c1cd6eb65e0e6d7590fe15de60f643c Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 21 Jul 2017 18:39:04 +0300 Subject: [PATCH 2/3] I'm starting to *really* hate the new SDK --- build.cake | 2 +- tests/Avalonia.LeakTests/toolproject/tool.csproj | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 81390436fd..12a9d85d05 100644 --- a/build.cake +++ b/build.cake @@ -371,7 +371,7 @@ Task("Run-Leak-Tests") System.IO.File.Delete(report); var proc = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo { - FileName="tests\\Avalonia.LeakTests\\toolproject\\bin\\Release\\net461\\dotMemoryUnit.exe", + FileName="tests\\Avalonia.LeakTests\\toolproject\\bin\\dotMemoryUnit.exe", Arguments="-targetExecutable=\"tools\\xunit.runner.console\\tools\\xunit.console.x86.exe\" -returnTargetExitCode -- tests\\Avalonia.LeakTests\\bin\\Release\\Avalonia.LeakTests.dll -xml tests\\Avalonia.LeakTests\\bin\\Release\\report.xml ", UseShellExecute = false, }); diff --git a/tests/Avalonia.LeakTests/toolproject/tool.csproj b/tests/Avalonia.LeakTests/toolproject/tool.csproj index c9f584be72..54dbe6f17e 100644 --- a/tests/Avalonia.LeakTests/toolproject/tool.csproj +++ b/tests/Avalonia.LeakTests/toolproject/tool.csproj @@ -1,5 +1,7 @@  + $(MSBuildThisFileDirectory)\bin + $(OutputPath) net461 Library From 36310f1b6a0a777fa97521386799c5929d0cd6c4 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 21 Jul 2017 19:04:12 +0300 Subject: [PATCH 3/3] dotMemory tests are now run with cake --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 038028f839..cc0063dac5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,7 +27,6 @@ before_build: build_script: - ps: .\build.ps1 -Target "AppVeyor" -Platform "$env:platform" -Configuration "$env:configuration" after_build: -- tests\Avalonia.LeakTests\bin\Release\dotMemoryUnit.exe -targetExecutable="%xunit20%\xunit.console.x86.exe" -returnTargetExitCode --"tests\Avalonia.LeakTests\bin\Release\Avalonia.LeakTests.dll" - "SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%" - pip install codecov - codecov -f "./artifacts/coverage.xml"