Skip to content

Commit

Permalink
Merge branch 'master' into quickinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred authored Jul 25, 2020
2 parents 4682884 + aff7540 commit f51549f
Showing 1 changed file with 41 additions and 13 deletions.
54 changes: 41 additions & 13 deletions src/OmniSharp.DotNetTest/VSTestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ public override async Task<GetTestStartInfoResponse> GetTestStartInfoAsync(strin
RunSettings = LoadRunSettingsOrDefault(runSettings, targetFrameworkVersion)
});

var message = ReadMessage();
var testStartInfo = message.DeserializePayload<TestProcessStartInfo>();
var testStartInfo = await GetTestRunnerProcessStartInfo(testCases, debuggingEnabled: false, runSettings, targetFrameworkVersion, cancellationToken);

return new GetTestStartInfoResponse
{
Expand All @@ -176,26 +175,55 @@ public override async Task<DebugTestGetStartInfoResponse> DebugGetStartInfoAsync
VerifyTestFramework(testFrameworkName);

var testCases = await DiscoverTestsAsync(methodNames, runSettings, targetFrameworkVersion, cancellationToken);
var testStartInfo = await GetTestRunnerProcessStartInfo(testCases, debuggingEnabled: true, runSettings, targetFrameworkVersion, cancellationToken);

return new DebugTestGetStartInfoResponse
{
FileName = testStartInfo.FileName,
Arguments = testStartInfo.Arguments,
WorkingDirectory = testStartInfo.WorkingDirectory,
EnvironmentVariables = testStartInfo.EnvironmentVariables,
Succeeded = true
};
}

private async Task<TestProcessStartInfo> GetTestRunnerProcessStartInfo(TestCase[] testCases, bool debuggingEnabled, string runSettings, string targetFrameworkVersion, CancellationToken cancellationToken)
{
SendMessage(MessageType.GetTestRunnerProcessStartInfoForRunSelected,
new
{
TestCases = testCases,
DebuggingEnabled = true,
RunSettings = LoadRunSettingsOrDefault(runSettings, targetFrameworkVersion)
});

var message = await ReadMessageAsync(cancellationToken);
var startInfo = message.DeserializePayload<TestProcessStartInfo>();

return new DebugTestGetStartInfoResponse
bool done = false;
TestProcessStartInfo startInfo = null;
while (!done)
{
FileName = startInfo.FileName,
Arguments = startInfo.Arguments,
WorkingDirectory = startInfo.WorkingDirectory,
EnvironmentVariables = startInfo.EnvironmentVariables,
Succeeded = true
};
var (success, message) = await TryReadMessageAsync(cancellationToken);
if (!success)
{
return startInfo;
}

switch (message.MessageType)
{
case MessageType.TestMessage:
EmitTestMessage(message.DeserializePayload<TestMessagePayload>());
break;

case MessageType.CustomTestHostLaunch:
startInfo = message.DeserializePayload<TestProcessStartInfo>();
done = true;
break;

case MessageType.ExecutionComplete:
done = true;
break;
}
}

return startInfo;
}

public override async Task DebugLaunchAsync(CancellationToken cancellationToken)
Expand Down

0 comments on commit f51549f

Please sign in to comment.