@@ -71,12 +71,18 @@ rm -rf "$videos_dir" "$screenshots_dir"
7171mkdir -p " $videos_dir " " $screenshots_dir "
7272
7373# HumHub.initApp() awaits the notification permission request, and the test
74- # can't answer the system alert. Install the app once and pre-grant it;
75- # `flutter test` installs over it, which keeps the permission.
74+ # can't answer the system alert. So the app is installed and the permission
75+ # granted before every test file: `flutter test` installs over it, which keeps
76+ # the permission, but uninstalls the app when it's done.
7677echo " Building the app for the simulator..."
7778flutter build ios --simulator --debug --target integration_test/app_launch_test.dart 2>&1 | tee " $logs_dir /ios_build.txt"
78- xcrun simctl install " $SIMULATOR " build/ios/iphonesimulator/Runner.app
79- applesimutils --byId " $SIMULATOR " --bundle " $PACKAGE " --setPermissions notifications=YES > /dev/null
79+
80+ # Whichever build is there (`flutter test` replaces it), it only has to carry
81+ # the bundle id.
82+ install_app () {
83+ xcrun simctl install " $SIMULATOR " build/ios/iphonesimulator/Runner.app
84+ applesimutils --byId " $SIMULATOR " --bundle " $PACKAGE " --setPermissions notifications=YES > /dev/null
85+ }
8086
8187xcrun simctl spawn " $SIMULATOR " log stream --level debug --style compact \
8288 --predicate ' process == "Runner"' > " $logs_dir /simulator.log" 2>&1 &
@@ -89,6 +95,8 @@ xcrun simctl spawn "$SIMULATOR" log stream --style compact \
8995 * E2E_SCREENSHOT:* )
9096 name=" ${line##* E2E_SCREENSHOT: } "
9197 name=" ${name// [^a-z0-9-]/ } "
98+ # log stream's header line repeats the predicate.
99+ [ -n " $name " ] || continue
92100 xcrun simctl io " $SIMULATOR " screenshot " $screenshots_dir /$name .png" > /dev/null 2>&1 < /dev/null
93101 echo " Screenshot of failed test: $screenshots_dir /$name .png"
94102 ;;
@@ -126,6 +134,7 @@ for test_file in integration_test/*_test.dart; do
126134 name=" $( basename " $test_file " .dart) "
127135 # A leftover app process would start the recording before the build.
128136 xcrun simctl terminate " $SIMULATOR " " $PACKAGE " > /dev/null 2>&1 || true
137+ install_app
129138 start_recording " $name "
130139 flutter test " $test_file " \
131140 -d " $SIMULATOR " \
0 commit comments