From 735ddeaf8cbc2a2be89ba292bd405bcce615ee60 Mon Sep 17 00:00:00 2001 From: Mark Plesko Date: Tue, 4 Apr 2023 11:32:55 -0700 Subject: [PATCH] Add error check for skipped tests in merged groups (#84284) If I test is written in the old style (with a Main and OutputType==Exe without an attribute such as RequiresProcessIsolation) in a merged test group directory, it will be skipped. This change adds a check to detect those cases. I have struggled with ways to automatically set OutputType. Directory.Build.props is too early (the test project file will override it). Directory.Build.targets is too late as the C# targets files will already have been processed and set other variables based on the value of OutputType. This Target doesn't execute until later, but since it is an error it doesn't matter how those additional properties were set. Since this adds more boilerplate to each merged test directory, I created a src/tests/Directory.Merged.props to share all of that. This catches 3 tests that aren't currently executing. Unrelated: - Use GetPathOfFileAbove in nearby locations for Directory.Build.props chaining rather than specific paths - Fix two easy IL warnings that appeared in my local build of all tests Resolves https://github.com/dotnet/runtime/issues/84182 --- src/tests/Directory.Build.targets | 13 +++++++++++++ src/tests/Directory.Merged.props | 8 ++++++++ src/tests/JIT/Directed/Directory.Build.props | 10 ++-------- .../JIT/HardwareIntrinsics/Directory.Build.props | 5 +---- .../General/ConstantFolding/StaticReadonlySimd.cs | 7 ++++--- .../ConstantFolding/StaticReadonlySimd.csproj | 3 ++- .../X86/X86Serialize_X64/Serialize.X64.cs | 6 ++++-- .../X86/X86Serialize_X64/Serialize.X64_r.csproj | 1 - .../X86/X86Serialize_X64/Serialize.X64_ro.csproj | 1 - src/tests/JIT/IL_Conformance/Directory.Build.props | 6 +----- src/tests/JIT/Methodical/Directory.Build.props | 10 ++-------- src/tests/JIT/Regression/Directory.Build.props | 7 +------ .../TypeGeneratorTests/Directory.Build.props | 8 ++------ .../baseservices/threading/Directory.Build.props | 10 ++-------- src/tests/reflection/ldtoken/byrefs.il | 4 ++-- 15 files changed, 44 insertions(+), 55 deletions(-) create mode 100644 src/tests/Directory.Merged.props diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index bdc77c9edb425..7773f30703d56 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -122,6 +122,19 @@ true + + + + + + + + diff --git a/src/tests/Directory.Merged.props b/src/tests/Directory.Merged.props new file mode 100644 index 0000000000000..04c63ce367891 --- /dev/null +++ b/src/tests/Directory.Merged.props @@ -0,0 +1,8 @@ + + + true + false + + $(MSBuildProjectName.Replace('_il_d', '').Replace('_il_r', '')) + + diff --git a/src/tests/JIT/Directed/Directory.Build.props b/src/tests/JIT/Directed/Directory.Build.props index 3d7aacef4e4fb..608affd337da0 100644 --- a/src/tests/JIT/Directed/Directory.Build.props +++ b/src/tests/JIT/Directed/Directory.Build.props @@ -1,13 +1,7 @@ - - - false - - $(MSBuildProjectName.Replace('_il_d', '').Replace('_il_r', '')) - - - + + true diff --git a/src/tests/JIT/HardwareIntrinsics/Directory.Build.props b/src/tests/JIT/HardwareIntrinsics/Directory.Build.props index 4afc73e25b8a3..81ddb5af5a309 100644 --- a/src/tests/JIT/HardwareIntrinsics/Directory.Build.props +++ b/src/tests/JIT/HardwareIntrinsics/Directory.Build.props @@ -1,8 +1,5 @@ - - false - - + diff --git a/src/tests/JIT/HardwareIntrinsics/General/ConstantFolding/StaticReadonlySimd.cs b/src/tests/JIT/HardwareIntrinsics/General/ConstantFolding/StaticReadonlySimd.cs index e07425d7939ea..df3b79a507774 100644 --- a/src/tests/JIT/HardwareIntrinsics/General/ConstantFolding/StaticReadonlySimd.cs +++ b/src/tests/JIT/HardwareIntrinsics/General/ConstantFolding/StaticReadonlySimd.cs @@ -6,10 +6,12 @@ using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; using System.Threading; +using Xunit; -class StaticReadonlySimd +public class StaticReadonlySimd { - static int Main() + [Fact] + public static void TestEntryPoint() { for (int i = 0; i < 100; i++) { @@ -17,7 +19,6 @@ static int Main() Test(); Thread.Sleep(15); } - return 100; } static readonly Vector2 v1 = new Vector2(-1.0f, 2.0f); diff --git a/src/tests/JIT/HardwareIntrinsics/General/ConstantFolding/StaticReadonlySimd.csproj b/src/tests/JIT/HardwareIntrinsics/General/ConstantFolding/StaticReadonlySimd.csproj index 9d5af3bce3d89..b38e191bc3652 100644 --- a/src/tests/JIT/HardwareIntrinsics/General/ConstantFolding/StaticReadonlySimd.csproj +++ b/src/tests/JIT/HardwareIntrinsics/General/ConstantFolding/StaticReadonlySimd.csproj @@ -1,6 +1,7 @@ - Exe + + true True diff --git a/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64.cs b/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64.cs index 2251f0cd2ab1f..15a8d3d87740f 100644 --- a/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64.cs +++ b/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64.cs @@ -7,15 +7,17 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using Xunit; namespace IntelHardwareIntrinsicTest { - class Program + public class Program { const int Pass = 100; const int Fail = 0; - static unsafe int Main() + [Fact] + public static unsafe int TestEntryPoint() { int testResult = X86Serialize.X64.IsSupported ? Pass : Fail; diff --git a/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64_r.csproj index 59c9556630eed..a5450ff3e249e 100644 --- a/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64_r.csproj +++ b/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64_r.csproj @@ -1,6 +1,5 @@ - Exe true diff --git a/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64_ro.csproj index 60aa0fc71e28b..cb69680838319 100644 --- a/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64_ro.csproj +++ b/src/tests/JIT/HardwareIntrinsics/X86/X86Serialize_X64/Serialize.X64_ro.csproj @@ -1,6 +1,5 @@ - Exe true diff --git a/src/tests/JIT/IL_Conformance/Directory.Build.props b/src/tests/JIT/IL_Conformance/Directory.Build.props index c8714a2e3b971..4d1258218b4a0 100644 --- a/src/tests/JIT/IL_Conformance/Directory.Build.props +++ b/src/tests/JIT/IL_Conformance/Directory.Build.props @@ -1,10 +1,6 @@ - - - false - - + diff --git a/src/tests/JIT/Methodical/Directory.Build.props b/src/tests/JIT/Methodical/Directory.Build.props index 10fa02939e9cd..02a2c0eb2f6b6 100644 --- a/src/tests/JIT/Methodical/Directory.Build.props +++ b/src/tests/JIT/Methodical/Directory.Build.props @@ -1,13 +1,7 @@ - - - false - - $(MSBuildProjectName.Replace('_il_d', '').Replace('_il_r', '')) - - - + + true diff --git a/src/tests/JIT/Regression/Directory.Build.props b/src/tests/JIT/Regression/Directory.Build.props index d8fc762ff474c..fd98cb087403e 100644 --- a/src/tests/JIT/Regression/Directory.Build.props +++ b/src/tests/JIT/Regression/Directory.Build.props @@ -1,11 +1,6 @@ - - false - - $(MSBuildProjectName.Replace('_il_d', '').Replace('_il_r', '')) - - + diff --git a/src/tests/Loader/classloader/TypeGeneratorTests/Directory.Build.props b/src/tests/Loader/classloader/TypeGeneratorTests/Directory.Build.props index 11d4730d4f949..3f13642cca802 100644 --- a/src/tests/Loader/classloader/TypeGeneratorTests/Directory.Build.props +++ b/src/tests/Loader/classloader/TypeGeneratorTests/Directory.Build.props @@ -1,11 +1,7 @@ - - - false - - - + + true diff --git a/src/tests/baseservices/threading/Directory.Build.props b/src/tests/baseservices/threading/Directory.Build.props index 10fa02939e9cd..02a2c0eb2f6b6 100644 --- a/src/tests/baseservices/threading/Directory.Build.props +++ b/src/tests/baseservices/threading/Directory.Build.props @@ -1,13 +1,7 @@ - - - false - - $(MSBuildProjectName.Replace('_il_d', '').Replace('_il_r', '')) - - - + + true diff --git a/src/tests/reflection/ldtoken/byrefs.il b/src/tests/reflection/ldtoken/byrefs.il index 6f6d2ba0c9c5a..b10808684d48f 100644 --- a/src/tests/reflection/ldtoken/byrefs.il +++ b/src/tests/reflection/ldtoken/byrefs.il @@ -80,12 +80,12 @@ } } -.class private auto ansi beforefieldinit MyType1 +.class private auto ansi sealed beforefieldinit MyType1 extends [mscorlib]System.ValueType { } -.class private auto ansi beforefieldinit MyType2 +.class private auto ansi sealed beforefieldinit MyType2 extends [mscorlib]System.ValueType { }