-
Notifications
You must be signed in to change notification settings - Fork 467
Expand file tree
/
Copy pathProcessExtensionsTests.cs
More file actions
41 lines (34 loc) · 1.25 KB
/
ProcessExtensionsTests.cs
File metadata and controls
41 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using System.Diagnostics;
using System.Runtime.InteropServices;
using Azure.Functions.Cli.Extensions;
using FluentAssertions;
using Xunit;
namespace Azure.Functions.Cli.UnitTests.ExtensionsTests
{
public class ProcessExtensionsTests
{
private volatile bool _calledContinueWith = false;
[SkippableFact]
public async Task WaitForExitTest()
{
Skip.IfNot(
RuntimeInformation.IsOSPlatform(OSPlatform.Windows),
reason: "Unreliable on linux CI");
Process process = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? Process.Start("cmd")
: Process.Start("sh");
process.CreateWaitForExitTask().ContinueWith(_ =>
{
_calledContinueWith = true;
}).Ignore();
process.Kill();
for (var i = 0; !_calledContinueWith && i < 10; i++)
{
await Task.Delay(200);
}
_calledContinueWith.Should().BeTrue(because: "the process should have exited and called the continuation");
}
}
}