Skip to content

Commit

Permalink
Merge branch 'main' into convert-unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Apr 23, 2024
2 parents f348707 + 40bc2d8 commit 4c64467
Show file tree
Hide file tree
Showing 516 changed files with 16,941 additions and 11,688 deletions.
24 changes: 13 additions & 11 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,22 @@
- eng/native/configurecompiler.cmake
- eng/native/build-commons.sh
- src/native/libs/build-native.sh
- src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs
- src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs
- src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
- src/mono/mono/tools/offsets-tool/offsets-tool.py
- src/mono/msbuild/apple/build/AppleBuild.targets
- src/installer/pkg/sfx/bundle/shared-framework-distribution-template-x64.xml
- src/installer/pkg/sfx/bundle/shared-framework-distribution-template-arm64.xml
- src/tasks/AotCompilerTask/MonoAOTCompiler.props
- src/tasks/AppleAppBuilder/Xcode.cs
- src/tasks/MobileBuildTasks/Apple/AppleProject.cs
- dotnet/installer repo > src/redist/targets/GeneratePKG.targets
-->
<AndroidApiLevelMin>21</AndroidApiLevelMin>
<iOSVersionMin>11.0</iOSVersionMin>
<tvOSVersionMin>11.0</tvOSVersionMin>
<macOSVersionMin>10.15</macOSVersionMin>
<macOSVersionMin Condition="('$(TargetOS)' == 'osx' or '$(TargetOS)' == 'maccatalyst') and '$(TargetArchitecture)' == 'arm64'">11.0</macOSVersionMin>
<iOSVersionMin>12.2</iOSVersionMin>
<tvOSVersionMin>12.2</tvOSVersionMin>
<macOSVersionMin>12.0</macOSVersionMin>
<MacCatalystVersionMin>15.0</MacCatalystVersionMin>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -397,12 +401,10 @@
<PropertyGroup Condition="$(MSBuildProjectFullPath.Contains('$([System.IO.Path]::DirectorySeparatorChar)tests$([System.IO.Path]::DirectorySeparatorChar)'))">
<IsTestProject Condition="$(MSBuildProjectName.EndsWith('.UnitTests')) or $(MSBuildProjectName.EndsWith('.Tests'))">true</IsTestProject>
<IsTrimmingTestProject Condition="$(MSBuildProjectName.EndsWith('.TrimmingTests'))">true</IsTrimmingTestProject>
<IsNativeAotTestProject Condition="$(MSBuildProjectName.EndsWith('.NativeAotTests'))">true</IsNativeAotTestProject>
<IsPublishedAppTestProject Condition="'$(IsTrimmingTestProject)' == 'true' or '$(IsNativeAotTestProject)' == 'true'">true</IsPublishedAppTestProject>
<IsTestSupportProject Condition="'$(IsTestProject)' != 'true' and '$(IsPublishedAppTestProject)' != 'true'">true</IsTestSupportProject>
<IsTestSupportProject Condition="'$(IsTestProject)' != 'true' and '$(IsTrimmingTestProject)' != 'true'">true</IsTestSupportProject>

<!-- Treat test assemblies as non-shipping (do not publish or sign them). -->
<IsShipping Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true' or '$(IsPublishedAppTestProject)' == 'true'">false</IsShipping>
<IsShipping Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true' or '$(IsTrimmingTestProject)' == 'true'">false</IsShipping>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -413,7 +415,7 @@
'$(IsReferenceAssemblyProject)' != 'true' and
'$(IsGeneratorProject)' != 'true' and
'$(IsTestProject)' != 'true' and
'$(IsPublishedAppTestProject)' != 'true' and
'$(IsTrimmingTestProject)' != 'true' and
'$(IsTestSupportProject)' != 'true' and
'$(UsingMicrosoftDotNetSharedFrameworkSdk)' != 'true' and
'$(MSBuildProjectExtension)' != '.pkgproj' and
Expand Down Expand Up @@ -464,7 +466,7 @@
</PropertyGroup>

