#!/usr/bin/env bash set -euo pipefail root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" if [ -f "$root/packages/messaging_flutter/pubspec.yaml" ]; then if command -v flutter >/dev/null 2>&1; then (cd "$root/packages/messaging_flutter" && flutter test) else echo "skip packages/messaging_flutter: flutter not found" fi fi if [ -f "$root/apps/flutter-test/pubspec.yaml" ]; then if command -v flutter >/dev/null 2>&1; then (cd "$root/apps/flutter-test" && flutter test) else echo "skip apps/flutter-test: flutter not found" fi fi if [ -f "$root/services/core/server/go.mod" ]; then if [ "${NEXO_CORE_GO_TEST:-0}" = "1" ]; then if command -v go >/dev/null 2>&1; then (cd "$root/services/core/server" && go test ./...) else echo "skip services/core/server: go not found" fi else echo "skip services/core/server: set NEXO_CORE_GO_TEST=1 to run the full Go test suite" fi fi if [ -f "$root/services/core/webapp/package.json" ]; then if [ "${NEXO_CORE_WEBAPP_TEST:-0}" = "1" ]; then if command -v npm >/dev/null 2>&1; then (cd "$root/services/core/webapp" && npm run test-ci) else echo "skip services/core/webapp: npm not found" fi else echo "skip services/core/webapp: set NEXO_CORE_WEBAPP_TEST=1 to run the webapp npm test suite" fi fi if [ -f "$root/apps/flutter-test/pubspec.yaml" ]; then if [ "${NEXO_FLUTTER_INTEGRATION_TEST:-0}" = "1" ]; then if command -v flutter >/dev/null 2>&1; then (cd "$root/apps/flutter-test" && flutter test integration_test) else echo "skip apps/flutter-test integration_test: flutter not found" fi else echo "skip apps/flutter-test integration_test: set NEXO_FLUTTER_INTEGRATION_TEST=1 to run integration tests" fi fi if [ "${NEXO_ANDROID_NATIVE_TEST:-0}" = "1" ]; then if [ -f "$root/apps/flutter-test/android/gradlew" ]; then if command -v java >/dev/null 2>&1; then # Check if Android SDK is available has_android_sdk=0 if [ -n "${ANDROID_HOME:-}" ] && [ -d "$ANDROID_HOME" ]; then has_android_sdk=1 elif [ -n "${ANDROID_SDK_ROOT:-}" ] && [ -d "$ANDROID_SDK_ROOT" ]; then has_android_sdk=1 else local_sdk_dir="" if [ -f "$root/apps/flutter-test/android/local.properties" ]; then # Extract non-commented sdk.dir value sdk_line=$(grep -E '^[[:space:]]*sdk\.dir[[:space:]]*=' "$root/apps/flutter-test/android/local.properties" || true) if [ -n "$sdk_line" ]; then local_sdk_dir=$(echo "$sdk_line" | cut -d'=' -f2- | xargs || true) fi fi if [ -n "$local_sdk_dir" ] && [ -d "$local_sdk_dir" ]; then has_android_sdk=1 fi fi if [ "$has_android_sdk" = "1" ]; then (cd "$root/apps/flutter-test/android" && ./gradlew testDebugUnitTest) else echo "skip apps/flutter-test Android native tests: Android SDK not found (ANDROID_HOME, ANDROID_SDK_ROOT, and local.properties sdk.dir are all missing or point to invalid directories)" fi else echo "BLOCKED apps/flutter-test Android native tests: java not found" fi else echo "skip apps/flutter-test Android native tests: gradlew not found" fi else echo "skip apps/flutter-test Android native tests: set NEXO_ANDROID_NATIVE_TEST=1 to run Android native tests" fi