Skip to content

Commit 649aaa5

Browse files
authored
Delete dead code in ServerModeTestsBase (#6854)
1 parent dacc39f commit 649aaa5

File tree

1 file changed

+0
-82
lines changed

1 file changed

+0
-82
lines changed

test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/ServerMode/ServerModeTestsBase.cs

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -69,86 +69,4 @@ protected async Task<TestingPlatformClient> StartAsServerAndConnectToTheClientAs
6969

7070
return new TestingPlatformClient(new(tcpClient.GetStream()), tcpClient, processHandler);
7171
}
72-
73-
protected async Task<TestingPlatformClient> StartAsServerAndConnectAsync(TestHost testHost, bool enableDiagnostic = false)
74-
{
75-
var environmentVariables = new Dictionary<string, string?>(DefaultEnvironmentVariables);
76-
foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables())
77-
{
78-
// Skip all unwanted environment variables.
79-
string? key = entry.Key.ToString();
80-
if (WellKnownEnvironmentVariables.ToSkipEnvironmentVariables.Contains(key, StringComparer.OrdinalIgnoreCase))
81-
{
82-
continue;
83-
}
84-
85-
environmentVariables[key!] = entry.Value!.ToString()!;
86-
}
87-
88-
// We expect to not fail for unhandled exception in server mode for IDE needs.
89-
environmentVariables.Add("TESTINGPLATFORM_EXIT_PROCESS_ON_UNHANDLED_EXCEPTION", "0");
90-
91-
// To attach to the server on startup
92-
// environmentVariables.Add(EnvironmentVariableConstants.TESTINGPLATFORM_LAUNCH_ATTACH_DEBUGGER, "1");
93-
TaskCompletionSource<int> portFound = new();
94-
ProcessConfiguration processConfig = new(testHost.FullName)
95-
{
96-
OnStandardOutput =
97-
(_, output) =>
98-
{
99-
Match m = ParsePort().Match(output);
100-
if (m.Success && int.TryParse(m.Groups[1].Value, out int port))
101-
{
102-
portFound.SetResult(port);
103-
}
104-
105-
// Do not remove pls
106-
// NotepadWindow.WriteLine($"[OnStandardOutput] {output}");
107-
},
108-
109-
// Do not remove pls
110-
// OnErrorOutput = (_, output) => NotepadWindow.WriteLine($"[OnErrorOutput] {output}"),
111-
OnErrorOutput = (_, output) =>
112-
{
113-
if (!portFound.Task.IsCompleted)
114-
{
115-
try
116-
{
117-
portFound.SetException(new InvalidOperationException(output));
118-
}
119-
catch (InvalidOperationException)
120-
{
121-
// possible race
122-
}
123-
}
124-
},
125-
OnExit = (processHandle, exitCode) =>
126-
{
127-
if (exitCode != 0)
128-
{
129-
if (portFound.Task.Exception is null && !portFound.Task.IsCompleted)
130-
{
131-
portFound.SetException(new InvalidOperationException($"Port not found during parsing and process exited with code '{exitCode}'"));
132-
}
133-
}
134-
},
135-
136-
// OnExit = (_, exitCode) => NotepadWindow.WriteLine($"[OnExit] Process exit code '{exitCode}'"),
137-
Arguments = "--server --diagnostic --diagnostic-verbosity trace",
138-
EnvironmentVariables = environmentVariables,
139-
};
140-
141-
IProcessHandle processHandler = ProcessFactory.Start(processConfig, cleanDefaultEnvironmentVariableIfCustomAreProvided: false);
142-
await portFound.Task;
143-
144-
var tcpClient = new TcpClient();
145-
using CancellationTokenSource cancellationTokenSource = new(TimeSpan.FromSeconds(90));
146-
#pragma warning disable VSTHRD103 // Call async methods when in an async method
147-
await tcpClient.ConnectAsync(new IPEndPoint(IPAddress.Loopback, portFound.Task.Result), cancellationTokenSource.Token);
148-
#pragma warning restore VSTHRD103 // Call async methods when in an async method
149-
return new TestingPlatformClient(new(tcpClient.GetStream()), tcpClient, processHandler, enableDiagnostic);
150-
}
151-
152-
[GeneratedRegex(@"Starting server. Listening on port '(\d+)'")]
153-
private static partial Regex ParsePort();
15472
}

0 commit comments

Comments
 (0)