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

Stop supporting multiple targets in XHarness Helix SDK #7462

Merged
merged 7 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
<Uri>https://github.com/dotnet/arcade-services</Uri>
<Sha>cac955fe259cb611f6a29d09209bd717deb69037</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="1.0.0-prerelease.21271.1">
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="1.0.0-prerelease.21303.1">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>98970876f4d21e6da5198a5c41de51ab1101089f</Sha>
<Sha>debdb2b11d810cea0435f5d086c0bf17b3ee6402</Sha>
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="3.10.0-4.21273.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<MicrosoftDotNetSwaggerGeneratorMSBuildVersion>6.0.0-beta.21277.1</MicrosoftDotNetSwaggerGeneratorMSBuildVersion>
<XliffTasksVersion>1.0.0-beta.21277.1</XliffTasksVersion>
<MicrosoftDotNetMaestroTasksVersion>1.1.0-beta.21228.1</MicrosoftDotNetMaestroTasksVersion>
<MicrosoftDotNetXHarnessCLIVersion>1.0.0-prerelease.21271.1</MicrosoftDotNetXHarnessCLIVersion>
<MicrosoftDotNetXHarnessCLIVersion>1.0.0-prerelease.21303.1</MicrosoftDotNetXHarnessCLIVersion>
<MicrosoftSymbolUploaderBuildTaskVersion>1.1.156402</MicrosoftSymbolUploaderBuildTaskVersion>
<MicrosoftSymbolUploaderVersion>1.1.152002</MicrosoftSymbolUploaderVersion>
<MicrosoftNetSdkWorkloadManifestReaderVersion>6.0.100-preview.5.21254.11</MicrosoftNetSdkWorkloadManifestReaderVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void AppleXHarnessWorkItemIsCreated()

var command = workItem.GetMetadata("Command");
command.Should().Contain("System.Foo.app");
command.Should().Contain("--targets \"ios-device_13.5\"");
command.Should().Contain("--target \"ios-device_13.5\"");
command.Should().Contain("--timeout \"00:08:55\"");
command.Should().Contain("--launch-timeout \"00:02:33\"");

Expand Down Expand Up @@ -181,7 +181,7 @@ public void AreDependenciesRegistered()

