Skip to content

Commit d2b9703

Browse files
authored
[Apple mobile] Use merged runners for runtime tests (#107118)
1 parent 27f045d commit d2b9703

File tree

49 files changed

+483
-412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+483
-412
lines changed

eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ parameters:
1919
variables: {}
2020
pool: ''
2121
dependsOn: []
22-
compileOnHelix: false
23-
interpreter: false
22+
extraHelixArguments: ''
2423
buildAllTestsAsStandalone: false
2524
#arcade-specific parameters
2625
condition: always()
@@ -84,56 +83,41 @@ steps:
8483
env:
8584
__MonoToolPrefix: aarch64-linux-gnu-
8685

87-
# Checks the value of the compileOnHelix parameter
88-
# and if set invokes libraries pipeline for AOT on Helix
89-
- ${{ if eq(parameters.compileOnHelix, 'true') }}:
90-
- template: /eng/pipelines/libraries/helix.yml
91-
parameters:
92-
osGroup: ${{ parameters.osGroup }}
93-
runtimeFlavor: ${{ parameters.runtimeFlavor }}
94-
archType: ${{ parameters.archType }}
95-
targetRid: ${{ parameters.targetRid }}
96-
buildConfig: ${{ parameters.buildConfig }}
97-
interpreter: ${{ parameters.interpreter }}
98-
testRunNamePrefixSuffix: ${{ parameters.testRunNamePrefixSuffix }}
99-
extraHelixArguments: ${{ parameters.extraHelixArguments }}
100-
helixQueues: ${{ parameters.helixQueues }}
101-
creator: ${{ parameters.creator }}
102-
- ${{ else }}:
103-
- template: /eng/pipelines/common/templates/runtimes/send-to-helix-step.yml
104-
parameters:
105-
displayName: Send tests to Helix
106-
buildConfig: $(buildConfigUpper)
107-
archType: ${{ parameters.archType }}
108-
osGroup: ${{ parameters.osGroup }}
109-
osSubgroup: ${{ parameters.osSubgroup}}
110-
coreClrRepoRoot: $(Build.SourcesDirectory)/src/coreclr
111-
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
112-
runtimeFlavor: ${{ parameters.runtimeFlavor }}
113-
runtimeVariant: ${{ parameters.runtimeVariant }}
86+
- template: /eng/pipelines/common/templates/runtimes/send-to-helix-step.yml
87+
parameters:
88+
displayName: Send tests to Helix
89+
buildConfig: $(buildConfigUpper)
90+
archType: ${{ parameters.archType }}
91+
osGroup: ${{ parameters.osGroup }}
92+
osSubgroup: ${{ parameters.osSubgroup}}
93+
coreClrRepoRoot: $(Build.SourcesDirectory)/src/coreclr
94+
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
95+
runtimeFlavor: ${{ parameters.runtimeFlavor }}
96+
runtimeVariant: ${{ parameters.runtimeVariant }}
11497

115-
${{ if eq(variables['System.TeamProject'], 'internal') }}:
116-
# Access token variable for internal project from the
117-
# DotNet-HelixApi-Access variable group
118-
helixAccessToken: $(HelixApiAccessToken)
119-
${{ else }}:
120-
creator: $(Build.DefinitionName)
98+
${{ if eq(variables['System.TeamProject'], 'internal') }}:
99+
# Access token variable for internal project from the
100+
# DotNet-HelixApi-Access variable group
101+
helixAccessToken: $(HelixApiAccessToken)
102+
${{ else }}:
103+
creator: $(Build.DefinitionName)
121104

122-
helixBuild: $(Build.BuildNumber)
123-
helixSource: $(_HelixSource)
124-
${{ if ne(parameters.readyToRun, true) }}:
125-
helixType: 'test/functional/cli/'
105+
helixBuild: $(Build.BuildNumber)
106+
helixSource: $(_HelixSource)
107+
${{ if ne(parameters.readyToRun, true) }}:
108+
helixType: 'test/functional/cli/'
126109

127-
helixQueues: ${{ parameters.helixQueues }}
128-
# This tests whether an array is empty
129-
${{ if eq(join('', parameters.helixQueues), '') }}:
130-
condition: false
131-
publishTestResults: true
132-
timeoutPerTestInMinutes: $(timeoutPerTestInMinutes)
133-
timeoutPerTestCollectionInMinutes: $(timeoutPerTestCollectionInMinutes)
134-
runCrossGen2: ${{ eq(parameters.readyToRun, true) }}
135-
compositeBuildMode: ${{ parameters.compositeBuildMode }}
136-
runInUnloadableContext: ${{ parameters.runInUnloadableContext }}
137-
nativeAotTest: ${{ parameters.nativeAotTest }}
138-
helixProjectArguments: '$(Build.SourcesDirectory)/src/tests/Common/helixpublishwitharcade.proj'
139-
scenarios: ${{ parameters.scenarios }}
110+
helixQueues: ${{ parameters.helixQueues }}
111+
# This tests whether an array is empty
112+
${{ if eq(join('', parameters.helixQueues), '') }}:
113+
condition: false
114+
publishTestResults: true
115+
timeoutPerTestInMinutes: $(timeoutPerTestInMinutes)
116+
timeoutPerTestCollectionInMinutes: $(timeoutPerTestCollectionInMinutes)
117+
runCrossGen2: ${{ eq(parameters.readyToRun, true) }}
118+
compositeBuildMode: ${{ parameters.compositeBuildMode }}
119+
runInUnloadableContext: ${{ parameters.runInUnloadableContext }}
120+
nativeAotTest: ${{ parameters.nativeAotTest }}
121+
helixProjectArguments: '$(Build.SourcesDirectory)/src/tests/Common/helixpublishwitharcade.proj'
122+
extraHelixArguments: ${{ parameters.extraHelixArguments }}
123+
scenarios: ${{ parameters.scenarios }}

eng/pipelines/common/templates/runtimes/send-to-helix-step.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ parameters:
1919
runCrossGen2: ''
2020
compositeBuildMode: false
2121
helixProjectArguments: ''
22+
extraHelixArguments: ''
2223
runInUnloadableContext: ''
2324
tieringTest: ''
2425
hotColdSplitting: ''
@@ -38,7 +39,7 @@ steps:
3839
- template: send-to-helix-inner-step.yml
3940
parameters:
4041
osGroup: ${{ parameters.osGroup }}
41-
sendParams: ${{ parameters.helixProjectArguments }} ${{ parameters.msbuildParallelism }} /bl:$(Build.SourcesDirectory)/artifacts/log/SendToHelix.binlog /p:TargetArchitecture=${{ parameters.archType }} /p:TargetOS=${{ parameters.osGroup }} /p:TargetOSSubgroup=${{ parameters.osSubgroup }} /p:Configuration=${{ parameters.buildConfig }}
42+
sendParams: ${{ parameters.helixProjectArguments }} ${{ parameters.msbuildParallelism }} /bl:$(Build.SourcesDirectory)/artifacts/log/SendToHelix.binlog /p:TargetArchitecture=${{ parameters.archType }} /p:TargetOS=${{ parameters.osGroup }} /p:TargetOSSubgroup=${{ parameters.osSubgroup }} /p:Configuration=${{ parameters.buildConfig }} ${{ parameters.extraHelixArguments }}
4243
condition: and(succeeded(), ${{ parameters.condition }})
4344
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
4445
displayName: ${{ parameters.displayName }}

eng/pipelines/extra-platforms/runtime-extra-platforms-ioslike.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ jobs:
9191
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
9292
parameters:
9393
creator: dotnet-bot
94+
testBuildArgs: /p:DevTeamProvisioning=- /p:RunAOTCompilation=true /p:MonoForceInterpreter=true /p:BuildTestsOnHelix=true
9495
compileOnHelix: true
95-
interpreter: true
96-
testBuildArgs: /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true /p:MonoForceInterpreter=true /p:BuildTestsOnHelix=true
9796
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
9897
extraHelixArguments: /p:NeedsToBuildAppsOnHelix=true
9998

eng/pipelines/extra-platforms/runtime-extra-platforms-ioslikesimulator.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ jobs:
8989
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
9090
parameters:
9191
creator: dotnet-bot
92+
testBuildArgs: /p:DevTeamProvisioning=- /p:RunAOTCompilation=true /p:MonoForceInterpreter=true /p:BuildTestsOnHelix=true
9293
compileOnHelix: true
93-
interpreter: true
94-
testBuildArgs: /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true /p:MonoForceInterpreter=true /p:BuildTestsOnHelix=true
9594
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
9695
extraHelixArguments: /p:NeedsToBuildAppsOnHelix=true
9796

eng/testing/tests.ioslike.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
<_AppleBuildCommand Condition="'$(IncludesTestRunner)' == 'true'">apple test</_AppleBuildCommand>
3030
<_AppleBuildCommand Condition="'$(IncludesTestRunner)' != 'true'">apple run</_AppleBuildCommand>
31+
3132
<_AppleExpectedExitCode Condition="'$(ExpectedExitCode)' != ''">--expected-exit-code $(ExpectedExitCode)</_AppleExpectedExitCode>
3233
<_AfterBuildCommands>
3334
mv $XHARNESS_OUT/AOTBuild.binlog &quot;$HELIX_WORKITEM_UPLOAD_ROOT&quot;
@@ -178,7 +179,7 @@
178179
<HybridGlobalization>true</HybridGlobalization>
179180
<IncludesTestRunner Condition="'$(IncludesTestRunner)' == ''">true</IncludesTestRunner>
180181
<Optimized Condition="'$(Configuration)' == 'Release'">true</Optimized>
181-
<MainLibraryFileName Condition="'$(MainLibraryFileName)' == '' and '$(IsRuntimeTests)' != 'true' and '$(IncludesTestRunner)' == 'true'">AppleTestRunner.dll</MainLibraryFileName>
182+
<MainLibraryFileName Condition="'$(MainLibraryFileName)' == '' and '$(IncludesTestRunner)' == 'true'">AppleTestRunner.dll</MainLibraryFileName>
182183

183184
<AppleBuildDir>$(PublishDir)</AppleBuildDir>
184185
<AppleBundleDir>$(BundleDir)</AppleBundleDir>

src/mono/msbuild/apple/build/AppleBuild.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@
4949
<Import Condition="'$(UseNativeAOTRuntime)' != 'true' and '$(UseMonoRuntime)' != 'false'" Project="$(_CommonTargetsDir)CommonMobileBuild.props" />
5050
<Import Condition="'$(UseNativeAOTRuntime)' != 'true' and '$(UseMonoRuntime)' != 'false'" Project="$(_CommonTargetsDir)RuntimeComponentManifest.targets" />
5151
<Import Condition="'$(UseNativeAOTRuntime)' != 'true' and ('$(UseMonoRuntime)' != 'false' and '$(RunAOTCompilation)' == 'true')" Project="$(_CommonTargetsDir)MonoAOTCompiler.props" />
52-
</Project>
52+
</Project>

src/tests/Common/CoreCLRTestLibrary/PlatformDetection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,6 @@ public static bool IsNonZeroLowerBoundArraySupported
6464
// These platforms have not had their infrastructure updated to support native test assets.
6565
public static bool PlatformDoesNotSupportNativeTestAssets =>
6666
OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS() || OperatingSystem.IsAndroid() || OperatingSystem.IsBrowser() || OperatingSystem.IsWasi();
67+
public static bool IsAppleMobile => OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS() || OperatingSystem.IsMacCatalyst();
6768
}
6869
}

