From 42fe0347e239f6bb0f8290dffbd1216a34fe700c Mon Sep 17 00:00:00 2001 From: Tomas Matousek Date: Tue, 13 Dec 2016 00:30:33 -0800 Subject: [PATCH] Fix or skip tests to work on Unix --- src/Scripting/CSharpTest/CommandLineRunnerTests.cs | 14 +++++++------- .../CSharpTest/InteractiveSessionTests.cs | 4 ++-- src/Scripting/CSharpTest/ObjectFormatterTests.cs | 14 +++++++------- .../Resolvers/RuntimeMetadataReferenceResolver.cs | 2 +- .../CoreTestUtilities/ObjectFormatterTestBase.cs | 4 ++-- .../Shared/Compilation/CompilationExtensions.cs | 4 +++- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Scripting/CSharpTest/CommandLineRunnerTests.cs b/src/Scripting/CSharpTest/CommandLineRunnerTests.cs index bc6aecebe66..9ecbd21baf4 100644 --- a/src/Scripting/CSharpTest/CommandLineRunnerTests.cs +++ b/src/Scripting/CSharpTest/CommandLineRunnerTests.cs @@ -326,7 +326,7 @@ public void Args_Interactive2() AssertEx.AssertEqualToleratingWhitespaceDifferences(error, runner.Console.Error.ToString()); } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void Args_InteractiveWithScript1() { var script = Temp.CreateFile(extension: ".csx").WriteAllText("foreach (var arg in Args) Print(arg);"); @@ -359,7 +359,7 @@ > 1 > ", runner.Console.Out.ToString()); } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void Args_Script1() { var script = Temp.CreateFile(extension: ".csx").WriteAllText("foreach (var arg in Args) Print(arg);"); @@ -367,7 +367,7 @@ public void Args_Script1() var runner = CreateRunner( args: new[] { script.Path, "arg1", "arg2", "arg3" }); - Assert.Equal(0, runner.RunInteractive()); + Assert.True(runner.RunInteractive() == 0, userMessage: runner.Console.Error.ToString()); AssertEx.AssertEqualToleratingWhitespaceDifferences($@" ""arg1"" @@ -376,7 +376,7 @@ public void Args_Script1() ", runner.Console.Out.ToString()); } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void Args_Script2() { var script = Temp.CreateFile(extension: ".csx").WriteAllText("foreach (var arg in Args) Print(arg);"); @@ -384,7 +384,7 @@ public void Args_Script2() var runner = CreateRunner( args: new[] { script.Path, "@arg1", "@arg2", "@arg3" }); - Assert.Equal(0, runner.RunInteractive()); + Assert.True(runner.RunInteractive() == 0, userMessage: runner.Console.Error.ToString()); AssertEx.AssertEqualToleratingWhitespaceDifferences($@" ""@arg1"" @@ -393,7 +393,7 @@ public void Args_Script2() ", runner.Console.Out.ToString()); } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void Args_Script3() { var script = Temp.CreateFile(extension: ".csx").WriteAllText("foreach (var arg in Args) Print(arg);"); @@ -412,7 +412,7 @@ public void Args_Script3() args: new[] { $"@{rsp.Path}", "/arg5", "--", "/arg7" }, input: "foreach (var arg in Args) Print(arg);"); - Assert.Equal(0, runner.RunInteractive()); + Assert.True(runner.RunInteractive() == 0, userMessage: runner.Console.Error.ToString()); AssertEx.AssertEqualToleratingWhitespaceDifferences($@" ""--"" diff --git a/src/Scripting/CSharpTest/InteractiveSessionTests.cs b/src/Scripting/CSharpTest/InteractiveSessionTests.cs index 7d3e0605b0e..022277e09e5 100644 --- a/src/Scripting/CSharpTest/InteractiveSessionTests.cs +++ b/src/Scripting/CSharpTest/InteractiveSessionTests.cs @@ -1167,13 +1167,13 @@ public void ReferenceDirective_RelativeToBaseParent() string scriptPath = Path.Combine(dir, "a.csx"); var script = CSharpScript.Create( - $@"#r ""..\{libFileName}""", + $@"#r ""{Path.Combine("..", libFileName)}""", ScriptOptions.Default.WithFilePath(scriptPath)); script.GetCompilation().VerifyDiagnostics(); } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void ReferenceDirective_RelativeToBaseRoot() { var file = Temp.CreateFile(); diff --git a/src/Scripting/CSharpTest/ObjectFormatterTests.cs b/src/Scripting/CSharpTest/ObjectFormatterTests.cs index 4802488307b..d48a494aa59 100644 --- a/src/Scripting/CSharpTest/ObjectFormatterTests.cs +++ b/src/Scripting/CSharpTest/ObjectFormatterTests.cs @@ -342,7 +342,7 @@ public void LongMembers() Assert.Equal("LongMembers { LongNa...", str); str = new TestCSharpObjectFormatter(maximumLineLength: 20).FormatObject(obj, SeparateLinesOptions); - Assert.Equal("LongMembers {\r\n LongName0123456789...\r\n LongValue: \"012345...\r\n}\r\n", str); + Assert.Equal($"LongMembers {{{Environment.NewLine} LongName0123456789...{Environment.NewLine} LongValue: \"012345...{Environment.NewLine}}}{Environment.NewLine}", str); } [Fact] @@ -834,7 +834,7 @@ public static void Method() } } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void StackTrace_NonGeneric() { try @@ -855,7 +855,7 @@ public void StackTrace_NonGeneric() } } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void StackTrace_GenericMethod() { try @@ -877,7 +877,7 @@ public void StackTrace_GenericMethod() } } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void StackTrace_GenericType() { try @@ -899,7 +899,7 @@ public void StackTrace_GenericType() } } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void StackTrace_GenericMethodInGenericType() { try @@ -968,7 +968,7 @@ public static void Method(ref U u) } } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void StackTrace_RefOutParameters() { try @@ -991,7 +991,7 @@ public void StackTrace_RefOutParameters() } } - [Fact] + [ConditionalFact(typeof(WindowsOnly)), WorkItem(15860, "https://github.com/dotnet/roslyn/issues/15860")] public void StackTrace_GenericRefParameter() { try diff --git a/src/Scripting/Core/Hosting/Resolvers/RuntimeMetadataReferenceResolver.cs b/src/Scripting/Core/Hosting/Resolvers/RuntimeMetadataReferenceResolver.cs index bdec69b415d..7f0345e537f 100644 --- a/src/Scripting/Core/Hosting/Resolvers/RuntimeMetadataReferenceResolver.cs +++ b/src/Scripting/Core/Hosting/Resolvers/RuntimeMetadataReferenceResolver.cs @@ -181,7 +181,7 @@ private PortableExecutableReference ResolveTrustedPlatformAssemblyCore(string na { var set = ImmutableDictionary.CreateBuilder(StringComparer.OrdinalIgnoreCase); - if (CoreClrShim.AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES") is string paths) + if (CoreClrShim.AppContext.GetData?.Invoke("TRUSTED_PLATFORM_ASSEMBLIES") is string paths) { foreach (var path in paths.Split(Path.PathSeparator)) { diff --git a/src/Scripting/CoreTestUtilities/ObjectFormatterTestBase.cs b/src/Scripting/CoreTestUtilities/ObjectFormatterTestBase.cs index af1fb9b2df9..de8831ab226 100644 --- a/src/Scripting/CoreTestUtilities/ObjectFormatterTestBase.cs +++ b/src/Scripting/CoreTestUtilities/ObjectFormatterTestBase.cs @@ -15,7 +15,7 @@ public abstract class ObjectFormatterTestBase public void AssertMembers(string str, params string[] expected) { int i = 0; - foreach (var line in str.Split(new[] { "\r\n " }, StringSplitOptions.None)) + foreach (var line in str.Split(new[] { Environment.NewLine + " " }, StringSplitOptions.None)) { if (i == 0) { @@ -23,7 +23,7 @@ public void AssertMembers(string str, params string[] expected) } else if (i == expected.Length - 1) { - Assert.Equal(expected[i] + "\r\n}\r\n", line); + Assert.Equal(expected[i] + Environment.NewLine + "}" + Environment.NewLine, line); } else { diff --git a/src/Test/Utilities/Shared/Compilation/CompilationExtensions.cs b/src/Test/Utilities/Shared/Compilation/CompilationExtensions.cs index 6e5468e9e13..06a02df22bb 100644 --- a/src/Test/Utilities/Shared/Compilation/CompilationExtensions.cs +++ b/src/Test/Utilities/Shared/Compilation/CompilationExtensions.cs @@ -11,7 +11,9 @@ using Microsoft.CodeAnalysis.CodeGen; using Microsoft.CodeAnalysis.Emit; using Microsoft.CodeAnalysis.Test.Extensions; +using Roslyn.Test.PdbUtilities; using Roslyn.Test.Utilities; +using Roslyn.Utilities; using Xunit; using Xunit.Sdk; @@ -33,7 +35,7 @@ public static class CompilationExtensions if (pdbStream == null && compilation.Options.OptimizationLevel == OptimizationLevel.Debug && options?.DebugInformationFormat != DebugInformationFormat.Embedded) { - if (MonoHelpers.IsRunningOnMono()) + if (MonoHelpers.IsRunningOnMono() || PathUtilities.IsUnixLikePlatform) { options = (options ?? EmitOptions.Default).WithDebugInformationFormat(DebugInformationFormat.PortablePdb); } -- GitLab