From 615f34183cfeaf01183ebbc949b7b9d73582ab0a Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Thu, 2 Apr 2020 11:50:29 -0400 Subject: [PATCH 1/2] [Harness] Ensure we do not throw an exception if we do not have tasks. The First extension will throw an exception if the list is empty. Use FirstOrDefault, check if the devices are null and return the test as Ignored. fixes: https://github.com/xamarin/xamarin-macios/issues/8271 --- .../Jenkins/TestTasks/AggregatedRunSimulatorTask.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/xharness/Jenkins/TestTasks/AggregatedRunSimulatorTask.cs b/tests/xharness/Jenkins/TestTasks/AggregatedRunSimulatorTask.cs index 6c805cd958ab..1cc7af4d52d8 100644 --- a/tests/xharness/Jenkins/TestTasks/AggregatedRunSimulatorTask.cs +++ b/tests/xharness/Jenkins/TestTasks/AggregatedRunSimulatorTask.cs @@ -63,7 +63,11 @@ protected override async Task ExecuteAsync () await task.SelectSimulatorAsync (); } - var devices = executingTasks.First ().Simulators; + var devices = executingTasks.FirstOrDefault ()?.Simulators; + if (devices == null) { + ExecutionResult = TestExecutingResult.Ignored; + return; + } Jenkins.MainLog.WriteLine ("Selected simulator: {0}", devices.Length > 0 ? devices [0].Name : "none"); foreach (var dev in devices) From 2ffaf5390af66279f81fa840643778aec1b5c639 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Fri, 3 Apr 2020 11:11:09 -0400 Subject: [PATCH 2/2] Use the correct error. --- tests/xharness/Jenkins/TestTasks/AggregatedRunSimulatorTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/xharness/Jenkins/TestTasks/AggregatedRunSimulatorTask.cs b/tests/xharness/Jenkins/TestTasks/AggregatedRunSimulatorTask.cs index 1cc7af4d52d8..1b42f64d6f04 100644 --- a/tests/xharness/Jenkins/TestTasks/AggregatedRunSimulatorTask.cs +++ b/tests/xharness/Jenkins/TestTasks/AggregatedRunSimulatorTask.cs @@ -65,7 +65,7 @@ protected override async Task ExecuteAsync () var devices = executingTasks.FirstOrDefault ()?.Simulators; if (devices == null) { - ExecutionResult = TestExecutingResult.Ignored; + ExecutionResult = TestExecutingResult.DeviceNotFound; return; } Jenkins.MainLog.WriteLine ("Selected simulator: {0}", devices.Length > 0 ? devices [0].Name : "none");