예제 #1
0
        public async Task KillsProcessOnSigInt()
        {
            void SendSigInt(int pid)
            {
                _output.WriteLine($"kill -SIGINT {pid}");
                Process.Start("kill", $"-SIGINT {pid}");
            }

            await _app.StartWatcherAsync(new[] { "--no-exit" });

            var childPid = await _app.GetProcessId();

            SendSigInt(_app.Process.Id);
            SendSigInt(childPid);

            await _app.Process.Exited.TimeoutAfter(TimeSpan.FromSeconds(30));

            Assert.DoesNotContain(_app.Process.Output, l => l.StartsWith("Exited with error code"));
        }
예제 #2
0
        public async Task RestartProcessOnFileChange()
        {
            await _app.StartWatcherAsync(new[] { "--no-exit" });

            var pid = await _app.GetProcessId();

            // Then wait for it to restart when we change a file
            var fileToChange = Path.Combine(_app.SourceDirectory, "Program.cs");
            var programCs    = File.ReadAllText(fileToChange);

            File.WriteAllText(fileToChange, programCs);

            await _app.HasRestarted();

            Assert.DoesNotContain(_app.Process.Output, l => l.StartsWith("Exited with error code"));

            var pid2 = await _app.GetProcessId();

            Assert.NotEqual(pid, pid2);
        }
예제 #3
0
        public async Task RestartProcessOnFileChange()
        {
            await _app.StartWatcherAsync(new[] { "--no-exit" });

            var pid = await _app.GetProcessId();

            // Then wait for it to restart when we change a file
            var fileToChange = Path.Combine(_app.SourceDirectory, "Program.cs");
            var programCs    = File.ReadAllText(fileToChange);

            File.WriteAllText(fileToChange, programCs);

            await _app.HasRestarted();

            var pid2 = await _app.GetProcessId();

            Assert.NotEqual(pid, pid2);

            // first app should have shut down
            Assert.Throws <ArgumentException>(() => Process.GetProcessById(pid));
        }