Skip to content

Commit

Permalink
Merge pull request #1333 from Aaronontheweb/1314-teamcity-mn-visualiz…
Browse files Browse the repository at this point in the history
…er-output

Resolves #1314. Add unit test output as TeamCity artifacts.
  • Loading branch information
annymsMthd committed Sep 26, 2015
2 parents b0bfd57 + 9ad5854 commit 43291fa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,6 @@ resetdev.bat

# FAKE build folder
.fake/

# Akka.Persistence Test Output
target/
10 changes: 6 additions & 4 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ printfn "Assembly version: %s\nNuget version; %s\n" release.AssemblyVersion rele
// Directories

let binDir = "bin"
let testOutput = "TestResults"
let testOutput = FullName "TestResults"

let nugetDir = binDir @@ "nuget"
let workingDir = binDir @@ "build"
Expand Down Expand Up @@ -213,7 +213,7 @@ Target "CleanTests" <| fun _ ->
//--------------------------------------------------------------------------------
// Run tests

open XUnit2Helper
open Fake.Testing
Target "RunTests" <| fun _ ->
let msTestAssemblies = !! "src/**/bin/Release/Akka.TestKit.VsTest.Tests.dll"
let nunitTestAssemblies = !! "src/**/bin/Release/Akka.TestKit.NUnit.Tests.dll"
Expand All @@ -233,7 +233,7 @@ Target "RunTests" <| fun _ ->
let xunitToolPath = findToolInSubPath "xunit.console.exe" "src/packages/xunit.runner.console*/tools"
printfn "Using XUnit runner: %s" xunitToolPath
xUnit2
(fun p -> { p with OutputDir = testOutput; ToolPath = xunitToolPath })
(fun p -> { p with XmlOutputPath = Some (testOutput + @"\XUnitTestResults.xml"); HtmlOutputPath = Some (testOutput + @"\XUnitTestResults.HTML"); ToolPath = xunitToolPath; TimeOut = System.TimeSpan.FromMinutes 30.0; Parallel = ParallelMode.NoParallelization })
xunitTestAssemblies

Target "RunTestsMono" <| fun _ ->
Expand All @@ -244,14 +244,15 @@ Target "RunTestsMono" <| fun _ ->
let xunitToolPath = findToolInSubPath "xunit.console.exe" "src/packages/xunit.runner.console*/tools"
printfn "Using XUnit runner: %s" xunitToolPath
xUnit2
(fun p -> { p with OutputDir = testOutput; ToolPath = xunitToolPath })
(fun p -> { p with XmlOutputPath = Some (testOutput + @"\XUnitTestResults.xml"); HtmlOutputPath = Some (testOutput + @"\XUnitTestResults.HTML"); ToolPath = xunitToolPath; TimeOut = System.TimeSpan.FromMinutes 30.0; Parallel = ParallelMode.NoParallelization })
xunitTestAssemblies

Target "MultiNodeTests" <| fun _ ->
let testSearchPath =
let assemblyFilter = getBuildParamOrDefault "spec-assembly" String.Empty
sprintf "src/**/bin/Release/*%s*.Tests.MultiNode.dll" assemblyFilter

mkdir testOutput
let multiNodeTestPath = findToolInSubPath "Akka.MultiNodeTestRunner.exe" "bin/core/Akka.MultiNodeTestRunner*"
let multiNodeTestAssemblies = !! testSearchPath
printfn "Using MultiNodeTestRunner: %s" multiNodeTestPath
Expand All @@ -262,6 +263,7 @@ Target "MultiNodeTests" <| fun _ ->
let args = new StringBuilder()
|> append assembly
|> append "-Dmultinode.enable-filesink=on"
|> append (sprintf "-Dmultinode.output-directory=\"%s\"" testOutput)
|> appendIfNotNullOrEmpty spec "-Dmultinode.test-spec="
|> toText

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// -----------------------------------------------------------------------

using System;
using System.IO;

namespace Akka.MultiNodeTestRunner.Shared.Persistence
{
Expand All @@ -19,5 +20,13 @@ public static string GenerateFileName(string assemblyName, string fileExtension,
{
return string.Format("{0}-{1}{2}", assemblyName.Replace(".dll", ""), utcNow.Ticks, fileExtension);
}

public static string GenerateFileName(string folderPath, string assemblyName, string fileExtension, DateTime utcNow)
{
if(string.IsNullOrEmpty(folderPath))
return GenerateFileName(assemblyName, fileExtension, utcNow);
var assemblyNameOnly = Path.GetFileName(assemblyName);
return Path.Combine(folderPath, GenerateFileName(assemblyNameOnly, fileExtension, utcNow));
}
}
}
23 changes: 17 additions & 6 deletions src/core/Akka.MultiNodeTestRunner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class Program

protected static IActorRef SinkCoordinator;



/// <summary>
/// MultiNodeTestRunner takes the following <see cref="args"/>:
///
/// C:\> Akka.MultiNodeTestRunner.exe [assembly name] [-Dmultinode.enable-filesink=on]
/// C:\> Akka.MultiNodeTestRunner.exe [assembly name] [-Dmultinode.enable-filesink=on] [-Dmultinode.output-directory={dir path}]
///
/// <list type="number">
/// <listheader>
Expand All @@ -57,6 +57,13 @@ class Program
/// current working directory as a .JSON file.
/// </description>
/// </item>
/// <item>
/// <term>-Dmultinode.multinode.output-directory</term>
/// <description>Setting this flag means that any persistent multi-node test runner output files
/// will be written to this directory instead of the default, which is the same folder
/// as the test binary.
/// </description>
/// </item>
/// </list>
/// </summary>
static void Main(string[] args)
Expand Down Expand Up @@ -156,19 +163,23 @@ static void EnableAllSinks(string assemblyName)
{
var now = DateTime.UtcNow;

// if multinode.output-directory wasn't specified, the results files will be written
// to the same directory as the test assembly.
var outputDirectory = CommandLine.GetProperty("multinode.output-directory");

Func<MessageSink> createJsonFileSink = () =>
{
var fileName = FileNameGenerator.GenerateFileName(assemblyName, ".json", now);
var fileName = FileNameGenerator.GenerateFileName(outputDirectory, assemblyName, ".json", now);
var visualizerProps = Props.Create(() =>
var jsonStoreProps = Props.Create(() =>
new FileSystemMessageSinkActor(new JsonPersistentTestRunStore(), fileName, true));
return new FileSystemMessageSink(visualizerProps);
return new FileSystemMessageSink(jsonStoreProps);
};

Func<MessageSink> createVisualizerFileSink = () =>
{
var fileName = FileNameGenerator.GenerateFileName(assemblyName, ".html", now);
var fileName = FileNameGenerator.GenerateFileName(outputDirectory, assemblyName, ".html", now);
var visualizerProps = Props.Create(() =>
new FileSystemMessageSinkActor(new VisualizerPersistentTestRunStore(), fileName, true));
Expand Down

0 comments on commit 43291fa

Please sign in to comment.