Skip to content
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

Enable more libraries tests #73104

Merged
merged 6 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<IlcArg Condition="$(ExportsFile) != ''" Include="--exportsfile:$(ExportsFile)" />
<IlcArg Include="@(AutoInitializedAssemblies->'--initassembly:%(Identity)')" />
<IlcArg Include="@(RuntimeHostConfigurationOption->'--appcontextswitch:%(Identity)=%(Value)')" />
<IlcArg Include="--appcontextswitch:RUNTIME_IDENTIFIER=$(RuntimeIdentifier)" />
<IlcArg Include="@(DirectPInvoke->'--directpinvoke:%(Identity)')" />
<IlcArg Include="@(DirectPInvokeList->'--directpinvokelist:%(Identity)')" />
<IlcArg Include="@(_TrimmerFeatureSettings->'--feature:%(Identity)=%(Value)')" />
Expand Down
27 changes: 15 additions & 12 deletions src/libraries/System.Console/tests/TermInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
Expand All @@ -10,6 +11,8 @@
[SkipOnPlatform(TestPlatforms.Android | TestPlatforms.Browser | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on Android, Browser, iOS, MacCatalyst, or tvOS.")]
public class TermInfo
{
private const string SystemConsoleFullNameSuffix = ", System.Console";

// Names of internal members accessed via reflection
private const string TerminfoType = "System.TermInfo";
private const string TerminfoDatabaseType = TerminfoType + "+Database";
Expand All @@ -30,7 +33,7 @@ public void VerifyInstalledTermInfosParse()
{
bool foundAtLeastOne = false;

string[] locations = GetFieldValueOnObject<string[]>(TerminfoLocationsField, null, typeof(Console).GetTypeInfo().Assembly.GetType(TerminfoDatabaseType));
string[] locations = GetFieldValueOnObject<string[]>(TerminfoLocationsField, null, Type.GetType(TerminfoDatabaseType + SystemConsoleFullNameSuffix));
foreach (string location in locations)
{
if (!Directory.Exists(location))
Expand Down Expand Up @@ -62,7 +65,7 @@ public void VerifyInstalledTermInfosParse()
[PlatformSpecific(TestPlatforms.AnyUnix)] // Tests TermInfo
public void VerifyTermInfoSupportsNewAndLegacyNcurses()
{
MethodInfo readDbMethod = typeof(Console).GetTypeInfo().Assembly.GetType(TerminfoDatabaseType).GetTypeInfo().GetDeclaredMethods(ReadDatabaseMethod).Where(m => m.GetParameters().Count() == 2).Single();
MethodInfo readDbMethod = Type.GetType(TerminfoDatabaseType + SystemConsoleFullNameSuffix).GetTypeInfo().GetDeclaredMethods(ReadDatabaseMethod).Where(m => m.GetParameters().Count() == 2).Single();
readDbMethod.Invoke(null, new object[] { "xterm", "ncursesFormats" }); // This will throw InvalidOperationException in case we don't support the legacy format
readDbMethod.Invoke(null, new object[] { "screen-256color", "ncursesFormats" }); // This will throw InvalidOperationException if we can't parse the new format
}
Expand Down Expand Up @@ -121,37 +124,37 @@ public void TryingToLoadTermThatDoesNotExistDoesNotThrow()

private object ReadTermInfoDatabase(string term)
{
MethodInfo readDbMethod = typeof(Console).GetTypeInfo().Assembly.GetType(TerminfoDatabaseType).GetTypeInfo().GetDeclaredMethods(ReadDatabaseMethod).Where(m => m.GetParameters().Count() == 1).Single();
MethodInfo readDbMethod = Type.GetType(TerminfoDatabaseType + SystemConsoleFullNameSuffix).GetTypeInfo().GetDeclaredMethods(ReadDatabaseMethod).Where(m => m.GetParameters().Count() == 1).Single();
return readDbMethod.Invoke(null, new object[] { term });
}

private object CreateTermColorInfo(object db)
{
return typeof(Console).GetTypeInfo().Assembly.GetType(TerminalFormatStringsType).GetTypeInfo().DeclaredConstructors
return Type.GetType(TerminalFormatStringsType + SystemConsoleFullNameSuffix).GetTypeInfo().DeclaredConstructors
.Where(c => c.GetParameters().Count() == 1).Single().Invoke(new object[] { db });
}

private string GetForegroundFormat(object colorInfo)
{
return GetFieldValueOnObject<string>(ForegroundFormatField, colorInfo, typeof(Console).GetTypeInfo().Assembly.GetType(TerminalFormatStringsType));
return GetFieldValueOnObject<string>(ForegroundFormatField, colorInfo, Type.GetType(TerminalFormatStringsType + SystemConsoleFullNameSuffix));
}

private string GetBackgroundFormat(object colorInfo)
{
return GetFieldValueOnObject<string>(BackgroundFormatField, colorInfo, typeof(Console).GetTypeInfo().Assembly.GetType(TerminalFormatStringsType));
return GetFieldValueOnObject<string>(BackgroundFormatField, colorInfo, Type.GetType(TerminalFormatStringsType + SystemConsoleFullNameSuffix));
}

private int GetMaxColors(object colorInfo)
{
return GetFieldValueOnObject<int>(MaxColorsField, colorInfo, typeof(Console).GetTypeInfo().Assembly.GetType(TerminalFormatStringsType));
return GetFieldValueOnObject<int>(MaxColorsField, colorInfo, Type.GetType(TerminalFormatStringsType + SystemConsoleFullNameSuffix));
}

private string GetResetFormat(object colorInfo)
{
return GetFieldValueOnObject<string>(ResetFormatField, colorInfo, typeof(Console).GetTypeInfo().Assembly.GetType(TerminalFormatStringsType));
return GetFieldValueOnObject<string>(ResetFormatField, colorInfo, Type.GetType(TerminalFormatStringsType + SystemConsoleFullNameSuffix));
}

private T GetFieldValueOnObject<T>(string name, object instance, Type baseType)
private T GetFieldValueOnObject<T>(string name, object instance, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)] Type baseType)
{
return (T)baseType.GetTypeInfo().GetDeclaredField(name).GetValue(instance);
}
Expand All @@ -160,7 +163,7 @@ private object CreateFormatParam(object o)
{
Assert.True((o.GetType() == typeof(int)) || (o.GetType() == typeof(string)));

TypeInfo ti = typeof(Console).GetTypeInfo().Assembly.GetType(FormatParamType).GetTypeInfo();
TypeInfo ti = Type.GetType(FormatParamType + SystemConsoleFullNameSuffix).GetTypeInfo();
ConstructorInfo ci = null;

foreach (ConstructorInfo c in ti.DeclaredConstructors)
Expand All @@ -184,8 +187,8 @@ private object CreateFormatParam(object o)

private string EvaluateParameterizedStrings(string format, params object[] parameters)
{
Type formatArrayType = typeof(Console).GetTypeInfo().Assembly.GetType(FormatParamType).MakeArrayType();
MethodInfo mi = typeof(Console).GetTypeInfo().Assembly.GetType(ParameterizedStringsType).GetTypeInfo()
Type formatArrayType = Type.GetType(FormatParamType + SystemConsoleFullNameSuffix).MakeArrayType();
MethodInfo mi = Type.GetType(ParameterizedStringsType + SystemConsoleFullNameSuffix).GetTypeInfo()
.GetDeclaredMethods(EvaluateMethod).First(m => m.GetParameters()[1].ParameterType.IsArray);

// Create individual FormatParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void RelativeSearchPath_Is_Null()
Assert.Null(AppDomain.CurrentDomain.RelativeSearchPath);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasHostExecutable))]
[SkipOnPlatform(TestPlatforms.Browser | TestPlatforms.Android | TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "The dotnet sdk will not be available on these platforms")]
public void TargetFrameworkTest()
{
Expand Down Expand Up @@ -258,7 +258,7 @@ public void ExecuteAssemblyByName()
}).Dispose();
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsAssemblyLoadingSupported))]
public void ExecuteAssembly()
{
CopyTestAssemblies();
Expand Down Expand Up @@ -361,7 +361,7 @@ public void Load()
Assert.NotNull(AppDomain.CurrentDomain.Load(typeof(AppDomainTests).Assembly.FullName));
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsAssemblyLoadingSupported))]
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser.")]
public void LoadBytes()
{
Expand Down Expand Up @@ -651,7 +651,7 @@ public CorrectlyPropagatesException(string message) : base(message)
{ }
}

