mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-24 22:35:39 -04:00
Fixed: several failing/flaky mono unit tests
Co-Authored-By: taloth <taloth@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,7 @@ namespace NzbDrone.Common.Test
|
||||
// We don't want one tests setup killing processes used in another
|
||||
[NonParallelizable]
|
||||
[TestFixture]
|
||||
[Platform(Exclude = "MacOsX")]
|
||||
public class ProcessProviderFixture : TestBase<ProcessProvider>
|
||||
{
|
||||
|
||||
@@ -71,20 +72,18 @@ namespace NzbDrone.Common.Test
|
||||
{
|
||||
var process = StartDummyProcess();
|
||||
|
||||
var check = Subject.GetProcessById(process.Id);
|
||||
check.Should().NotBeNull();
|
||||
Thread.Sleep(500);
|
||||
|
||||
process.Refresh();
|
||||
process.HasExited.Should().BeFalse();
|
||||
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should()
|
||||
.BeTrue("one running dummy process");
|
||||
|
||||
process.Kill();
|
||||
process.WaitForExit();
|
||||
process.HasExited.Should().BeTrue();
|
||||
|
||||
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Platform(Exclude="MacOsX")]
|
||||
[Retry(3)]
|
||||
public void exists_should_find_running_process()
|
||||
{
|
||||
var process = StartDummyProcess();
|
||||
@@ -100,12 +99,13 @@ namespace NzbDrone.Common.Test
|
||||
|
||||
|
||||
[Test]
|
||||
[Platform(Exclude="MacOsX")]
|
||||
public void kill_all_should_kill_all_process_with_name()
|
||||
{
|
||||
var dummy1 = StartDummyProcess();
|
||||
var dummy2 = StartDummyProcess();
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
Subject.KillAll(DummyApp.DUMMY_PROCCESS_NAME);
|
||||
|
||||
dummy1.HasExited.Should().BeTrue();
|
||||
@@ -114,26 +114,11 @@ namespace NzbDrone.Common.Test
|
||||
|
||||
private Process StartDummyProcess()
|
||||
{
|
||||
var processStarted = new ManualResetEventSlim();
|
||||
|
||||
var path = Path.Combine(TestContext.CurrentContext.TestDirectory, DummyApp.DUMMY_PROCCESS_NAME + ".exe");
|
||||
var process = Subject.Start(path, onOutputDataReceived: (string data) => {
|
||||
if (data.StartsWith("Dummy process. ID:"))
|
||||
{
|
||||
processStarted.Set();
|
||||
}
|
||||
});
|
||||
|
||||
if (!processStarted.Wait(2000))
|
||||
{
|
||||
Assert.Fail("Failed to start process within 2 sec");
|
||||
}
|
||||
|
||||
return process;
|
||||
return Subject.Start(path);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Retry(3)]
|
||||
public void ToString_on_new_processInfo()
|
||||
{
|
||||
Console.WriteLine(new ProcessInfo().ToString());
|
||||
|
||||
Reference in New Issue
Block a user