<!-- Warnings that should be disabled in our test projects. -->
<PropertyGroup Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true' or '$(IsPublishedAppTestProject)' == 'true'">
<PropertyGroup Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true' or '$(IsTrimmingTestProject)' == 'true'">
<!-- we need to re-enable BinaryFormatter within test projects since some tests exercise these code paths to ensure compat -->
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
<!-- don't warn on usage of BinaryFormatter or legacy serialization infrastructure from test projects -->
Expand Down
4 changes: 2 additions & 2 deletions docs/design/datacontracts/contract-descriptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ struct DotNetRuntimeContractDescriptor
uint32_t flags;
uint32_t descriptor_size;
const char *descriptor;
uint32_t aux_data_count;
uint32_t pointer_data_count;
uint32_t pad0;
uintptr_t *aux_data;
uintptr_t *pointer_data;
};
```

Expand Down
4 changes: 4 additions & 0 deletions docs/design/datacontracts/data/empty.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// the empty baseline data descriptor
{
"version": 0
}
1 change: 1 addition & 0 deletions docs/project/list-of-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute
| __`SYSLIB0052`__ | This API supports obsolete mechanisms for Regex extensibility. It is not supported. |
| __`SYSLIB0053`__ | AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size. |
| __`SYSLIB0054`__ | Thread.VolatileRead and Thread.VolatileWrite are obsolete. Use Volatile.Read or Volatile.Write respectively instead. |
| __`SYSLIB0055`__ | The underlying hardware instruction does not perform a signed saturate narrowing operation, and it always returns an unsigned result. Use the unsigned overload instead. |

## Analyzer Warnings

Expand Down
38 changes: 28 additions & 10 deletions docs/workflow/testing/coreclr/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
* [Building an Individual Test](#building-an-individual-test)
* [Building a Test Directory](#building-a-test-directory)
* [Building a Test Subtree](#building-a-test-subtree)
* [Test Executors](#test-executors)
* [The Standalone Test Runner and Build Time Test Filtering](#the-standalone-test-runner-and-build-time-test-filtering)
* [Building all tests with the Standalone Runner](#building-all-tests-with-the-standalone-runner)
* [Building C++/CLI Native Test Components Against the Live Ref Assemblies](#building-ccli-native-test-components-against-the-live-ref-assemblies)
* [Test Priorities](#test-priorities)
* [Running the Tests](#running-the-tests)
* [Running Individual Tests](#running-individual-tests)
* [Tests Without a Main Method](#tests-without-a-main-method)
* [PAL Tests (macOS and Linux only)](#pal-tests-macos-and-linux-only)
* [Building PAL Tests](#building-pal-tests)
* [Running PAL Tests](#running-pal-tests)
Expand Down Expand Up @@ -62,7 +64,7 @@ This example assumes you built CoreCLR on _Debug_ mode and the Libraries on _Rel

The following subsections will explain how to segment the test suite according to your needs. There are three main scopes of building tests:

* Individual Test
* Individual Test Runner
* Full Directory
* Entire Subtree

Expand All @@ -83,19 +85,19 @@ To build an individual test, you have to pass the `-test` flag along with the pa
On Windows:

```cmd
.\src\tests\build.cmd test JIT\Intrinsics\MathRoundDouble_ro.csproj test JIT\Intrinsics\MathFloorDouble_ro.csproj
.\src\tests\build.cmd test JIT\Methodical\Methodical_d1.csproj test JIT\JIT_ro.csproj
```

On macOS and Linux:

```bash
./src/tests/build.sh -test:JIT/Intrinsics/MathRoundDouble_ro.csproj -test:JIT/Intrinsics/MathFloorDouble_ro.csproj
./src/tests/build.sh -test:JIT/Methodical/Methodical_d1.csproj -test:JIT/JIT_ro.csproj
```

Alternatively, you can call _build_ directly using the `dotnet.cmd/dotnet.sh` script at the root of the repo and pass all arguments directly yourself:

```bash
./dotnet.sh build -c <Your Configuration> src/tests/path/to/test/csproj
./dotnet.sh build -c <Your Configuration> src/tests/path/to/test.csproj
```

### Building a Test Directory
Expand All @@ -105,13 +107,13 @@ To build all the tests contained in an individual directory, you have to pass th
On Windows:

```cmd
.\src\tests\build.cmd dir JIT\Methodical\Arrays\lcs dir JIT\Methodical\cctor\misc\Desktop
.\src\tests\build.cmd dir JIT dir Loader
```

On macOS and Linux:

```bash
./src/tests/build.sh -dir:JIT/Methodical/Arrays/lcs -dir:JIT/Methodical/cctor/misc/Desktop
./src/tests/build.sh -dir:JIT -dir:Loader
```

### Building a Test Subtree
Expand All @@ -130,6 +132,24 @@ On macOS and Linux:
./src/tests/build.sh -tree:baseservices/exceptions -tree:JIT/Methodical
```

