test.sh 2.19 KB
Newer Older
1 2
#!/bin/bash

3
export PATH="$PWD/bin:$PWD/bin/cache/dart-sdk/bin:$PATH"
4

5 6 7 8
trap detect_error_on_exit EXIT HUP INT QUIT TERM

detect_error_on_exit() {
    exit_code=$?
9
    set +x
10
    if [[ $exit_code -ne 0 ]]; then
11
        echo -e "\x1B[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1B[0m"
Ian Hickson's avatar
Ian Hickson committed
12
        echo -e "\x1B[1mError:\x1B[31m script exited early due to error ($exit_code)\x1B[0m"
13
        echo -e "\x1B[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1B[0m"
14
    fi
15 16
}

17 18
set -ex

Hixie's avatar
Hixie committed
19
# analyze all the Dart code in the repo
20
flutter analyze --flutter-repo
21

Ian Hickson's avatar
Ian Hickson committed
22
# verify that the tests actually return failure on failure and success on success
23 24
(cd dev/automated_tests; ! flutter test test_smoke_test/fail_test.dart > /dev/null)
(cd dev/automated_tests; flutter test test_smoke_test/pass_test.dart > /dev/null)
25
(cd packages/flutter_driver; ! flutter drive --use-existing-app -t test_driver/failure.dart >/dev/null 2>&1)
Ian Hickson's avatar
Ian Hickson committed
26

27
COVERAGE_FLAG=
28
if [ -n "$TRAVIS" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
29 30 31
  COVERAGE_FLAG=--coverage
fi

32 33
SRC_ROOT=$PWD

34
# run tests
35
(cd packages/flutter; flutter test $COVERAGE_FLAG)
36
(cd packages/flutter_driver; dart -c test/all.dart)
37
(cd packages/flutter_test; flutter test)
38
(cd packages/flutter_tools; FLUTTER_ROOT=$SRC_ROOT dart -c test/all.dart)
39

40
(cd dev/devicelab; dart -c test/all.dart)
41 42 43
(cd dev/manual_tests; flutter test)
(cd examples/hello_world; flutter test)
(cd examples/layers; flutter test)
44
(cd examples/stocks; flutter test)
45
(cd examples/flutter_gallery; flutter test)
46 47 48

# generate and analyze our large sample app
dart dev/tools/mega_gallery.dart
49
(cd dev/benchmarks/mega_gallery; flutter analyze --watch --benchmark)
50 51 52 53 54 55 56 57 58

if [ -n "$COVERAGE_FLAG" ]; then
  GSUTIL=$HOME/google-cloud-sdk/bin/gsutil
  GCLOUD=$HOME/google-cloud-sdk/bin/gcloud

  $GCLOUD auth activate-service-account --key-file ../gcloud_key_file.json
  STORAGE_URL=gs://flutter_infra/flutter/coverage/lcov.info
  $GSUTIL cp packages/flutter/coverage/lcov.info $STORAGE_URL
fi
59 60

# generate the API docs, upload them
61
dev/bots/docs.sh