Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Add automated testing of _tests and angular_test to travis.
Browse files Browse the repository at this point in the history
* Only test on Dart stable for now. Let's get this working 1st.
* Start XVFB (thanks Gary!) and download/"install" Dartium.

Misc changes necessary to land this:

* Renamed the generated files in test_files from .dart -> .check
  * Otherwise the analyzer would scream about these files locally
* Reflection remover considers "main()" to be an entry-point
  * Removes the need for explicit @AngularEntrypoint() in tests

Closes #534.

PiperOrigin-RevId: 162556261
  • Loading branch information
matanlurey committed Jul 20, 2017
1 parent 703e5d2 commit 073e728
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 54 deletions.
25 changes: 23 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: dart
sudo: false

dart:
- dev
# Temporarily disabled. We only have the stable release of Dartium installed.
# - dev
- stable

env:
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion _tests/.gitignore
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions _tests/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -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:
14 changes: 14 additions & 0 deletions _tests/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion _tests/test/core/application_ref_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
}
Expand Down
1 change: 1 addition & 0 deletions _tests/test/core/linker/component_loader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion _tests/test/core/linker/host_events_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Tags(const ['codegen'])
@Tags(const ['codegen', 'known_pub_serve_failure'])
@TestOn('browser && !js')
import 'dart:async';
import 'dart:html';
Expand Down
4 changes: 2 additions & 2 deletions _tests/test/source_gen/template_compiler/generate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Future main(List<String> args) async {
],
generatedExtension: updateGoldens
? '.template_release.golden'
: '.template_release.dart',
: '.template_release.check',
isStandalone: true),
inputs)
..addAction(
Expand All @@ -42,7 +42,7 @@ Future main(List<String> args) async {
],
generatedExtension: updateGoldens
? '.template_debug.golden'
: '.template_debug.dart',
: '.template_debug.check',
isStandalone: true),
inputs));
await build(phaseGroup, deleteFilesByDefault: updateGoldens);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions angular/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,7 +37,7 @@ dependency_overrides:
# === ^^^ REMOVE WHEN PUBLISHING ^^^ ===

transformers:
- angular/transform/codegen
- angular
- $dart2js:
commandLineOptions:
- '--show-package-warnings'
16 changes: 4 additions & 12 deletions angular_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion angular_test/test/bootstrap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion angular_test/test/frontend/bed_error_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion angular_test/test/frontend/bed_lifecycle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion angular_test/test/frontend/pageloader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion angular_test/test/frontend/query_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
36 changes: 18 additions & 18 deletions angular_test/test/test_on_travis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(<Future>[
proc.exitCode,
standardIoToLines(proc.stdout).forEach(print),
standardIoToLines(proc.stderr).forEach(print),
]);

var values = await Future.wait(<Future>[
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);
}
}
12 changes: 10 additions & 2 deletions tool/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 073e728

Please sign in to comment.