From 558fa6caa8987e109520cdbd580af32fed874ffb Mon Sep 17 00:00:00 2001 From: evanweible-wf Date: Tue, 31 Jul 2018 10:48:29 -0600 Subject: [PATCH] Dart 2 compatibility --- .travis.yml | 4 ++-- dart_test.yaml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ pubspec.yaml | 11 +++++++---- tool/travis.sh | 21 ++++++++++----------- 4 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 dart_test.yaml diff --git a/.travis.yml b/.travis.yml index 95435d4..e72d8ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: dart dart: - - stable + - 1.24.3 - dev # Workaround for issue with sandboxed Chrome in containerized Travis builds. @@ -16,5 +16,5 @@ cache: before_script: npm install script: - - pub run dart_dev analyze + - dartanalyzer . - ./tool/travis.sh test diff --git a/dart_test.yaml b/dart_test.yaml new file mode 100644 index 0000000..509be54 --- /dev/null +++ b/dart_test.yaml @@ -0,0 +1,47 @@ +# Dart 1: +# ------- +# +# Run unit tests: +# +# $ pub run test +# +# Run integration tests: +# +# $ node tool/server.js +# $ pub run test -P integration +# +# +# Dart 2: +# ------- +# +# Run unit tests: +# +# $ pub run build_runner test +# +# Run integration tests: +# +# $ node tool/server.js +# $ pub run build_runner test -- -P integration +platforms: +- chrome + +paths: +- test/xhr_streaming_test.dart + +presets: + all: + concurrency: 1 + paths: + - test/xhr_streaming_test.dart + - test/sockjs_client_integration_test.dart + + integration: + concurrency: 1 + paths: + - test/sockjs_client_integration_test.dart + + travis: + reporter: expanded + # The SockJS integration test server sometimes gets overloaded and rejects + # connections. Retries are enabled during CI to mitigate these failures. + retry: 3 diff --git a/pubspec.yaml b/pubspec.yaml index 1aa995c..1585ba6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,15 +7,18 @@ authors: - Sébastien Deleuze dependencies: browser: '>=0.9.0 <1.0.0' + dart2_constant: ^1.0.0 logging: '>=0.9.0 <1.0.0' dev_dependencies: - coverage: ^0.10.0 - dart2_constant: ^1.0.1 - dart_dev: ^1.9.1 + build_runner: ">=0.6.0 <1.0.0" + build_test: ">=0.9.0 <1.0.0" + build_web_compilers: ">=0.2.0 <1.0.0" + coverage: '>=0.10.0 <0.13.0' + dart_dev: ^1.9.5 dart_style: ^1.0.7 test: ^0.12.23+1 environment: - sdk: '>=1.0.0 <2.0.0' + sdk: '>=1.0.0 <3.0.0' transformers: - test/pub_serve: diff --git a/tool/travis.sh b/tool/travis.sh index 934e456..046d40f 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -12,27 +12,26 @@ if [ -z "$TASK" ]; then exit 1 fi +DART_VERSION=$(dart --version 2>&1) +DART_2_PREFIX="Dart VM version: 2" + # Run the correct task type. case $TASK in test) echo -e '\033[1mTASK: Testing [test]\033[22m' - echo -e 'pub build test --web-compiler=dartdevc' - # Precompile tests to avoid timeouts/hung builds. - pub build test --web-compiler=dartdevc - # The --precompile option requires that it be given a merged output dir with - # both compiled JS files and the source .dart files. - # NOTE: Once we're on Dart 2 for good, we can switch to build_runner which - # does all of this for us. - cp -R test/** build/test/ - node tool/server.js & SOCKJS_SERVER=$! sleep 2 - echo -e 'pub run test -j 1 -p chrome --precompiled=build/' - pub run test -j 1 -p chrome --precompiled=build/ + if [[ $DART_VERSION = $DART_2_PREFIX* ]]; then + echo -e 'pub run build_runner test -- -P all -P travis' + pub run build_runner test -- -P all -P travis + else + echo -e 'pub run test -P all -P travis' + pub run test -P all -P travis + fi kill $SOCKJS_SERVER sleep 2