### Test Executors

We have multiple different mechanisms of executing tests.

Our test entrypoints are generally what we call "merged test runners", as they provide an executable runner project for multiple different test assemblies. These projects can be identified by the `<Import Project="$(TestSourceDir)MergedTestRunner.targets" />` line in their .csproj file. These projects provide a simple experience for running tests. When executing a merged runner project, it will run each test sequentially and record if it passes or fails in an xunit results file. The merged test runner support runtime test filtering. If specified, the first argument to the test runner is treated as a `dotnet test --filter` argument following the xUnit rules in their documentation. Today, the runner only supports the simple form, a substring of a test's fully-qualified name, in the format `Namespace.ContainingTypeName.TypeName.Method`. If support for further filtering options is desired, please open an issue requesting it.

Some tests need to be run in their own process as they interact with global process state, they have a custom test entrypoint, or they interact poorly with other tests in the same process. These tests are generally marked with `<RequiresProcessIsolation>true</RequiresProcessIsolation>` in their project files. These tests can be run directly, but they can also be invoked through their corresponding merged test runner. The merged test runner will invoke them as a subprocess in the same manner as if they were run individually.

#### The Standalone Test Runner and Build Time Test Filtering

Sometimes you may want to run a test with the least amount of code before actually executing the test. In addition to the merged test runner, we have another runner mode known as the "Standalone" runner. This runner is used by default in tests that require process isolation. This runner consists of a simple `try-catch` around executing each test sequentially, with no test results file or runtime test filtering.

To filter tests on a merged test runner built as standalone, you can set the `TestFilter` property, like so: `./dotnet.sh build -c Checked src/tests/path/to/test.csproj -p:TestFilter=SubstringOfFullyQualifiedTestName`. This mechanism supports the same filtering as the runtime test filtering. Using this mechanism will allow you to skip individual test cases at build time instead of at runtime.

#### Building all tests with the Standalone Runner

