Fixes #12: Console runner should return failure error code when assembly does not load.

This commit is contained in:
Brad Wilson 2014-03-22 12:00:06 -07:00
Родитель 0ca932b0a6
Коммит e4045a9854
1 изменённых файлов: 4 добавлений и 14 удалений

Просмотреть файл

@ -13,6 +13,7 @@ namespace Xunit.ConsoleClient
public class Program
{
volatile static bool cancel;
static bool failed;
static readonly ConcurrentDictionary<string, ExecutionSummary> completionMessages = new ConcurrentDictionary<string, ExecutionSummary>();
[STAThread]
@ -61,13 +62,11 @@ namespace Xunit.ConsoleClient
}
catch (ArgumentException ex)
{
Console.WriteLine();
Console.WriteLine("error: {0}", ex.Message);
return 1;
}
catch (BadImageFormatException ex)
{
Console.WriteLine();
Console.WriteLine("{0}", ex.Message);
return 1;
}
@ -164,7 +163,7 @@ namespace Xunit.ConsoleClient
xmlTransformers.ForEach(transformer => transformer(assembliesElement));
return completionMessages.Values.Sum(summary => summary.Failed);
return failed ? 1 : completionMessages.Values.Sum(summary => summary.Failed);
}
static XmlTestExecutionVisitor CreateVisitor(object consoleLock, string defaultDirectory, XElement assemblyElement, bool teamCity, bool silent)
@ -200,17 +199,8 @@ namespace Xunit.ConsoleClient
}
catch (Exception ex)
{
var e = ex;
while (e != null)
{
Console.WriteLine("{0}: {1}", e.GetType().FullName, e.Message);
foreach (string stackLine in e.StackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
Console.WriteLine(stackLine);
e = e.InnerException;
}
Console.WriteLine("{0}: {1}", ex.GetType().FullName, ex.Message);
failed = true;
}
return assemblyElement;