src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private static void AddRunnerSource(SourceProductionContext context, ImmutableAr
259259
{
260260
if (targetOS?.ToLowerInvariant() is "ios" or "iossimulator" or "tvos" or "tvossimulator" or "maccatalyst" or "android" or "browser")
261261
{
262-
context.AddSource("XHarnessRunner.g.cs", GenerateXHarnessTestRunner(methods, aliasMap, assemblyName));
262+
context.AddSource("XHarnessRunner.g.cs", GenerateXHarnessTestRunner(methods, aliasMap, assemblyName, targetOS));
263263
}
264264
else
265265
{
@@ -431,7 +431,7 @@ private static string GenerateFullTestRunner(ImmutableArray<ITestInfo> testInfos
431431
return builder.GetCode();
432432
}
433433

434-
private static string GenerateXHarnessTestRunner(ImmutableArray<ITestInfo> testInfos, ImmutableDictionary<string, string> aliasMap, string assemblyName)
434+
private static string GenerateXHarnessTestRunner(ImmutableArray<ITestInfo> testInfos, ImmutableDictionary<string, string> aliasMap, string assemblyName, string? targetOS)
435435
{
436436
// For simplicity, we'll use top-level statements for the generated Main method.
437437
CodeBuilder builder = new();
@@ -440,6 +440,18 @@ private static string GenerateXHarnessTestRunner(ImmutableArray<ITestInfo> testI
440440
builder.AppendLine("XUnitWrapperLibrary.TestSummary summary;");
441441
builder.AppendLine("System.Diagnostics.Stopwatch stopwatch;");
442442
builder.AppendLine("XUnitWrapperLibrary.TestOutputRecorder outputRecorder;");
443+
if (targetOS?.ToLowerInvariant() is "ios" or "iossimulator" or "tvos" or "tvossimulator" or "maccatalyst")
444+
{
445+
builder.AppendLine("string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);");
446+
builder.AppendLine($@"string tempLogPath = System.IO.Path.Combine(documentsPath, ""{assemblyName}.templog.xml"");");
447+
builder.AppendLine($@"string testStatsPath = System.IO.Path.Combine(documentsPath, ""{assemblyName}.testStats.csv"");");
448+
}
449+
else
450+
{
451+
builder.AppendLine($@"string tempLogPath = ""{assemblyName}.templog.xml"";");
452+
builder.AppendLine($@"string testStatsPath = ""{assemblyName}.testStats.csv"";");
453+
}
454+
443455
builder.AppendLine();
444456

445457
builder.AppendLine("try");
@@ -468,16 +480,16 @@ private static string GenerateXHarnessTestRunner(ImmutableArray<ITestInfo> testI
468480

469481
using (builder.NewBracesScope())
470482
{
471-
builder.AppendLine($@"if (System.IO.File.Exists(""{assemblyName}.tempLog.xml""))");
483+
builder.AppendLine("if (System.IO.File.Exists(tempLogPath))");
472484
using (builder.NewBracesScope())
473485
{
474-
builder.AppendLine($@"System.IO.File.Delete(""{assemblyName}.tempLog.xml"");");
486+
builder.AppendLine("System.IO.File.Delete(tempLogPath);");
475487
}
476488

477-
builder.AppendLine($@"if (System.IO.File.Exists(""{assemblyName}.testStats.csv""))");
489+
builder.AppendLine("if (System.IO.File.Exists(testStatsPath))");
478490
using (builder.NewBracesScope())
479491
{
480-
builder.AppendLine($@"System.IO.File.Delete(""{assemblyName}.testStats.csv"");");
492+
builder.AppendLine("System.IO.File.Delete(testStatsPath);");
481493
}
482494
builder.AppendLine();
483495

@@ -495,8 +507,8 @@ private static string GenerateXHarnessTestRunner(ImmutableArray<ITestInfo> testI
495507
builder.AppendLine("Initialize();");
496508

497509
// Open the stream writer for the temp log.
498-
builder.AppendLine($@"using (System.IO.StreamWriter tempLogSw = System.IO.File.AppendText(""{assemblyName}.templog.xml""))");
499-
builder.AppendLine($@"using (System.IO.StreamWriter statsCsvSw = System.IO.File.AppendText(""{assemblyName}.testStats.csv""))");
510+
builder.AppendLine($"using (System.IO.StreamWriter tempLogSw = System.IO.File.AppendText(tempLogPath))");
511+
builder.AppendLine($"using (System.IO.StreamWriter statsCsvSw = System.IO.File.AppendText(testStatsPath))");
500512
CodeBuilder testExecutorBuilder = new();
501513

502514
using (builder.NewBracesScope())

0 commit comments

Comments
 (0)