[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsAssemblyLoadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/43909", TestRuntimes.Mono)]
[InlineData(true)]
[InlineData(false)]
Expand Down Expand Up @@ -872,7 +872,7 @@ public static IEnumerable<object[]> TestingCreateInstanceFromObjectHandleData()
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclassnodefaultconstructorsample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", exceptionType };
}

[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsAssemblyLoadingSupported))]
[MemberData(nameof(TestingCreateInstanceObjectHandleData))]
public static void TestingCreateInstanceObjectHandle(string assemblyName, string type, string returnedFullNameType, Type exceptionType)
{
Expand Down Expand Up @@ -921,7 +921,7 @@ public static void TestingCreateInstanceObjectHandle(string assemblyName, string
{ "assemblyresolvetestapp", "assemblyresolvetestapp.publicclassnodefaultconstructorsample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", typeof(TypeLoadException) }
};

[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsAssemblyLoadingSupported))]
[MemberData(nameof(TestingCreateInstanceFromObjectHandleFullSignatureData))]
public static void TestingCreateInstanceFromObjectHandleFullSignature(string physicalFileName, string assemblyFile, string type, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, string returnedFullNameType)
{
Expand Down Expand Up @@ -951,7 +951,7 @@ public static IEnumerable<object[]> TestingCreateInstanceFromObjectHandleFullSig
}
}