If you wish to use the Standalone runner described in the [previous section](#the-standalone-test-runner-and-build-time-test-filtering), you can set the `BuildAllTestsAsStandalone` environment variable to `true` when invoking the `./src/tests/build.sh` or `./src/tests/build.cmd` scripts (for example, `export BuildAllTestsAsStandalone=true` or `set BuildAllTestsAsStandalone=true`). This will build all tests that are not directly in a merged test runner's project as separate executable tests and build only the tests that are compiled into the runner directly. If a runner has no tests that are built directly into the runner, then it will be excluded.

### Building C++/CLI Native Test Components Against the Live Ref Assemblies

By default, the _C++/CLI_ native test components build against the _ref pack_ from the SDK specified in the `global.json` file in the root of the repository. To build these components against the _ref assemblies_ produced in the build, pass the `-cmakeargs -DCPP_CLI_LIVE_REF_ASSEMBLIES=1` parameters to the test build. For example:
Expand Down Expand Up @@ -233,9 +253,7 @@ cd path/to/JIT/Intrinsics/MathRoundDouble_ro
./MathRoundDouble_ro.sh -coreroot=<repo_root>/artifacts/tests/coreclr/<OS>.<Arch>.<Configuration>/Tests/Core_Root
```

#### Tests Without a Main Method

Guide on how to run tests without a `Main()` Method coming soon!
If you want to run an individual test from a test runner, use the filtering capabilities described in the [Test Executors section](#test-executors).

### PAL Tests (macOS and Linux only)

Expand Down
1 change: 1 addition & 0 deletions eng/DotNetBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<InnerBuildArgs Condition="'$(SourceBuiltNonShippingPackagesDir)' != ''">$(InnerBuildArgs) /p:SourceBuiltNonShippingPackagesDir=$(SourceBuiltNonShippingPackagesDir)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(SourceBuiltAssetManifestsDir)' != ''">$(InnerBuildArgs) /p:SourceBuiltAssetManifestsDir=$(SourceBuiltAssetManifestsDir)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(SourceBuiltSymbolsDir)' != ''">$(InnerBuildArgs) /p:SourceBuiltSymbolsDir=$(SourceBuiltSymbolsDir)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(GitHubRepositoryName)' != ''">$(InnerBuildArgs) /p:GitHubRepositoryName=$(GitHubRepositoryName)</InnerBuildArgs>
</PropertyGroup>
</Target>

Expand Down
8 changes: 8 additions & 0 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@
<SubsetName Include="Tools.ILLink" Description="The projects that produce illink and analyzer tools for trimming." />
<SubsetName Include="Tools.ILLinkTests" OnDemand="true" Description="Unit tests for the tools.illink subset." />

<SubsetName Include="Tools.CdacReaderTests" OnDemand="true" Description="Units tests for the cDAC reader." />

<!-- Host -->
<SubsetName Include="Host" Description="The .NET hosts, packages, hosting libraries, and tests. Equivalent to: $(DefaultHostSubsets)" />
<SubsetName Include="Host.Native" Description="The .NET hosts." />
Expand Down Expand Up @@ -358,6 +360,8 @@
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_inbuild.csproj" Category="clr" />

<ProjectToBuild Condition="'$(TargetOS)' == 'windows' or ('$(TargetOS)' == 'linux' and ('$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64')) or '$(TargetOS)' == 'osx'" Include="$(CoreClrProjectRoot)tools\SuperFileCheck\SuperFileCheck.csproj" Category="clr" />

<ProjectToBuild Include="$(CoreClrProjectRoot)tools\cdac-build-tool\cdac-build-tool.csproj" Category="clr" />
</ItemGroup>

<ItemGroup Condition="$(_subset.Contains('+clr.toolstests+'))">
Expand All @@ -369,6 +373,10 @@
Test="true" Category="clr" Condition="'$(DotNetBuildSourceOnly)' != 'true' and '$(NativeAotSupported)' == 'true'"/>
</ItemGroup>

<ItemGroup Condition="$(_subset.Contains('+tools.cdacreadertests+'))">
<ProjectToBuild Include="$(SharedNativeRoot)managed\cdacreader\tests\Microsoft.Diagnostics.DataContractReader.Tests.csproj" Test="true" Category="tools"/>
</ItemGroup>

<ItemGroup Condition="$(_subset.Contains('+tools.illink+'))">
<ProjectToBuild Include="$(ToolsProjectRoot)illink\src\linker\Mono.Linker.csproj" Category="tools" />
<ProjectToBuild Include="$(ToolsProjectRoot)illink\src\ILLink.Tasks\ILLink.Tasks.csproj" Category="tools" />
Expand Down
Loading

0 comments on commit 4c64467

Please sign in to comment.