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

Fix issue #66 - Test discovery may fail if the test display name is longer than 447 characters. #70

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class VsDiscoveryVisitor : TestMessageVisitor<IDiscoveryCompleteMessage>,
{
static readonly Action<TestCase, string, string> addTraitThunk = GetAddTraitThunk();
static readonly Uri uri = new Uri(Constants.ExecutorUri);
const string Ellipsis = "...";
const int MaximumDisplayNameLength = 447;

readonly Func<bool> cancelThunk;
readonly ITestFrameworkDiscoverer discoverer;
Expand Down Expand Up @@ -85,9 +87,16 @@ static string Escape(string value)
if (value == null)
return String.Empty;

return value.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t");
return Truncate(value.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t"));
}

static string Truncate(string value)
{
if (value.Length <= MaximumDisplayNameLength)
return value;
return value.Substring(0, MaximumDisplayNameLength - Ellipsis.Length) + Ellipsis;
}

public int Finish()
{
Finished.WaitOne();
Expand Down