Skip to content

Commit 9995f80

Browse files
authored
Merge pull request #8193 from unoplatform/mergify/bp/release/stable/4.1/pr-8166
test: Log active tests for Runtime Tests runner (backport #8166)
2 parents 9815ff7 + 493fcc5 commit 9995f80

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed

build/ci/.azure-devops-ios-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
JobTimeoutInMinutes: 90
111111
vmImage: ${{ parameters.vmImageTest }}
112112
UITEST_SNAPSHOTS_ONLY: false
113-
UITEST_TEST_TIMEOUT: '3600000'
113+
UITEST_TEST_TIMEOUT: '5400000'
114114
UITEST_AUTOMATED_GROUP: 4
115115
UITEST_ALLOW_RERUN: 'false'
116116
xCodeRoot: ${{ parameters.xCodeRootTest }}

build/test-scripts/ios-uitest-run.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ export UNO_TESTS_LOCAL_TESTS_FILE=$BUILD_SOURCESDIRECTORY/src/SamplesApp/Samples
8282
export UNO_UITEST_BENCHMARKS_PATH=$BUILD_ARTIFACTSTAGINGDIRECTORY/benchmarks/ios-automated
8383
export UNO_UITEST_RUNTIMETESTS_RESULTS_FILE_PATH=$BUILD_SOURCESDIRECTORY/build/RuntimeTestResults-ios-automated.xml
8484

85-
if [ $(wc -l < "$UNO_TESTS_FAILED_LIST") -eq 1 ];
86-
then
85+
export UNO_UITEST_SIMULATOR_VERSION="com.apple.CoreSimulator.SimRuntime.iOS-15-2"
86+
export UNO_UITEST_SIMULATOR_NAME="iPad Pro (12.9-inch) (4th generation)"
87+
88+
UITEST_IGNORE_RERUN_FILE="${UITEST_IGNORE_RERUN_FILE:=false}"
89+
90+
if [ $(wc -l < "$UNO_TESTS_FAILED_LIST") -eq 1 ] && [ "$UITEST_IGNORE_RERUN_FILE" != "true" ]; then
8791
# The test results file only contains the re-run marker and no
8892
# other test to rerun. We can skip this run.
8993
echo "The file $UNO_TESTS_FAILED_LIST does not contain tests to re-run, skipping."
@@ -96,8 +100,16 @@ date
96100
echo "Listing iOS simulators"
97101
xcrun simctl list devices --json
98102

99-
## Preemptively start the simulator
100-
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator &
103+
##
104+
## Pre-install the application to avoid https://github.com/microsoft/appcenter/issues/2389
105+
##
106+
export SIMULATOR_ID=`xcrun simctl list -j | jq -r --arg sim "$UNO_UITEST_SIMULATOR_VERSION" --arg name "$UNO_UITEST_SIMULATOR_NAME" '.devices[$sim] | .[] | select(.name==$name) | .udid'`
107+
108+
echo "Starting simulator: $SIMULATOR_ID ($UNO_UITEST_SIMULATOR_VERSION / $UNO_UITEST_SIMULATOR_NAME)"
109+
xcrun simctl boot "$SIMULATOR_ID" || true
110+
111+
echo "Install app on simulator: $SIMULATOR_ID"
112+
xcrun simctl install "$SIMULATOR_ID" "$UNO_UITEST_IOSBUNDLE_PATH" || true
101113

102114
## Pre-build the transform tool to get early warnings
103115
pushd $BUILD_SOURCESDIRECTORY/src/Uno.NUnitTransformTool
@@ -149,10 +161,17 @@ date
149161
# export the simulator logs
150162
export LOG_FILEPATH=$UNO_UITEST_SCREENSHOT_PATH/_logs
151163
export TMP_LOG_FILEPATH=/tmp/DeviceLog-`date +"%Y%m%d%H%M%S"`.logarchive
164+
export LOG_FILEPATH_FULL=$LOG_FILEPATH/DeviceLog-$UITEST_AUTOMATED_GROUP-`date +"%Y%m%d%H%M%S"`.txt
152165

153166
mkdir -p $LOG_FILEPATH
154167
xcrun simctl spawn booted log collect --output $TMP_LOG_FILEPATH
155-
log show --style syslog $TMP_LOG_FILEPATH > $LOG_FILEPATH/DeviceLog-$UITEST_AUTOMATED_GROUP-`date +"%Y%m%d%H%M%S"`.txt
168+
log show --style syslog $TMP_LOG_FILEPATH > $LOG_FILEPATH_FULL
169+
170+
if grep -Fxq "mini-generic-sharing.c:899" $LOG_FILEPATH_FULL
171+
then
172+
# The application may crash without known cause, add a marker so the job can be restarted in that case.
173+
echo "##[error]mini-generic-sharing.c:899 assertion reached (https://github.com/unoplatform/uno/issues/8167)"
174+
fi
156175

157176
if [ ! -f "$UNO_ORIGINAL_TEST_RESULTS" ]; then
158177
echo "ERROR: The test results file $UNO_ORIGINAL_TEST_RESULTS does not exist (did nunit crash ?)"

src/SamplesApp/SamplesApp.Shared/App.xaml.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,21 @@ private void LaunchiOSWatchDog()
220220
Console.WriteLine("Starting dispatcher WatchDog...");
221221

222222
var dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
223+
var timeout = TimeSpan.FromSeconds(240);
223224

224225
Task.Run(async () =>
225226
{
226227

227228
while (true)
228229
{
229-
var delayTask = Task.Delay(TimeSpan.FromSeconds(240));
230+
var delayTask = Task.Delay(timeout);
230231
var messageTask = dispatcher.RunAsync(CoreDispatcherPriority.High, () => { }).AsTask();
231232

232233
if (await Task.WhenAny(delayTask, messageTask) == delayTask)
233234
{
234235
ThreadPool.QueueUserWorkItem(
235236
_ => {
236-
Console.WriteLine("WatchDog detecting a stall in the dispatcher, terminating the app");
237+
Console.WriteLine($"WatchDog detecting a stall in the dispatcher after {timeout}, terminating the app");
237238
throw new Exception($"Watchdog failed");
238239
});
239240
}
@@ -407,6 +408,18 @@ public static void ConfigureFilters()
407408
builder.AddConsole();
408409
#endif
409410

411+
412+
#if !DEBUG
413+
// Exclude logs below this level
414+
builder.SetMinimumLevel(LogLevel.Information);
415+
#else
416+
// Exclude logs below this level
417+
builder.SetMinimumLevel(LogLevel.Debug);
418+
#endif
419+
420+
// Runtime Tests control logging
421+
builder.AddFilter("Uno.UI.Samples.Tests", LogLevel.Information);
422+
410423
builder.AddFilter("Uno", LogLevel.Warning);
411424
builder.AddFilter("Windows", LogLevel.Warning);
412425
builder.AddFilter("Microsoft", LogLevel.Warning);

src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private void StopRunningTests()
179179
private async Task ReportMessage(string message, bool isRunning = true)
180180
{
181181
#if HAS_UNO
182-
Uno.Foundation.Logging.LogExtensionPoint.Log(GetType()).Info(message);
182+
_log?.Info(message);
183183
#endif
184184

185185
void Setter()

0 commit comments

Comments
 (0)