From: Roman Marusyk Date: Sun, 22 Dec 2019 06:13:14 +0000 (+0200) Subject: Consolidate .netcoreapp.cs files because System.Diagnostics.* projects is no longer... X-Git-Tag: submit/tizen/20210909.063632~10623 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ed1e99c0ac87b004ae3ec45efe0dfb7a3edb85c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Consolidate .netcoreapp.cs files because System.Diagnostics.* projects is no longer cross-compiled (#1101) --- diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs index 0621fa0..e91bc99 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs @@ -20,7 +20,7 @@ using Xunit; namespace System.Diagnostics.Tests { - public partial class ProcessStartInfoTests : ProcessTestBase + public class ProcessStartInfoTests : ProcessTestBase { [Fact] public void TestEnvironmentProperty() @@ -1117,5 +1117,65 @@ namespace System.Diagnostics.Tests Assert.Equal(expected, Assert.Throws(() => Process.Start(info)).NativeErrorCode); } + + [Fact] + public void UnintializedArgumentList() + { + ProcessStartInfo psi = new ProcessStartInfo(); + Assert.Equal(0, psi.ArgumentList.Count); + + psi = new ProcessStartInfo("filename", "-arg1 -arg2"); + Assert.Equal(0, psi.ArgumentList.Count); + } + + [Fact] + public void InitializeWithArgumentList() + { + ProcessStartInfo psi = new ProcessStartInfo("filename"); + psi.ArgumentList.Add("arg1"); + psi.ArgumentList.Add("arg2"); + + Assert.Equal(2, psi.ArgumentList.Count); + Assert.Equal("arg1", psi.ArgumentList[0]); + Assert.Equal("arg2", psi.ArgumentList[1]); + } + + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // No Notepad on Nano + [MemberData(nameof(UseShellExecute))] + [OuterLoop("Launches notepad")] + [PlatformSpecific(TestPlatforms.Windows)] + public void StartInfo_NotepadWithContent_withArgumentList(bool useShellExecute) + { + string tempFile = GetTestFilePath() + ".txt"; + File.WriteAllText(tempFile, $"StartInfo_NotepadWithContent({useShellExecute})"); + + ProcessStartInfo info = new ProcessStartInfo + { + UseShellExecute = useShellExecute, + FileName = @"notepad.exe", + Arguments = null, + WindowStyle = ProcessWindowStyle.Minimized + }; + + info.ArgumentList.Add(tempFile); + + using (var process = Process.Start(info)) + { + Assert.True(process != null, $"Could not start {info.FileName} {info.Arguments} UseShellExecute={info.UseShellExecute}"); + + try + { + process.WaitForInputIdle(); // Give the file a chance to load + Assert.Equal("notepad", process.ProcessName); + + // On some Windows versions, the file extension is not included in the title + Assert.StartsWith(Path.GetFileNameWithoutExtension(tempFile), process.MainWindowTitle); + } + finally + { + process?.Kill(); + } + } + } } } diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.netcoreapp.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.netcoreapp.cs deleted file mode 100644 index 29214a3..0000000 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.netcoreapp.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using Xunit; - -namespace System.Diagnostics.Tests -{ - public partial class ProcessStartInfoTests - { - [Fact] - public void UnintializedArgumentList() - { - ProcessStartInfo psi = new ProcessStartInfo(); - Assert.Equal(0, psi.ArgumentList.Count); - - psi = new ProcessStartInfo("filename", "-arg1 -arg2"); - Assert.Equal(0, psi.ArgumentList.Count); - } - - [Fact] - public void InitializeWithArgumentList() - { - ProcessStartInfo psi = new ProcessStartInfo("filename"); - psi.ArgumentList.Add("arg1"); - psi.ArgumentList.Add("arg2"); - - Assert.Equal(2, psi.ArgumentList.Count); - Assert.Equal("arg1", psi.ArgumentList[0]); - Assert.Equal("arg2", psi.ArgumentList[1]); - } - - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // No Notepad on Nano - [MemberData(nameof(UseShellExecute))] - [OuterLoop("Launches notepad")] - [PlatformSpecific(TestPlatforms.Windows)] - public void StartInfo_NotepadWithContent_withArgumentList(bool useShellExecute) - { - string tempFile = GetTestFilePath() + ".txt"; - File.WriteAllText(tempFile, $"StartInfo_NotepadWithContent({useShellExecute})"); - - ProcessStartInfo info = new ProcessStartInfo - { - UseShellExecute = useShellExecute, - FileName = @"notepad.exe", - Arguments = null, - WindowStyle = ProcessWindowStyle.Minimized - }; - - info.ArgumentList.Add(tempFile); - - using (var process = Process.Start(info)) - { - Assert.True(process != null, $"Could not start {info.FileName} {info.Arguments} UseShellExecute={info.UseShellExecute}"); - - try - { - process.WaitForInputIdle(); // Give the file a chance to load - Assert.Equal("notepad", process.ProcessName); - - // On some Windows versions, the file extension is not included in the title - Assert.StartsWith(Path.GetFileNameWithoutExtension(tempFile), process.MainWindowTitle); - } - finally - { - process?.Kill(); - } - } - } - } -} diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.cs index 29a959c..9be34d8 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; @@ -14,7 +15,7 @@ using Xunit; namespace System.Diagnostics.Tests { - public partial class ProcessStreamReadTests : ProcessTestBase + public class ProcessStreamReadTests : ProcessTestBase { [Fact] public void TestSyncErrorStream() @@ -544,5 +545,48 @@ namespace System.Diagnostics.Tests Assert.True(p.WaitForExit(WaitInMS)); } } + + [Fact] + public void TestCustomStandardInputEncoding() + { + var process = CreateProcessPortable(RemotelyInvokable.ReadLineWithCustomEncodingWriteLineWithUtf8, Encoding.UTF32.WebName); + process.StartInfo.RedirectStandardInput = true; + process.StartInfo.StandardInputEncoding = Encoding.UTF32; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.StandardOutputEncoding = Encoding.UTF8; + process.Start(); + + const string TestLine = "\U0001f627\U0001f62e\U0001f62f"; + process.StandardInput.WriteLine(TestLine); + process.StandardInput.Close(); + + var output = process.StandardOutput.ReadLine(); + Assert.Equal(TestLine, output); + + Assert.True(process.WaitForExit(WaitInMS)); + Assert.Equal(RemotelyInvokable.SuccessExitCode, process.ExitCode); + } + + [Fact] + public void TestMismatchedStandardInputEncoding() + { + var process = CreateProcessPortable(RemotelyInvokable.ReadLineWithCustomEncodingWriteLineWithUtf8, Encoding.UTF32.WebName); + process.StartInfo.RedirectStandardInput = true; + // incorrect: the process will be writing in UTF-32 + process.StartInfo.StandardInputEncoding = Encoding.ASCII; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.StandardOutputEncoding = Encoding.UTF8; + process.Start(); + + const string TestLine = "\U0001f627\U0001f62e\U0001f62f"; + process.StandardInput.WriteLine(TestLine); + process.StandardInput.Close(); + + var output = process.StandardOutput.ReadLine(); + Assert.NotEqual(TestLine, output); + + Assert.True(process.WaitForExit(WaitInMS)); + Assert.Equal(RemotelyInvokable.SuccessExitCode, process.ExitCode); + } } } diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.netcoreapp.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.netcoreapp.cs deleted file mode 100644 index 5be8043..0000000 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.netcoreapp.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Xunit; - -namespace System.Diagnostics.Tests -{ - public partial class ProcessStreamReadTests : ProcessTestBase - { - [Fact] - public void TestCustomStandardInputEncoding() - { - var process = CreateProcessPortable(RemotelyInvokable.ReadLineWithCustomEncodingWriteLineWithUtf8, Encoding.UTF32.WebName); - process.StartInfo.RedirectStandardInput = true; - process.StartInfo.StandardInputEncoding = Encoding.UTF32; - process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.StandardOutputEncoding = Encoding.UTF8; - process.Start(); - - const string TestLine = "\U0001f627\U0001f62e\U0001f62f"; - process.StandardInput.WriteLine(TestLine); - process.StandardInput.Close(); - - var output = process.StandardOutput.ReadLine(); - Assert.Equal(TestLine, output); - - Assert.True(process.WaitForExit(WaitInMS)); - Assert.Equal(RemotelyInvokable.SuccessExitCode, process.ExitCode); - } - - [Fact] - public void TestMismatchedStandardInputEncoding() - { - var process = CreateProcessPortable(RemotelyInvokable.ReadLineWithCustomEncodingWriteLineWithUtf8, Encoding.UTF32.WebName); - process.StartInfo.RedirectStandardInput = true; - // incorrect: the process will be writing in UTF-32 - process.StartInfo.StandardInputEncoding = Encoding.ASCII; - process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.StandardOutputEncoding = Encoding.UTF8; - process.Start(); - - const string TestLine = "\U0001f627\U0001f62e\U0001f62f"; - process.StandardInput.WriteLine(TestLine); - process.StandardInput.Close(); - - var output = process.StandardOutput.ReadLine(); - Assert.NotEqual(TestLine, output); - - Assert.True(process.WaitForExit(WaitInMS)); - Assert.Equal(RemotelyInvokable.SuccessExitCode, process.ExitCode); - } - } -} diff --git a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj index bcae59c..162b60a 100644 --- a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj +++ b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj @@ -33,8 +33,6 @@ - - diff --git a/src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.cs b/src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.cs index a0b0cfd..8c8be7706 100644 --- a/src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.cs +++ b/src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.cs @@ -4,11 +4,14 @@ using System.IO; using System.Reflection; +using System.Reflection.Emit; +using System.Linq; +using Microsoft.DotNet.RemoteExecutor; using Xunit; namespace System.Diagnostics.TraceSourceTests { - public partial class DefaultTraceListenerClassTests : FileCleanupTestBase + public class DefaultTraceListenerClassTests : FileCleanupTestBase { private class TestDefaultTraceListener : DefaultTraceListener { @@ -139,5 +142,43 @@ namespace System.Diagnostics.TraceSourceTests listener.LogFileName = expectedLogFileName; Assert.Equal(expectedLogFileName, listener.LogFileName); } + + [Fact] + public void EntryAssemblyName_Default_IncludedInTrace() + { + RemoteExecutor.Invoke(() => + { + var listener = new TestDefaultTraceListener(); + Trace.Listeners.Add(listener); + Trace.TraceError("hello world"); + Assert.Equal(Assembly.GetEntryAssembly()?.GetName().Name + " Error: 0 : hello world", listener.Output.Trim()); + }).Dispose(); + } + + [Fact] + public void EntryAssemblyName_Null_NotIncludedInTrace() + { + RemoteExecutor.Invoke(() => + { + MakeAssemblyGetEntryAssemblyReturnNull(); + + var listener = new TestDefaultTraceListener(); + Trace.Listeners.Add(listener); + Trace.TraceError("hello world"); + Assert.Equal("Error: 0 : hello world", listener.Output.Trim()); + }).Dispose(); + } + + /// + /// Makes Assembly.GetEntryAssembly() return null using private reflection. + /// + private static void MakeAssemblyGetEntryAssemblyReturnNull() + { + typeof(Assembly) + .GetField("s_forceNullEntryPoint", BindingFlags.NonPublic | BindingFlags.Static) + .SetValue(null, true); + + Assert.Null(Assembly.GetEntryAssembly()); + } } } diff --git a/src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.netcoreapp.cs b/src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.netcoreapp.cs deleted file mode 100644 index 0dacf4e..0000000 --- a/src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.netcoreapp.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using System.Reflection; -using System.Reflection.Emit; -using System.Linq; -using Microsoft.DotNet.RemoteExecutor; -using Xunit; - -namespace System.Diagnostics.TraceSourceTests -{ - public partial class DefaultTraceListenerClassTests - { - [Fact] - public void EntryAssemblyName_Default_IncludedInTrace() - { - RemoteExecutor.Invoke(() => - { - var listener = new TestDefaultTraceListener(); - Trace.Listeners.Add(listener); - Trace.TraceError("hello world"); - Assert.Equal(Assembly.GetEntryAssembly()?.GetName().Name + " Error: 0 : hello world", listener.Output.Trim()); - }).Dispose(); - } - - [Fact] - public void EntryAssemblyName_Null_NotIncludedInTrace() - { - RemoteExecutor.Invoke(() => - { - MakeAssemblyGetEntryAssemblyReturnNull(); - - var listener = new TestDefaultTraceListener(); - Trace.Listeners.Add(listener); - Trace.TraceError("hello world"); - Assert.Equal("Error: 0 : hello world", listener.Output.Trim()); - }).Dispose(); - } - - /// - /// Makes Assembly.GetEntryAssembly() return null using private reflection. - /// - private static void MakeAssemblyGetEntryAssemblyReturnNull() - { - typeof(Assembly) - .GetField("s_forceNullEntryPoint", BindingFlags.NonPublic | BindingFlags.Static) - .SetValue(null, true); - - Assert.Null(Assembly.GetEntryAssembly()); - } - } -} diff --git a/src/libraries/System.Diagnostics.TraceSource/tests/System.Diagnostics.TraceSource.Tests.csproj b/src/libraries/System.Diagnostics.TraceSource/tests/System.Diagnostics.TraceSource.Tests.csproj index eaceb29..63d79be 100644 --- a/src/libraries/System.Diagnostics.TraceSource/tests/System.Diagnostics.TraceSource.Tests.csproj +++ b/src/libraries/System.Diagnostics.TraceSource/tests/System.Diagnostics.TraceSource.Tests.csproj @@ -24,7 +24,4 @@ - - - \ No newline at end of file