[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsAssemblyLoadingSupported))]
[MemberData(nameof(TestingCreateInstanceObjectHandleFullSignatureData))]
public static void TestingCreateInstanceObjectHandleFullSignature(string assemblyName, string type, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, string returnedFullNameType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static void StartNewAndRestart()
}
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
public static void DebuggerAttributesValid()
{
Stopwatch watch = new Stopwatch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void ProcessorCount_Windows_MatchesGetSystemInfo()
public static int GetProcessorCount() => Environment.ProcessorCount;

[PlatformSpecific(TestPlatforms.Windows)]
[Theory]
[ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/52910", TestRuntimes.Mono)]
[InlineData(8000, 0, null)]
[InlineData(8000, 2000, null)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class EnvironmentStackTrace
static string s_stackTrace;

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/73051", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))]
[ActiveIssue("https://github.com/mono/mono/issues/15315", TestRuntimes.Mono)]
public void StackTraceTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ public static void GetAssemblyName_AssemblyNameProxy()
AssertExtensions.Throws<ArgumentException>("path", null, () => anp.GetAssemblyName(string.Empty));
Assert.Throws<FileNotFoundException>(() => anp.GetAssemblyName(Guid.NewGuid().ToString("N")));

Assembly a = typeof(AssemblyNameProxyTests).Assembly;
Assert.Equal(new AssemblyName(a.FullName).ToString(), anp.GetAssemblyName(Path.GetFullPath(a.Location)).ToString());
if (PlatformDetection.HasAssemblyFiles)
{
Assembly a = typeof(AssemblyNameProxyTests).Assembly;
Assert.Equal(new AssemblyName(a.FullName).ToString(), anp.GetAssemblyName(Path.GetFullPath(a.Location)).ToString());
}
}
}
}
14 changes: 4 additions & 10 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@
<!-- https://github.com/dotnet/runtime/issues/72908 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Reflection.MetadataLoadContext\tests\System.Reflection.MetadataLoadContext.Tests.csproj" />

<!-- Test needs to copy .so file: https://github.com/dotnet/runtime/issues/72987 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.Ports\tests\System.IO.Ports.Tests.csproj"
Condition="'$(TargetOS)' != 'windows'" />

<!-- Not applicable to NativeAOT -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Reflection\tests\InvokeEmit\System.Reflection.InvokeEmit.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Reflection\tests\InvokeInterpreted\System.Reflection.InvokeInterpreted.Tests.csproj" />
Expand Down Expand Up @@ -456,12 +460,6 @@
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.FileSystem\tests\System.IO.FileSystem.Tests.csproj" />
<!--Needs work to get these tests to pass -->
<!--These tests have failures-->
<!-- Couple trimming related issues. Easy -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Console\tests\System.Console.Tests.csproj"
Condition="'$(TargetOS)' == 'linux'" />
<!-- Test needs to copy .so file: https://github.com/dotnet/runtime/issues/72987 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.Ports\tests\System.IO.Ports.Tests.csproj"
Condition="'$(TargetOS)' == 'linux'" />
<!-- Looks like our xunit runner doesn't respect tests that don't want to be multithreaded -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Net.NameResolution\tests\FunctionalTests\System.Net.NameResolution.Functional.Tests.csproj"
Condition="'$(TargetOS)' == 'windows'"/>
Expand Down Expand Up @@ -529,7 +527,6 @@
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Linq.Queryable\tests\System.Linq.Queryable.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Management\tests\System.Management.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Net.WebSockets\tests\System.Net.WebSockets.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Numerics.Tensors\tests\System.Numerics.Tensors.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.ObjectModel\tests\System.ObjectModel.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Private.Runtime.InteropServices.JavaScript\tests\System.Private.Runtime.InteropServices.JavaScript.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Private.Xml\tests\XmlSerializer\ReflectionOnly\System.Xml.XmlSerializer.ReflectionOnly.Tests.csproj" />
Expand All @@ -541,9 +538,6 @@
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Resources.Extensions\tests\System.Resources.Extensions.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Resources.ResourceManager\tests\System.Resources.ResourceManager.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime\tests\NlsTests\System.Runtime.Nls.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Extensions\tests\System.Runtime.Extensions.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices.RuntimeInformation\tests\System.Runtime.InteropServices.RuntimeInformation.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Serialization.Formatters\tests\System.Runtime.Serialization.Formatters.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Serialization.Json\tests\System.Runtime.Serialization.Json.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Serialization.Json\tests\ReflectionOnly\System.Runtime.Serialization.Json.ReflectionOnly.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Serialization.Xml\tests\System.Runtime.Serialization.Xml.Tests.csproj" />
Expand Down