1
// Permission is hereby granted, free of charge, to any person obtaining
2
// a copy of this software and associated documentation files (the
3
// "Software"), to deal in the Software without restriction, including
4
// without limitation the rights to use, copy, modify, merge, publish,
5
// distribute, sublicense, and/or sell copies of the Software, and to
6
// permit persons to whom the Software is furnished to do so, subject to
7
// the following conditions:
9
// The above copyright notice and this permission notice shall be
10
// included in all copies or substantial portions of the Software.
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
// Copyright (c) 2007-2008 Novell, Inc.
23
// Jackson Harper (jackson@ximian.com)
28
using System.Collections;
30
namespace MoonlightTests {
32
public class ConsoleReport : IReport {
36
public void BeginRun (TestRun run)
40
Console.WriteLine ("Running tests...");
43
public void Executing (Test test)
50
Console.WriteLine ("\n");
52
ReportIgnoredTests ();
60
public void AddResult (Test test, TestResult result)
62
string state = string.Empty;
67
color = ConsoleColor.Green;
68
state = run.VerboseLevel != VerboseLevel.None ? "P" : ".";
70
case TestResult.Ignore:
71
color = ConsoleColor.White;
75
color = ConsoleColor.Red;
78
case TestResult.KnownFailure:
79
color = ConsoleColor.Blue;
82
case TestResult.UnexpectedPass:
83
color = ConsoleColor.Cyan;
87
color = ConsoleColor.Green;
92
if (!run.Runner.Driver.UseGdb)
93
Console.ForegroundColor = color;
95
if (run.VerboseLevel != VerboseLevel.None)
96
Console.Write ("{0} ({1}): ", test.InputFile, test.Id);
97
Console.Write (state);
98
if (run.VerboseLevel != VerboseLevel.None)
101
if (!run.Runner.Driver.UseGdb)
102
Console.ResetColor ();
106
private void ReportAllTests ()
108
Console.WriteLine ("========================= Test Summary =========================");
109
foreach (Test t in run.Tests)
110
AddResult (t, t.Result);
111
Console.WriteLine ("Tests run: {0} {1} Pass, {2} Ignored, {3} Failures, {4} Known Failures",
112
run.ExecutedTests.Count, run.PassedTests.Count, run.IgnoredTests.Count, run.FailedTests.Count, run.KnownFailures.Count);
113
Console.WriteLine ("");
116
private void ReportIgnoredTests ()
118
if (run.IgnoredTests.Count < 1)
121
Console.WriteLine ("========================= Ignored Tests =========================");
122
foreach (Test t in run.IgnoredTests) {
123
Console.WriteLine ("Ignored: {0} -- {1}", t.InputFile, t.IgnoreReason);
126
Console.WriteLine ("\n");
129
private void ReportFailedTests ()
131
if (run.FailedTests.Count < 1)
134
Console.WriteLine ("========================= Failed Tests ==========================");
135
foreach (Test t in run.FailedTests) {
136
Console.WriteLine ("Failed: {0} ({2}) -- {1}", t.InputFile, t.FailedReason, t.Id);
137
if (run.VerboseLevel >= VerboseLevel.ShowShockerLines) {
138
Console.WriteLine (" Log Lines:");
139
foreach (string str in run.LoggingServer.GetTestLogLines (t.InputFileName)) {
140
Console.WriteLine (" {0}", str);
144
if (run.VerboseLevel >= VerboseLevel.ShowStderr) {
145
Console.WriteLine (" Stderr:");
146
foreach (string str in t.Stderr.Split (Environment.NewLine [0])) {
147
Console.WriteLine (" {0}", str);
150
if (run.VerboseLevel >= VerboseLevel.ShowStdout) {
151
Console.WriteLine (" Stdout:");
152
foreach (string str in t.Stdout.Split (Environment.NewLine [0])) {
153
Console.WriteLine (" {0}", str);
159
Console.WriteLine ("\n");
162
private void ReportPassedTests ()
164
// TODO: This should only happen when we run-known-failures-only
167
private void ReportSummary ()
169
Console.WriteLine ("Tests run: {0} {1} Pass, {2} Ignored, {3} Failures, {4} Known Failures",
170
run.ExecutedTests.Count, run.PassedTests.Count, run.IgnoredTests.Count, run.FailedTests.Count, run.KnownFailures.Count);