#!/usr/bin/env bash # Build the dart-flavored veilid-flutter wasm blob, copy it into the example's # web/wasm (via example/scripts/wasm_update.sh, the same step a plain # `flutter run -d chrome` of the example needs), and run its integration tests. # # Runs against veilid-core's in-process mock unless --live is given. The # selection is a cargo feature here rather than the environment the native build # hook reads, because this blob is built by wasm_build.sh directly - so # switching costs a wasm rebuild each way. SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" VEILIDDIR="$( cd "$SCRIPTDIR/.." >/dev/null 2>&1 && pwd )" # pipefail keeps pipe exit codes; no `set -e` — failures are handled explicitly # so this script returns the flutter-drive test result. set -o pipefail # shellcheck source=../scripts/_integration_test_common.sh source "$VEILIDDIR/scripts/_integration_test_common.sh" || exit 1 # shellcheck source=../scripts/_chromedriver_helper.sh source "$VEILIDDIR/scripts/_chromedriver_helper.sh" || exit 1 print_help() { cat <&2; exit 1; } fi trap stop_chromedriver EXIT start_chromedriver || { echo "failed to start chromedriver" >&2; exit 1; } start_chromedriver_log_poller # flutter drive's own --headless governs the browser chromedriver launches, and # it defaults to on - so the visible run is the one that has to ask. HEADLESS_ARG=--no-headless if [ "$HEADLESS" = true ]; then HEADLESS_ARG=--headless fi pushd "$SCRIPTDIR/example" >/dev/null || exit 1 # Web Flutter Driver tests require `-d web-server` in `--release` (or --profile): # debug is not yet supported (flutter/docs Running-Flutter-Driver-tests-with-Web.md). # `-d chrome` uses a dwds VM-service debug connection that fails on web ("The # stream `Timer` is not supported on web devices") and hangs; `-d web-server` in # debug mode silently no-ops the test bodies. In release, web-server drives the # app through chromedriver's WebDriver bridge and reads results via JS — no VM # service. Browser console is forwarded by start_chromedriver_log_poller. run_flutter_drive_for_web_tests \ --driver=test_driver/integration_test.dart \ --target=integration_test/app_test.dart \ -d web-server \ --browser-name=chrome \ --release \ "$HEADLESS_ARG" \ --verbose \ "${DEFINES[@]}" \ ${PASSTHROUGH[@]+"${PASSTHROUGH[@]}"} status=$? popd >/dev/null exit $status