Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
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
53 changes: 38 additions & 15 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import multiprocessing
import os
import re
import shutil
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -752,21 +753,43 @@ def run_objc_tests(ios_variant='ios_debug_sim_unopt', test_filter=None):
ios_unit_test_dir = os.path.join(
BUILDROOT_DIR, 'flutter', 'testing', 'ios', 'IosUnitTests'
)
# Avoid using xcpretty unless the following can be addressed:
# - Make sure all relevant failure output is printed on a failure.
# - Make sure that a failing exit code is set for CI.
# See https://github.com/flutter/flutter/issues/63742
test_command = [
'xcodebuild '
'-sdk iphonesimulator '
'-scheme IosUnitTests '
"-destination name='" + new_simulator_name + "' "
'test '
'FLUTTER_ENGINE=' + ios_variant
]
if test_filter is not None:
test_command[0] = test_command[0] + ' -only-testing:%s' % test_filter
run_cmd(test_command, cwd=ios_unit_test_dir, shell=True)

with tempfile.TemporaryDirectory(suffix='ios_embedding_xcresult'
) as result_bundle_temp:
result_bundle_path = os.path.join(result_bundle_temp, 'ios_embedding')

# Avoid using xcpretty unless the following can be addressed:
# - Make sure all relevant failure output is printed on a failure.
# - Make sure that a failing exit code is set for CI.
# See https://github.com/flutter/flutter/issues/63742
test_command = [
'xcodebuild '
'-sdk iphonesimulator '
'-scheme IosUnitTests '
'-resultBundlePath ' + result_bundle_path + ' '
'-destination name=' + new_simulator_name + ' '
'test '
'FLUTTER_ENGINE=' + ios_variant
]
if test_filter is not None:
test_command[0] = test_command[0] + ' -only-testing:%s' % test_filter
run_cmd(test_command, cwd=ios_unit_test_dir, shell=True)

# except:
# The LUCI environment may provide a variable containing a directory path
# for additional output files that will be uploaded to cloud storage.
# Upload the xcresult when the tests fail.
luci_test_outputs_path = os.environ.get('FLUTTER_TEST_OUTPUTS_DIR')
xcresult_bundle = os.path.join(
result_bundle_temp, 'ios_embedding.xcresult'
)
if luci_test_outputs_path and os.path.exists(xcresult_bundle):
dump_path = os.path.join(
luci_test_outputs_path, 'ios_embedding.xcresult'
)
# xcresults contain many little files. Archive the bundle before upload.
shutil.make_archive(dump_path, 'zip', root_dir=xcresult_bundle)

finally:
delete_simulator(new_simulator_name)

Expand Down
2 changes: 1 addition & 1 deletion testing/scenario_app/lib/src/platform_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenar
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder()
..pushClipRect(const Rect.fromLTRB(100, 100, 400, 400));
..pushClipRect(const Rect.fromLTRB(90, 100, 400, 400));

addPlatformView(
id,
Expand Down
43 changes: 38 additions & 5 deletions testing/scenario_app/run_ios_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,58 @@ fi
# Can also be set via Simulator app Device > Rotate Device Automatically
defaults write com.apple.iphonesimulator RotateWindowWhenSignaledByGuest -int 1

cd $SRC_DIR/out/$FLUTTER_ENGINE/scenario_app/Scenarios
SCENARIO_PATH=$SRC_DIR/out/$FLUTTER_ENGINE/scenario_app/Scenarios
pushd .
cd $SCENARIO_PATH

RESULT_BUNDLE_FOLDER="ios_scenario_xcresult"
RESULT_BUNDLE_PATH="${SCENARIO_PATH}/${RESULT_BUNDLE_FOLDER}"

# Zip and upload xcresult to luci.
# First parameter ($1) is the zip output name.
zip_and_upload_xcresult_to_luci () {
# We don't want the zip to contain the abusolute path,
# so use relative path (./$RESULT_BUNDLE_FOLDER) instead.
zip -q -r $1 "./$RESULT_BUNDLE_FOLDER"
mv -f $1 $FLUTTER_TEST_OUTPUTS_DIR
exit 1
}

echo "Running simulator tests with Skia"
echo ""

set -o pipefail && xcodebuild -sdk iphonesimulator \
mktemp -d $RESULT_BUNDLE_PATH

if set -o pipefail && xcodebuild -sdk iphonesimulator \
-scheme Scenarios \
-resultBundlePath "$RESULT_BUNDLE_PATH/ios_scenario.xcresult" \
-destination 'platform=iOS Simulator,OS=16.2,name=iPhone SE (3rd generation)' \
clean test \
FLUTTER_ENGINE="$FLUTTER_ENGINE"
FLUTTER_ENGINE="$FLUTTER_ENGINE"; then
echo "test success."
else
echo "test failed."
zip_and_upload_xcresult_to_luci "ios_scenario_xcresult.zip"
fi
rm -rf $RESULT_BUNDLE_PATH

echo "Running simulator tests with Impeller"
echo ""

# Skip testFontRenderingWhenSuppliedWithBogusFont: https://github.com/flutter/flutter/issues/113250
set -o pipefail && xcodebuild -sdk iphonesimulator \
if set -o pipefail && xcodebuild -sdk iphonesimulator \
-scheme Scenarios \
-resultBundlePath "$RESULT_BUNDLE_PATH/ios_scenario.xcresult" \
-destination 'platform=iOS Simulator,OS=16.2,name=iPhone SE (3rd generation)' \
clean test \
FLUTTER_ENGINE="$FLUTTER_ENGINE" \
-skip-testing "ScenariosUITests/BogusFontTextTest/testFontRenderingWhenSuppliedWithBogusFont" \
INFOPLIST_FILE="Scenarios/Info_Impeller.plist" # Plist with FLTEnableImpeller=YES
INFOPLIST_FILE="Scenarios/Info_Impeller.plist"; then # Plist with FLTEnableImpeller=YES
echo "test success."
else
echo "test failed."
zip_and_upload_xcresult_to_luci "ios_scenario_impeller_xcresult.zip"
fi
rm -rf $RESULT_BUNDLE_PATH

popd