Skip to content
This repository was archived by the owner on Aug 23, 2019. It is now read-only.

Commit 8a3a770

Browse files
committed
Merge pull request #11 from will14smith/feature/teamcitytiming
Fix TeamCity timing
1 parent 6269119 commit 8a3a770

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Machine.Specifications.ConsoleRunner.Specs/ProgramSpecs.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,25 @@ public class when_running_two_spec_assemblies : ConsoleRunnerSpecs
267267
console.Lines.Count(x => x.StartsWith("Contexts: ")).Should().Be(1);
268268
}
269269

270+
[Subject("Console runner")]
271+
public class when_running_on_teamcity : ConsoleRunnerSpecs
272+
{
273+
Because of = () =>
274+
program.Run(new[] { GetPath(@"Example.dll"), "--teamcity" });
275+
276+
It should_output_valid_durations = () =>
277+
console.Lines.Count(x => ExtractDuration(x) >= 0).Should().Be(6);
278+
It should_not_output_invalid_durations = () =>
279+
console.Lines.Count(x => x.Contains("duration='-1'")).Should().Be(0);
280+
281+
private static long? ExtractDuration(string message)
282+
{
283+
var match = Regex.Match(message, "duration='(\\d+)'");
284+
if (!match.Success) return null;
285+
return long.Parse(match.Groups[1].Value);
286+
}
287+
}
288+
270289
public class ConsoleRunnerSpecs
271290
{
272291
const string TeamCityIndicator = "TEAMCITY_PROJECT_NAME";

Machine.Specifications.ConsoleRunner/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public ExitCode Run(string[] arguments)
102102
}
103103
}
104104

105-
listeners.Add(mainListener);
105+
listeners.Insert(0, mainListener);
106106

107107
if (options.AssemblyFiles.Count == 0)
108108
{

0 commit comments

Comments
 (0)