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 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -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(targets);
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 = "Target";
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>
<Target>ios-simulator-64_13.5</Targets>
</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 `<Target>` 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>
<Target>ios-simulator-64</Target>
<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!
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>
<Target>ios-device</Target>
<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>
<Target>ios-simulator-64</Target>
<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>
<Target>ios-simulator-64</Target>
<TestTimeout>00:05:00</TestTimeout>
<WorkItemTimeout>00:15:00</WorkItemTimeout>
<LaunchTimeout>00:06:00</LaunchTimeout>
Expand Down
2 changes: 1 addition & 1 deletion tests/XHarness/XHarness.Simulator.CustomCommands.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>
<XHarnessAppBundleToTest Include="$(ArtifactsTmpDir)XHarness.CustomCommandsAppBundle/$(XHarnessAppBundleName).app">
<Targets>ios-simulator-64</Targets>
<Target>ios-simulator-64</Target>
<WorkItemTimeout>00:15:00</WorkItemTimeout>
<TestTimeout>00:05:00</TestTimeout>
<LaunchTimeout>00:05:00</LaunchTimeout>
Expand Down