Skip to content

Commit

Permalink
Merge pull request #8193 from unoplatform/mergify/bp/release/stable/4…
Browse files Browse the repository at this point in the history
….1/pr-8166

test: Log active tests for Runtime Tests runner (backport #8166)
  • Loading branch information
jeromelaban authored Mar 8, 2022
2 parents 9815ff7 + 493fcc5 commit 9995f80
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/ci/.azure-devops-ios-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
JobTimeoutInMinutes: 90
vmImage: ${{ parameters.vmImageTest }}
UITEST_SNAPSHOTS_ONLY: false
UITEST_TEST_TIMEOUT: '3600000'
UITEST_TEST_TIMEOUT: '5400000'
UITEST_AUTOMATED_GROUP: 4
UITEST_ALLOW_RERUN: 'false'
xCodeRoot: ${{ parameters.xCodeRootTest }}
Expand Down
29 changes: 24 additions & 5 deletions build/test-scripts/ios-uitest-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ export UNO_TESTS_LOCAL_TESTS_FILE=$BUILD_SOURCESDIRECTORY/src/SamplesApp/Samples
export UNO_UITEST_BENCHMARKS_PATH=$BUILD_ARTIFACTSTAGINGDIRECTORY/benchmarks/ios-automated
export UNO_UITEST_RUNTIMETESTS_RESULTS_FILE_PATH=$BUILD_SOURCESDIRECTORY/build/RuntimeTestResults-ios-automated.xml

if [ $(wc -l < "$UNO_TESTS_FAILED_LIST") -eq 1 ];
then
export UNO_UITEST_SIMULATOR_VERSION="com.apple.CoreSimulator.SimRuntime.iOS-15-2"
export UNO_UITEST_SIMULATOR_NAME="iPad Pro (12.9-inch) (4th generation)"

UITEST_IGNORE_RERUN_FILE="${UITEST_IGNORE_RERUN_FILE:=false}"

if [ $(wc -l < "$UNO_TESTS_FAILED_LIST") -eq 1 ] && [ "$UITEST_IGNORE_RERUN_FILE" != "true" ]; then
# The test results file only contains the re-run marker and no
# other test to rerun. We can skip this run.
echo "The file $UNO_TESTS_FAILED_LIST does not contain tests to re-run, skipping."
Expand All @@ -96,8 +100,16 @@ date
echo "Listing iOS simulators"
xcrun simctl list devices --json

## Preemptively start the simulator
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator &
##
## Pre-install the application to avoid https://github.com/microsoft/appcenter/issues/2389
##
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'`

echo "Starting simulator: $SIMULATOR_ID ($UNO_UITEST_SIMULATOR_VERSION / $UNO_UITEST_SIMULATOR_NAME)"
xcrun simctl boot "$SIMULATOR_ID" || true

echo "Install app on simulator: $SIMULATOR_ID"
xcrun simctl install "$SIMULATOR_ID" "$UNO_UITEST_IOSBUNDLE_PATH" || true

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

mkdir -p $LOG_FILEPATH
xcrun simctl spawn booted log collect --output $TMP_LOG_FILEPATH
log show --style syslog $TMP_LOG_FILEPATH > $LOG_FILEPATH/DeviceLog-$UITEST_AUTOMATED_GROUP-`date +"%Y%m%d%H%M%S"`.txt
log show --style syslog $TMP_LOG_FILEPATH > $LOG_FILEPATH_FULL

if grep -Fxq "mini-generic-sharing.c:899" $LOG_FILEPATH_FULL
then
# The application may crash without known cause, add a marker so the job can be restarted in that case.
echo "##[error]mini-generic-sharing.c:899 assertion reached (https://github.com/unoplatform/uno/issues/8167)"
fi

if [ ! -f "$UNO_ORIGINAL_TEST_RESULTS" ]; then
echo "ERROR: The test results file $UNO_ORIGINAL_TEST_RESULTS does not exist (did nunit crash ?)"
Expand Down
17 changes: 15 additions & 2 deletions src/SamplesApp/SamplesApp.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,21 @@ private void LaunchiOSWatchDog()
Console.WriteLine("Starting dispatcher WatchDog...");

var dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
var timeout = TimeSpan.FromSeconds(240);

Task.Run(async () =>
{

while (true)
{
var delayTask = Task.Delay(TimeSpan.FromSeconds(240));
var delayTask = Task.Delay(timeout);
var messageTask = dispatcher.RunAsync(CoreDispatcherPriority.High, () => { }).AsTask();

if (await Task.WhenAny(delayTask, messageTask) == delayTask)
{
ThreadPool.QueueUserWorkItem(
_ => {
Console.WriteLine("WatchDog detecting a stall in the dispatcher, terminating the app");
Console.WriteLine($"WatchDog detecting a stall in the dispatcher after {timeout}, terminating the app");
throw new Exception($"Watchdog failed");
});
}
Expand Down Expand Up @@ -407,6 +408,18 @@ public static void ConfigureFilters()
builder.AddConsole();
#endif


#if !DEBUG
// Exclude logs below this level
builder.SetMinimumLevel(LogLevel.Information);
#else
// Exclude logs below this level
builder.SetMinimumLevel(LogLevel.Debug);
#endif

// Runtime Tests control logging
builder.AddFilter("Uno.UI.Samples.Tests", LogLevel.Information);

builder.AddFilter("Uno", LogLevel.Warning);
builder.AddFilter("Windows", LogLevel.Warning);
builder.AddFilter("Microsoft", LogLevel.Warning);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void StopRunningTests()
private async Task ReportMessage(string message, bool isRunning = true)
{
#if HAS_UNO
Uno.Foundation.Logging.LogExtensionPoint.Log(GetType()).Info(message);
_log?.Info(message);
#endif

void Setter()
Expand Down

0 comments on commit 9995f80

Please sign in to comment.