diff --git a/.travis.yml b/.travis.yml index 837bee06e4..4c7c41a9b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: dart -sudo: false dart: - - dev + # Temporarily disabled. We only have the stable release of Dartium installed. + # - dev - stable env: @@ -12,6 +12,27 @@ env: - PKG=angular_router - PKG=angular_test +# We don't use the dart_task model yet (mono-repo), so this will have to do. +before_install: + # Add a local `bin` folder and add it to the PATH. + - mkdir -p bin + - export PATH="$PATH:$PWD/bin" + + # Start UI (required for Dartium). + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start & + - sleep 3 + + # Download the latest stable release of Dartium, extract it, and add a symlink to bin. + - wget http://gsdview.appspot.com/dart-archive/channels/stable/release/latest/dartium/dartium-linux-x64-release.zip + - unzip dartium-linux-x64-release.zip + - rm dartium-linux-x64-release.zip + - PATH_TO_DARTIUM=`pwd`/`echo dartium-linux-*`/chrome + - ln -sv "$PATH_TO_DARTIUM" "bin/dartium" + + # Sanity check for terminal output. + - echo `which dartium` + script: ./tool/travis.sh # Only building master means that we don't run two builds for each pull request. diff --git a/_tests/.gitignore b/_tests/.gitignore index c590ad0e53..e2cddfc754 100644 --- a/_tests/.gitignore +++ b/_tests/.gitignore @@ -1,2 +1,2 @@ # Ignore files generated by test/source_gen/template_compiler/generate.dart -test/source_gen/template_compiler/test_files/**/*.template_*.dart +test/source_gen/template_compiler/test_files/**/*.template_*.check diff --git a/_tests/dart_test.yaml b/_tests/dart_test.yaml index 2ddf2238b6..289aa7f164 100644 --- a/_tests/dart_test.yaml +++ b/_tests/dart_test.yaml @@ -1,10 +1,10 @@ presets: travis: - exclude_tags: codegen || failing_i302 || known_ff_failure + exclude_tags: known_pub_serve_failure || failing_i302 || known_ff_failure tags: - # See https://github.com/dart-lang/angular2/issues/272 - codegen: - # See https://github.com/dart-lang/angular2/issues/302 + # Tests that fail with pub serve/pub run test. + known_pub_serve_failure: + # See https://github.com/dart-lang/angular2/issues/302. failing_i302: - # TODO(kevmoo): Need note here + # TODO(kevmoo): Need note here. known_ff_failure: diff --git a/_tests/pubspec.yaml b/_tests/pubspec.yaml index 8f55b8f4d4..1e3c861ea4 100644 --- a/_tests/pubspec.yaml +++ b/_tests/pubspec.yaml @@ -20,3 +20,17 @@ dependency_overrides: path: ../angular_compiler angular_test: path: ../angular_test + # TODO: Publish a new `build_runner` to remove this override. + build_barback: 0.3.0 + +transformers: + - angular: + entry_points: test/**_test.dart + $exclude: + - test/**.template.dart + - test/core/reflection/reflector_test.dart + - test/source_gen/template_compiler/test_files/** + + # Allow test to proxy-load files so we can run tests w/ pub serve. + - test/pub_serve: + $include: test/**_test.dart diff --git a/_tests/test/core/application_ref_test.dart b/_tests/test/core/application_ref_test.dart index 77dd5721e8..1fcb535e2e 100644 --- a/_tests/test/core/application_ref_test.dart +++ b/_tests/test/core/application_ref_test.dart @@ -161,7 +161,7 @@ void main() { throwsWith('Cannot bootstrap as there are still ' 'asynchronous initializers running. Wait for them using ' 'waitForAsyncInitializers().')); - }); + }, tags: 'known_pub_serve_failure'); }); }); } diff --git a/_tests/test/core/linker/component_loader_test.dart b/_tests/test/core/linker/component_loader_test.dart index 5873db41b2..b4b1072514 100644 --- a/_tests/test/core/linker/component_loader_test.dart +++ b/_tests/test/core/linker/component_loader_test.dart @@ -5,6 +5,7 @@ import 'package:test/test.dart'; import 'package:angular/angular.dart'; import 'package:angular_test/angular_test.dart'; +// ignore: uri_has_not_been_generated import 'component_loader_test.template.dart' as ng; void main() { diff --git a/_tests/test/core/linker/host_events_test.dart b/_tests/test/core/linker/host_events_test.dart index 6ff77b15bb..0721e4c318 100644 --- a/_tests/test/core/linker/host_events_test.dart +++ b/_tests/test/core/linker/host_events_test.dart @@ -1,4 +1,4 @@ -@Tags(const ['codegen']) +@Tags(const ['codegen', 'known_pub_serve_failure']) @TestOn('browser && !js') import 'dart:async'; import 'dart:html'; diff --git a/_tests/test/source_gen/template_compiler/generate.dart b/_tests/test/source_gen/template_compiler/generate.dart index f3ae9a50ed..fe96fb78e4 100644 --- a/_tests/test/source_gen/template_compiler/generate.dart +++ b/_tests/test/source_gen/template_compiler/generate.dart @@ -32,7 +32,7 @@ Future main(List args) async { ], generatedExtension: updateGoldens ? '.template_release.golden' - : '.template_release.dart', + : '.template_release.check', isStandalone: true), inputs) ..addAction( @@ -42,7 +42,7 @@ Future main(List args) async { ], generatedExtension: updateGoldens ? '.template_debug.golden' - : '.template_debug.dart', + : '.template_debug.check', isStandalone: true), inputs)); await build(phaseGroup, deleteFilesByDefault: updateGoldens); diff --git a/_tests/test/source_gen/template_compiler/generate_template_test.dart b/_tests/test/source_gen/template_compiler/generate_template_test.dart index b4da299ebd..b31ac4e878 100644 --- a/_tests/test/source_gen/template_compiler/generate_template_test.dart +++ b/_tests/test/source_gen/template_compiler/generate_template_test.dart @@ -6,7 +6,7 @@ import 'package:test/test.dart'; import 'compare_to_golden.dart' as golden; -String summaryExtension(String codegenMode) => '.template_$codegenMode.dart'; +String summaryExtension(String codegenMode) => '.template_$codegenMode.check'; String goldenExtension(String codegenMode) => '.template_$codegenMode.golden'; /// To update the golden files, in the root angular2 directory, run diff --git a/angular/lib/src/transform/reflection_remover/entrypoint_matcher.dart b/angular/lib/src/transform/reflection_remover/entrypoint_matcher.dart index f9009c702e..9fbca0f279 100644 --- a/angular/lib/src/transform/reflection_remover/entrypoint_matcher.dart +++ b/angular/lib/src/transform/reflection_remover/entrypoint_matcher.dart @@ -23,8 +23,8 @@ class EntrypointMatcher { (node is! FunctionDeclaration && node is! MethodDeclaration)) { return false; } - return node.metadata - .any((a) => _annotationMatcher.isEntrypoint(a, _assetId)); + return node is FunctionDeclaration && node.name.name == 'main' || + node.metadata.any((a) => _annotationMatcher.isEntrypoint(a, _assetId)); } /// Gets the name assigned to the `AngularEntrypoint`. diff --git a/angular/pubspec.yaml b/angular/pubspec.yaml index 64a5264d4a..ae6fb1256b 100644 --- a/angular/pubspec.yaml +++ b/angular/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: angular_compiler: ^0.1.0-dev barback: ^0.15.2+2 build: ^0.9.0 - build_barback: ^0.2.0 + build_barback: ^0.3.0 code_builder: '^1.0.0-beta+4' collection: '^1.12.0' csslib: ^0.14.0 @@ -37,7 +37,7 @@ dependency_overrides: # === ^^^ REMOVE WHEN PUBLISHING ^^^ === transformers: - - angular/transform/codegen + - angular - $dart2js: commandLineOptions: - '--show-package-warnings' diff --git a/angular_test/pubspec.yaml b/angular_test/pubspec.yaml index f49e6f8b62..07ddb66829 100644 --- a/angular_test/pubspec.yaml +++ b/angular_test/pubspec.yaml @@ -33,18 +33,10 @@ dependency_overrides: # === ^^^ REMOVE WHEN PUBLISHING ^^^ === transformers: - # Run the code generator on the entire package. - - angular/transform/codegen - - # Run the reflection remover just on tests that have AoT enabled. - # TODO: Automate this, either via script or a naming convention. - - angular/transform/reflection_remover: - $include: - - test/frontend/bed_error_test.dart - - test/frontend/bed_lifecycle_test.dart - - test/frontend/pageloader_test.dart - - test/frontend/query_test.dart - - test/bootstrap_test.dart + - angular: + entry_points: test/**_test.dart + $exclude: + - test/**.template.dart # Allow test to proxy-load files so we can run AoT tests w/ pub serve. - test/pub_serve: diff --git a/angular_test/test/bootstrap_test.dart b/angular_test/test/bootstrap_test.dart index 224a9a3891..7c060b1cf6 100644 --- a/angular_test/test/bootstrap_test.dart +++ b/angular_test/test/bootstrap_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@Tags(const ['aot']) +@Tags(const ['codegen']) @TestOn('browser') import 'dart:html'; diff --git a/angular_test/test/frontend/bed_error_test.dart b/angular_test/test/frontend/bed_error_test.dart index 2eef129ffe..776b0a1f20 100644 --- a/angular_test/test/frontend/bed_error_test.dart +++ b/angular_test/test/frontend/bed_error_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@Tags(const ['aot']) +@Tags(const ['codegen']) @TestOn('browser') import 'dart:async'; diff --git a/angular_test/test/frontend/bed_lifecycle_test.dart b/angular_test/test/frontend/bed_lifecycle_test.dart index 3305b76883..4f2ee668ed 100644 --- a/angular_test/test/frontend/bed_lifecycle_test.dart +++ b/angular_test/test/frontend/bed_lifecycle_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@Tags(const ['aot']) +@Tags(const ['codegen']) @TestOn('browser') import 'dart:html'; diff --git a/angular_test/test/frontend/pageloader_test.dart b/angular_test/test/frontend/pageloader_test.dart index 1e37b58283..97649572f8 100644 --- a/angular_test/test/frontend/pageloader_test.dart +++ b/angular_test/test/frontend/pageloader_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@Tags(const ['aot']) +@Tags(const ['codegen']) @TestOn('browser') import 'package:pageloader/objects.dart'; import 'package:test/test.dart'; diff --git a/angular_test/test/frontend/query_test.dart b/angular_test/test/frontend/query_test.dart index 065cf13bf2..058d837181 100644 --- a/angular_test/test/frontend/query_test.dart +++ b/angular_test/test/frontend/query_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@Tags(const ['aot']) +@Tags(const ['codegen']) @TestOn('browser') import 'package:test/test.dart'; import 'package:angular/angular.dart'; diff --git a/angular_test/test/test_on_travis.dart b/angular_test/test/test_on_travis.dart index d2d01c1c32..2892f19998 100644 --- a/angular_test/test/test_on_travis.dart +++ b/angular_test/test/test_on_travis.dart @@ -13,31 +13,31 @@ import 'dart:async'; import 'dart:io'; -import 'package:test/test.dart'; import 'package:angular_test/src/util.dart'; -main() { - var exec = 'pub'; - var args = [ - 'run', - 'angular_test', +main() async { + final exec = 'dart'; + final args = [ + 'bin/angular_test.dart', // Use a specific port to avoid grabbing a bad one. '--serve-arg=--port=8080', '--test-arg=--timeout=4x', - '--test-arg=--tags=aot', + '--test-arg=--tags=codegen', '--test-arg=--platform=dartium', ]; - var name = ([exec]..addAll(args)).join(' '); + final name = ([exec]..addAll(args)).join(' '); + final proc = await Process.start(exec, args); - test(name, () async { - var proc = await Process.start(exec, args); + final values = await Future.wait([ + proc.exitCode, + standardIoToLines(proc.stdout).forEach(print), + standardIoToLines(proc.stderr).forEach(print), + ]); - var values = await Future.wait([ - proc.exitCode, - standardIoToLines(proc.stdout).forEach(print), - standardIoToLines(proc.stderr).forEach(print), - ]); - - expect(values.first, 0, reason: "Expect exit code to be 0 (successs)."); - }); + // We purposefully don't use package:test because of dealing with timeouts + // as part of the compiler running above on travis. + if (values.first != 0) { + stdout.writeln('Ran $name; failed.'); + exit(1); + } } diff --git a/tool/travis.sh b/tool/travis.sh index 7a7f2519a9..1723d8b1bf 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -13,11 +13,19 @@ pub upgrade dartanalyzer --fatal-warnings . if [ "$PKG" == "_tests" ]; then + dartium --version dart test/source_gen/template_compiler/generate.dart + pub run test -p vm -x codegen + pub run angular_test \ + --serve-arg=--port=8080 \ + --test-arg=--platform=dartium \ + --test-arg=--tags=codegen \ + --test-arg=--exclude-tags=known_pub_serve_failure fi -if [ "$PKG" == "_tests" ] || [ "$PKG" == "angular_test" ]; then - pub run test +if [ "$PKG" == "angular_test" ]; then + dartium --version + dart test/test_on_travis.dart fi if [ "$TRAVIS_DART_VERSION" == "stable" ]; then