-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle correctly waiting for process exit on Unix systems #3410
Changes from 2 commits
1d9b0a0
b7bc552
e1c0d57
464f152
09639a9
00ddb0b
f87683d
f90c45c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.IO; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Microsoft.TestPlatform.AcceptanceTests; | ||
|
||
[TestClass] | ||
public class ProcessTests : AcceptanceTestBase | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that it would be nice to add one more test where we have a specific test adapter (not sure if that's the right "level") that would be hanging so we can prove that the cancellation are correctly done. If you share the feeling, I'd be happy to be helped to add it. |
||
[TestMethod] | ||
public void MissingFrameworkTextIsCorrectlyDisplayed() | ||
{ | ||
// Arrange | ||
var assemblyPath = GetAssetFullPath("SimpleTestProjectMessedUpTargetFramework.dll", Core21TargetFramework); | ||
var runtimeConfigJson = Path.Combine(Path.GetDirectoryName(assemblyPath), "SimpleTestProjectMessedUpTargetFramework.runtimeconfig.json"); | ||
var fileContent = File.ReadAllText(runtimeConfigJson); | ||
var updatedContent = fileContent.Replace("\"version\": \"2.1.0\"", "\"version\": \"42\""); | ||
File.WriteAllText(runtimeConfigJson, updatedContent); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. q: this test is modifying the assets right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that's why I created a new test asset. I originally thought that we were doing a local copy of the asset for each test but we don't so I wasn't sure how to best do this. Given the question, I should probably put a comment in the code to explain what/why. Thanks for pointing it out! |
||
|
||
// Act | ||
InvokeDotnetTest(assemblyPath); | ||
|
||
// Assert | ||
ExitCodeEquals(1); | ||
StdErrorContains("The framework 'Microsoft.NETCore.App', version '42' (x64) was not found."); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -599,6 +599,11 @@ protected static void ExecuteApplication(string path, string args, out string st | |
throw new ArgumentException("Executable path must not be null or whitespace.", nameof(path)); | ||
} | ||
|
||
if (!File.Exists(path)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR, but when trying to debug I noticed that without this check we end up with error like |
||
{ | ||
throw new ArgumentException($"Executable path '{path}' could not be found.", nameof(path)); | ||
} | ||
|
||
var executableName = Path.GetFileName(path); | ||
|
||
using var process = new Process(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<!-- Imports Common TestAssets props. --> | ||
<Import Project="..\..\..\scripts\build\TestAssets.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks> | ||
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netcoreapp3.1</TargetFrameworks> | ||
<TestProject>true</TestProject> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MSTest.TestFramework"> | ||
<Version>$(MSTestFrameworkVersion)</Version> | ||
</PackageReference> | ||
<PackageReference Include="MSTest.TestAdapter"> | ||
<Version>$(MSTestAdapterVersion)</Version> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk"> | ||
<Version>$(NETTestSdkVersion)</Version> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace SimpleTestProjectMessedUpTargetFramework | ||
{ | ||
[TestClass] | ||
public class UnitTest1 | ||
{ | ||
[TestMethod] | ||
public void TestMethod1() | ||
{ | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't really find in which existing type this would fit best so I created this one, feel free to suggest alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProcessesInteractionTests
?