private ITaskItem CreateAppBundle(
string path,
string targets,
string target,
string? workItemTimeout = null,
string? testTimeout = null,
string? launchTimeout = null,
Expand All @@ -191,7 +191,7 @@ private ITaskItem CreateAppBundle(
{
var mockBundle = new Mock<ITaskItem>();
mockBundle.SetupGet(x => x.ItemSpec).Returns(path);
mockBundle.Setup(x => x.GetMetadata(CreateXHarnessAppleWorkItems.MetadataNames.Targets)).Returns(targets);
mockBundle.Setup(x => x.GetMetadata(CreateXHarnessAppleWorkItems.MetadataNames.Target)).Returns(target);
mockBundle.Setup(x => x.GetMetadata(CreateXHarnessAppleWorkItems.MetadataNames.IncludesTestRunner)).Returns(includesTestRunner.ToString());

if (workItemTimeout != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private static ITaskItem CreateAppBundle(string path, string targets)
{
var mockBundle = new Mock<ITaskItem>();
mockBundle.SetupGet(x => x.ItemSpec).Returns(path);
mockBundle.Setup(x => x.GetMetadata(CreateXHarnessAppleWorkItems.MetadataNames.Targets)).Returns(targets);
mockBundle.Setup(x => x.GetMetadata(CreateXHarnessAppleWorkItems.MetadataNames.Target)).Returns(targets);
return mockBundle.Object;
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAppleWorkItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CreateXHarnessAppleWorkItems : XHarnessTaskBase

public static class MetadataNames
{
public const string Targets = "Targets";
public const string Target = "TestTarget";
public const string LaunchTimeout = "LaunchTimeout";
public const string IncludesTestRunner = "IncludesTestRunner";
public const string ResetSimulator = "ResetSimulator";
Expand Down Expand Up @@ -102,14 +102,14 @@ private async Task<ITaskItem> PrepareWorkItem(
var (testTimeout, workItemTimeout, expectedExitCode, customCommands) = ParseMetadata(appBundleItem);

// Validation of any metadata specific to iOS stuff goes here
if (!appBundleItem.TryGetMetadata(MetadataNames.Targets, out string targets))
if (!appBundleItem.TryGetMetadata(MetadataNames.Target, out string target))
{
Log.LogError($"'{MetadataNames.Targets}' metadata must be specified - " +
Log.LogError($"'{MetadataNames.Target}' metadata must be specified - " +
"expecting list of target device/simulator platforms to execute tests on (e.g. ios-simulator-64)");
return null;
}

targets = targets.ToLowerInvariant();
target = target.ToLowerInvariant();

// Optional timeout for the how long it takes for the app to be installed, booted and tests start executing
TimeSpan launchTimeout = s_defaultLaunchTimeout;
Expand Down Expand Up @@ -151,7 +151,7 @@ private async Task<ITaskItem> PrepareWorkItem(
customCommands = $"xharness apple {(includesTestRunner ? "test" : "run")} " +
"--app \"$app\" " +
"--output-directory \"$output_directory\" " +
"--targets \"$targets\" " +
"--target \"$target\" " +
"--timeout \"$timeout\" " +
(includesTestRunner
? $"--launch-timeout \"$launch_timeout\" "
Expand All @@ -163,7 +163,7 @@ private async Task<ITaskItem> PrepareWorkItem(
}

string appName = fileSystem.GetFileName(appBundleItem.ItemSpec);
string helixCommand = GetHelixCommand(appName, targets, testTimeout, launchTimeout, includesTestRunner, expectedExitCode, resetSimulator);
string helixCommand = GetHelixCommand(appName, target, testTimeout, launchTimeout, includesTestRunner, expectedExitCode, resetSimulator);
string payloadArchivePath = await CreateZipArchiveOfFolder(zipArchiveManager, fileSystem, appFolderPath, customCommands);

Log.LogMessage($"Creating work item with properties Identity: {workItemName}, Payload: {appFolderPath}, Command: {helixCommand}");
Expand All @@ -179,7 +179,7 @@ private async Task<ITaskItem> PrepareWorkItem(

private string GetHelixCommand(
string appName,
string targets,
string target,
TimeSpan testTimeout,
TimeSpan launchTimeout,
bool includesTestRunner,
Expand All @@ -188,7 +188,7 @@ private string GetHelixCommand(
=>
$"chmod +x {EntryPointScript} && ./{EntryPointScript} " +
$"--app \"{appName}\" " +
$"--targets \"{targets}\" " +
$"--target \"{target}\" " +
$"--timeout \"{testTimeout}\" " +
$"--launch-timeout \"{launchTimeout}\" " +
(includesTestRunner ? "--includes-test-runner " : string.Empty) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void AddProfilesToBundles(ITaskItem[] appBundles)

foreach (var appBundle in appBundles)
{
if (!appBundle.TryGetMetadata(CreateXHarnessAppleWorkItems.MetadataNames.Targets, out string bundleTargets))
if (!appBundle.TryGetMetadata(CreateXHarnessAppleWorkItems.MetadataNames.Target, out string bundleTargets))
{
_log.LogError("'Targets' metadata must be specified - " +
"expecting list of target device/simulator platforms to execute tests on (e.g. ios-simulator-64)");
Expand Down
18 changes: 9 additions & 9 deletions src/Microsoft.DotNet.Helix/Sdk/tools/xharness-runner/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ To execute .app bundles, declare one or more `XHarnessAppBundleToTest` items:
<ItemGroup>
<!-- Find all directories named *.app -->
<XHarnessAppBundleToTest Include="$([System.IO.Directory]::GetDirectories('$(TestArchiveTestsRoot)', '*.app', System.IO.SearchOption.AllDirectories))">
<Targets>ios-simulator-64_13.5</Targets>
<TestTarget>ios-simulator-64_13.5</TestTarget>
</XHarnessAppBundleToTest>
</ItemGroup>
```

The `<Targets>` metadata is a required configuration that tells XHarness which kind of device/Simulator to target.
Use the XHarness CLI help command to find more (see the `--targets` option).
The `<TestTarget>` metadata is a required configuration that tells XHarness which kind of device/Simulator to target.
Use the XHarness CLI help command to find more (see the `--target` option).

You can also specify some additional metadata that will help you configure the run better:

Expand Down Expand Up @@ -163,17 +163,17 @@ Example:
```xml
<ItemGroup>
<XHarnessAppBundleToTest Include="path\to\Some.iOS.app">
<Targets>ios-simulator-64</Targets>
<TestTarget>ios-simulator-64</TestTarget>
<WorkItemTimeout>00:12:00</WorkItemTimeout>
<CustomCommands>
set -e
deviceId=`xharness apple device $targets`
xharness apple install -t $targets --device "$deviceId" -o "$output_directory" --app=$app
deviceId=`xharness apple device $target`
xharness apple install -t $target --device "$deviceId" -o "$output_directory" --app=$app
set +e
result=0
xharness apple just-test -t $targets --device "$deviceId" -o "$output_directory" --app net.dot.Some.iOS --timeout 00:08:00
xharness apple just-test -t $target --device "$deviceId" -o "$output_directory" --app net.dot.Some.iOS --timeout 00:08:00
((result|=$?))
xharness apple uninstall -t $targets --device "$deviceId" -o "$output_directory" --app net.dot.Some.iOS
xharness apple uninstall -t $target --device "$deviceId" -o "$output_directory" --app net.dot.Some.iOS
((result|=$?))
exit $result
</CustomCommands>
Expand All @@ -187,7 +187,7 @@ When using `CustomCommands`, several variables will be defined for you for easie
- `$app` - path to the application
- `$output_directory` - path under which all files will be uploaded to Helix at the end of the job
- If a file named `testResults.xml` is found containing xUnit results, it will be uploaded back to Azure DevOps
- `$targets`, `$timeout`, `$launch_timeout`, `$expected_exit_code`, `$includes_test_runner` - parsed metadata defined on the original `XHarnessAppBundleToTest` MSBuild item
- `$target`, `$timeout`, `$launch_timeout`, `$expected_exit_code`, `$includes_test_runner` - parsed metadata defined on the original `XHarnessAppBundleToTest` MSBuild item

#### Variables defined for Android scenarios
Android is currently not supported - coming soon!
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

app=''
output_directory=''
targets=''
target=''
timeout=''
launch_timeout=''
xharness_cli_path=''
Expand All @@ -29,8 +29,8 @@ while [[ $# -gt 0 ]]; do
output_directory="$2"
shift
;;
--targets)
targets="$2"
--target)
target="$2"
shift
;;
--timeout)
Expand Down Expand Up @@ -77,8 +77,8 @@ if [ -z "$app" ]; then
die "App bundle path wasn't provided";
fi

if [ -z "$targets" ]; then
die "No targets were provided";
if [ -z "$target" ]; then
die "No target were provided";
fi

if [ -z "$output_directory" ]; then
Expand All @@ -96,7 +96,7 @@ else
fi

# Signing
if [ "$targets" == 'ios-device' ] || [ "$targets" == 'tvos-device' ]; then
if [ "$target" == 'ios-device' ] || [ "$target" == 'tvos-device' ]; then
echo "Real device target detected, application will be signed"

provisioning_profile="$app/embedded.mobileprovision"
Expand Down
2 changes: 1 addition & 1 deletion tests/XHarness/XHarness.Device.AppleRun.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>
<XHarnessAppBundleToTest Include="$(ArtifactsTmpDir)XHarness.RunDeviceAppBundle/$(XHarnessRunAppBundleName)">
<Targets>ios-device</Targets>
<TestTarget>ios-device</TestTarget>
<WorkItemTimeout>00:05:00</WorkItemTimeout>
<TestTimeout>00:04:00</TestTimeout>
<LaunchTimeout>00:03:00</LaunchTimeout>
Expand Down
2 changes: 1 addition & 1 deletion tests/XHarness/XHarness.Simulator.AppleRun.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>
<XHarnessAppBundleToTest Include="$(ArtifactsTmpDir)XHarness.RunAppBundle/$(XHarnessRunAppBundleName)">
<Targets>ios-simulator-64</Targets>
<TestTarget>ios-simulator-64</TestTarget>
<WorkItemTimeout>00:12:00</WorkItemTimeout>
<TestTimeout>00:08:00</TestTimeout>
<LaunchTimeout>00:05:00</LaunchTimeout>
Expand Down
2 changes: 1 addition & 1 deletion tests/XHarness/XHarness.Simulator.AppleTest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>
<XHarnessAppBundleToTest Include="$(ArtifactsTmpDir)XHarness.TestAppBundle/$(XHarnessTestAppBundleName)">
<Targets>ios-simulator-64</Targets>
<TestTarget>ios-simulator-64</TestTarget>
<TestTimeout>00:05:00</TestTimeout>
<WorkItemTimeout>00:15:00</WorkItemTimeout>
<LaunchTimeout>00:06:00</LaunchTimeout>
Expand Down
10 changes: 5 additions & 5 deletions tests/XHarness/XHarness.Simulator.CustomCommands.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@

<ItemGroup>
<XHarnessAppBundleToTest Include="$(ArtifactsTmpDir)XHarness.CustomCommandsAppBundle/$(XHarnessAppBundleName).app">
<Targets>ios-simulator-64</Targets>
<TestTarget>ios-simulator-64</TestTarget>
<WorkItemTimeout>00:15:00</WorkItemTimeout>
<TestTimeout>00:05:00</TestTimeout>
<LaunchTimeout>00:05:00</LaunchTimeout>
<CustomCommands>
set -ex
deviceId=`xharness apple device $targets`
xharness apple install -t=$targets --device="$deviceId" -o="$output_directory" --app="$app" -v
deviceId=`xharness apple device $target`
xharness apple install -t=$target --device="$deviceId" -o="$output_directory" --app="$app" -v
set +e
result=0
xharness apple just-test -t=$targets --device="$deviceId" -o="$output_directory" --app="net.dot.$(XHarnessAppBundleName)" --launch-timeout=$launch_timeout --timeout=$timeout -v
xharness apple just-test -t=$target --device="$deviceId" -o="$output_directory" --app="net.dot.$(XHarnessAppBundleName)" --launch-timeout=$launch_timeout --timeout=$timeout -v
((result|=$?))
xharness apple uninstall -t=$targets --device="$deviceId" -o="$output_directory" --app="net.dot.$(XHarnessAppBundleName)" -v
xharness apple uninstall -t=$target --device="$deviceId" -o="$output_directory" --app="net.dot.$(XHarnessAppBundleName)" -v
((result|=$?))
exit $result
</CustomCommands>
Expand Down