Example #1
0
        public async Task ShutdownDoesNotAbortCompilation()
        {
            var host = new TestableCompilerServerHost();

            using (var startedMre = new ManualResetEvent(initialState: false))
                using (var finishedMre = new ManualResetEvent(initialState: false))
                    using (var serverData = await ServerUtil.CreateServer(compilerServerHost: host))
                    {
                        // Create a compilation that is guaranteed to complete after the shutdown is seen.
                        host.RunCompilation = (request, cancellationToken) =>
                        {
                            startedMre.Set();
                            finishedMre.WaitOne();
                            return(s_emptyBuildResponse);
                        };

                        var compileTask = ServerUtil.Send(serverData.PipeName, s_emptyCSharpBuildRequest);
                        startedMre.WaitOne();

                        // The compilation is now in progress, send the shutdown.
                        await ServerUtil.SendShutdown(serverData.PipeName);

                        Assert.False(compileTask.IsCompleted);
                        finishedMre.Set();

                        var response = await compileTask;
                        Assert.Equal(BuildResponse.ResponseType.Completed, response.Type);
                        Assert.Equal(0, ((CompletedBuildResponse)response).ReturnCode);

                        await serverData.Verify(connections : 2, completed : 2);
                    }
        }
Example #2
0
        public async Task ShutdownRequestDirect()
        {
            using (var serverData = await ServerUtil.CreateServer())
            {
                var serverProcessId = await ServerUtil.SendShutdown(serverData.PipeName);

                Assert.Equal(Process.GetCurrentProcess().Id, serverProcessId);
                await serverData.Verify(connections : 1, completed : 1);
            }
        }