Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaned up the SpecPass / SpecFail messages #4912

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/core/Akka.MultiNodeTestRunner.Shared/Sinks/Spec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,12 @@ public SpecFail(int nodeIndex, string nodeRole, string testDisplayName) : base(n
FailureMessages = new List<string>();
FailureStackTraces = new List<string>();
FailureExceptionTypes = new List<string>();
Timestamp = DateTime.UtcNow;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was hiding the Timestamp property I later added to SpecPass, which is the base class of SpecFail - I added them the other way around the first time, so I wanted to clean that up here.

}

public IList<string> FailureMessages { get; private set; }
public IList<string> FailureStackTraces { get; private set; }
public IList<string> FailureExceptionTypes { get; private set; }

public DateTime Timestamp { get; }

public override string ToString()
{
var sb = new StringBuilder();
Expand Down
72 changes: 36 additions & 36 deletions src/core/Akka.NodeTestRunner/Sink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,47 @@ public Sink(int nodeIndex, string nodeRole, IActorRef logger)

public bool OnMessage(IMessageSinkMessage message)
{
var resultMessage = message as ITestResultMessage;
if (resultMessage != null)
if (message is ITestResultMessage resultMessage)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resharper'd all of this code to take advantage of newer C# language features

{
_logger.Tell(resultMessage.Output);
Console.WriteLine(resultMessage.Output);
}
var testPassed = message as ITestPassed;
if (testPassed != null)
{
//the MultiNodeTestRunner uses 1-based indexing, which is why we have to add 1 to the index.
var specPass = new SpecPass(_nodeIndex + 1, _nodeRole, testPassed.TestCase.DisplayName);
_logger.Tell(specPass.ToString());
Console.WriteLine(specPass.ToString()); //so the message also shows up in the individual per-node build log
Passed = true;
return true;
}
var testFailed = message as ITestFailed;
if (testFailed != null)
{
//the MultiNodeTestRunner uses 1-based indexing, which is why we have to add 1 to the index.
var specFail = new SpecFail(_nodeIndex + 1, _nodeRole, testFailed.TestCase.DisplayName);
foreach (var failedMessage in testFailed.Messages) specFail.FailureMessages.Add(failedMessage);
foreach (var stackTrace in testFailed.StackTraces) specFail.FailureStackTraces.Add(stackTrace);
foreach(var exceptionType in testFailed.ExceptionTypes) specFail.FailureExceptionTypes.Add(exceptionType);
_logger.Tell(specFail.ToString());
Console.WriteLine(specFail.ToString());
return true;
}
var errorMessage = message as ErrorMessage;
if (errorMessage != null)
{
var specFail = new SpecFail(_nodeIndex + 1, _nodeRole, "ERRORED");
foreach (var failedMessage in errorMessage.Messages) specFail.FailureMessages.Add(failedMessage);
foreach (var stackTrace in errorMessage.StackTraces) specFail.FailureStackTraces.Add(stackTrace);
foreach (var exceptionType in errorMessage.ExceptionTypes) specFail.FailureExceptionTypes.Add(exceptionType);
_logger.Tell(specFail.ToString());
Console.WriteLine(specFail.ToString());
}
if (message is ITestAssemblyFinished)

switch (message)
{
Finished.Set();
case ITestPassed testPassed:
{
//the MultiNodeTestRunner uses 1-based indexing, which is why we have to add 1 to the index.
var specPass = new SpecPass(_nodeIndex + 1, _nodeRole, testPassed.TestCase.DisplayName);
_logger.Tell(specPass.ToString());
Console.WriteLine(specPass.ToString()); //so the message also shows up in the individual per-node build log
Passed = true;
return true;
}
case ITestFailed testFailed:
{
//the MultiNodeTestRunner uses 1-based indexing, which is why we have to add 1 to the index.
var specFail = new SpecFail(_nodeIndex + 1, _nodeRole, testFailed.TestCase.DisplayName);
foreach (var failedMessage in testFailed.Messages) specFail.FailureMessages.Add(failedMessage);
foreach (var stackTrace in testFailed.StackTraces) specFail.FailureStackTraces.Add(stackTrace);
foreach(var exceptionType in testFailed.ExceptionTypes) specFail.FailureExceptionTypes.Add(exceptionType);
_logger.Tell(specFail.ToString());
Console.WriteLine(specFail.ToString());
return true;
}
case ErrorMessage errorMessage:
{
var specFail = new SpecFail(_nodeIndex + 1, _nodeRole, "ERRORED");
foreach (var failedMessage in errorMessage.Messages) specFail.FailureMessages.Add(failedMessage);
foreach (var stackTrace in errorMessage.StackTraces) specFail.FailureStackTraces.Add(stackTrace);
foreach (var exceptionType in errorMessage.ExceptionTypes) specFail.FailureExceptionTypes.Add(exceptionType);
_logger.Tell(specFail.ToString());
Console.WriteLine(specFail.ToString());
break;
}
case ITestAssemblyFinished _:
Finished.Set();
break;
}

return true;
Expand Down