chore(install+test): single cmd to full install/test & test JS w/o Dart
* `npm install` now does a full install; auxiliary installation steps have been integrated into the `postinstall` script. * Updated developer docs `DEVELOPER.md` accordingly; also added instructions to dev docs for performing full tests (via `npm test`) -- same as those run on Travis. * Reorg in tests so that JS tests can run without a Dart env. Partly fixes #945 **under the assumption that when running JS tests locally, `ChromeCanary` is the desired browser to use**. Note that CI tests (Travis) still uses `DartiumWithWebPlatform` across the board (Maybe because ChromeCanary isn't being installed?) Fixes #1012. Closes #1010
This commit is contained in:
parent
bd48c927d0
commit
83402930f2
49
DEVELOPER.md
49
DEVELOPER.md
|
@ -95,23 +95,22 @@ Next, install the modules and packages needed to build Angular and run tests:
|
|||
```shell
|
||||
# Install Angular project dependencies (package.json)
|
||||
npm install
|
||||
|
||||
# Ensure protractor has the latest webdriver
|
||||
$(npm bin)/webdriver-manager update
|
||||
|
||||
# Install Dart packages
|
||||
pub get
|
||||
```
|
||||
|
||||
**Optional**: In this document, we make use of project local `npm` package scripts and binaries
|
||||
(stored under `./node_modules/.bin`) by prefixing these command invocations with `$(npm bin)`; in
|
||||
particular `gulp` and `protractor` commands. If you prefer, you can drop this path prefix by
|
||||
globally installing these two packages as follows:
|
||||
particular `gulp` and `protractor` commands. If you prefer, you can drop this path prefix by either:
|
||||
|
||||
*Option 1*: globally installing these two packages as follows:
|
||||
|
||||
* `npm install -g gulp` (you might need to prefix this command with `sudo`)
|
||||
* `npm install -g protractor` (you might need to prefix this command with `sudo`)
|
||||
|
||||
Since global installs can become stale, we avoid their use in these instructions.
|
||||
Since global installs can become stale, and required versions can vary by project, we avoid their
|
||||
use in these instructions.
|
||||
|
||||
*Option 2*: defining a bash alias like `alias nbin='PATH=$(npm bin):$PATH'` as detailed in this
|
||||
[Stackoverflow answer](http://stackoverflow.com/questions/9679932/how-to-use-package-installed-locally-in-node-modules/15157360#15157360) and used like this: e.g., `nbin gulp build`.
|
||||
|
||||
## Build commands
|
||||
|
||||
|
@ -133,22 +132,35 @@ $(npm bin)/gulp clean
|
|||
|
||||
## Running Tests Locally
|
||||
|
||||
### Basic tests
|
||||
### Full test suite
|
||||
|
||||
1. `$(npm bin)/gulp test.unit.js`: JS tests in a browser; runs in **watch mode** (i.e. karma
|
||||
watches the test files for changes and re-runs tests when files are updated).
|
||||
2. `$(npm bin)/gulp test.unit.cjs`: JS tests in NodeJS; runs in **watch mode**
|
||||
3. `$(npm bin)/gulp test.unit.dart`: Dart tests in Dartium; runs in **watch mode**.
|
||||
* `npm test`: full test suite for both JS and Dart versions of Angular. These are the same tests as
|
||||
those run on Travis.
|
||||
|
||||
You can selectively run either the JS or Dart versions as follows:
|
||||
|
||||
* `$(npm bin)/gulp test.all.js`
|
||||
* `$(npm bin)/gulp test.all.dart`
|
||||
|
||||
### Unit tests
|
||||
|
||||
You can run just the unit tests as follows:
|
||||
|
||||
* `$(npm bin)/gulp test.unit.js`: JS tests in a browser; runs in **watch mode** (i.e. karma
|
||||
watches the test files for changes and re-runs tests when files are updated).
|
||||
* `$(npm bin)/gulp test.unit.cjs`: JS tests in NodeJS; runs in **watch mode**.
|
||||
* `$(npm bin)/gulp test.unit.dart`: Dart tests in Dartium; runs in **watch mode**.
|
||||
|
||||
If you prefer running tests in "single-run" mode rather than watch mode use
|
||||
|
||||
* `$(npm bin)/gulp test.unit.js/ci`
|
||||
* `$(npm bin)/gulp test.unit.cjs/ci`
|
||||
* `$(npm bin)/gulp test.unit.dart/ci`
|
||||
|
||||
**Note**: If you want to only run a single test you can alter the test you wish
|
||||
to run by changing `it` to `iit` or `describe` to `ddescribe`. This will only
|
||||
run that individual test and make it much easier to debug. `xit` and `xdescribe`
|
||||
can also be useful to exclude a test and a group of tests respectively.
|
||||
**Note**: If you want to only run a single test you can alter the test you wish to run by changing
|
||||
`it` to `iit` or `describe` to `ddescribe`. This will only run that individual test and make it
|
||||
much easier to debug. `xit` and `xdescribe` can also be useful to exclude a test and a group of
|
||||
tests respectively.
|
||||
|
||||
**Note** for transpiler tests: The karma preprocessor is setup in a way so that after every test
|
||||
run the transpiler is reloaded. With that it is possible to make changes to the preprocessor and
|
||||
|
@ -232,4 +244,3 @@ on the `debugger;` statement.
|
|||
You can then step into the code and add watches.
|
||||
The `debugger;` statement is needed because WebStorm will stop in a transpiled file. Breakpoints in
|
||||
the original source files are not supported at the moment.
|
||||
|
||||
|
|
24
gulpfile.js
24
gulpfile.js
|
@ -1,5 +1,6 @@
|
|||
var gulp = require('gulp');
|
||||
var gulpPlugins = require('gulp-load-plugins')();
|
||||
var shell = require('gulp-shell');
|
||||
var runSequence = require('run-sequence');
|
||||
var madge = require('madge');
|
||||
var merge = require('merge');
|
||||
|
@ -26,6 +27,7 @@ var runServerDartTests = require('./tools/build/run_server_dart_tests');
|
|||
var transformCJSTests = require('./tools/build/transformCJSTests');
|
||||
var util = require('./tools/build/util');
|
||||
|
||||
// Note: when DART_SDK is not found, all gulp tasks ending with `.dart` will be skipped.
|
||||
var DART_SDK = require('./tools/build/dartdetect')(gulp);
|
||||
// -----------------------
|
||||
// configuration
|
||||
|
@ -431,7 +433,11 @@ gulp.task('build/multicopy.dart', copy.multicopy(gulp, gulpPlugins, {
|
|||
// ------------
|
||||
// pubspec
|
||||
|
||||
gulp.task('build/pubspec.dart', pubget(gulp, gulpPlugins, {
|
||||
// Run a top-level `pub get` for this project.
|
||||
gulp.task('pubget.dart', pubget.dir(gulp, gulpPlugins, { dir: '.', command: DART_SDK.PUB }));
|
||||
|
||||
// Run `pub get` over CONFIG.dest.dart
|
||||
gulp.task('build/pubspec.dart', pubget.subDir(gulp, gulpPlugins, {
|
||||
dir: CONFIG.dest.dart,
|
||||
command: DART_SDK.PUB
|
||||
}));
|
||||
|
@ -588,6 +594,22 @@ createDocsTasks(true);
|
|||
createDocsTasks(false);
|
||||
|
||||
// ------------------
|
||||
// CI tests suites
|
||||
|
||||
gulp.task('test.js', function(done) {
|
||||
runSequence('test.transpiler.unittest', 'docs/test', 'test.unit.js/ci',
|
||||
'test.unit.cjs/ci', done);
|
||||
});
|
||||
|
||||
gulp.task('test.dart', function(done) {
|
||||
runSequence('test.transpiler.unittest', 'docs/test', 'test.unit.dart/ci', done);
|
||||
});
|
||||
|
||||
// Reuse the Travis scripts
|
||||
// TODO: rename test_*.sh to test_all_*.sh
|
||||
gulp.task('test.all.js', shell.task(['./scripts/ci/test_js.sh']))
|
||||
gulp.task('test.all.dart', shell.task(['./scripts/ci/test_dart.sh']))
|
||||
|
||||
// karma tests
|
||||
// These tests run in the browser and are allowed to access
|
||||
// HTML DOM APIs.
|
||||
|
|
|
@ -20,10 +20,8 @@
|
|||
"url": "https://github.com/angular/angular.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "npm run test-js && npm run test-dart",
|
||||
"test-js": "./scripts/ci/test_js.sh",
|
||||
"test-dart": "./scripts/ci/test_dart.sh",
|
||||
"postinstall": "./node_modules/.bin/bower install"
|
||||
"postinstall": "webdriver-manager update && bower install && gulp pubget.dart",
|
||||
"test": "gulp test.all.js && gulp test.all.dart"
|
||||
},
|
||||
"dependencies": {
|
||||
"es6-module-loader": "^0.9.2",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/false
|
||||
#!/bin/bash
|
||||
set -e -o pipefail
|
||||
|
||||
if [[ -z $ENV_SET ]]; then
|
||||
|
@ -95,4 +95,4 @@ if [[ -z $ENV_SET ]]; then
|
|||
echo NGDART_SCRIPT_DIR=$NGDART_SCRIPT_DIR
|
||||
$DART --version 2>&1
|
||||
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -4,8 +4,9 @@ set -e
|
|||
echo =============================================================================
|
||||
# go to project dir
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
source $SCRIPT_DIR/env_dart.sh
|
||||
cd $SCRIPT_DIR/../..
|
||||
|
||||
${SCRIPT_DIR}/test_unit_dart.sh
|
||||
./node_modules/.bin/gulp test.js --browsers=$KARMA_BROWSERS
|
||||
${SCRIPT_DIR}/test_server_dart.sh
|
||||
${SCRIPT_DIR}/test_e2e_dart.sh
|
||||
|
|
|
@ -4,7 +4,6 @@ set -e
|
|||
echo =============================================================================
|
||||
# go to project dir
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
source $SCRIPT_DIR/env_dart.sh
|
||||
cd $SCRIPT_DIR/../..
|
||||
|
||||
./node_modules/.bin/webdriver-manager update
|
||||
|
|
|
@ -4,7 +4,6 @@ set -e
|
|||
echo =============================================================================
|
||||
# go to project dir
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
source $SCRIPT_DIR/env_dart.sh
|
||||
cd $SCRIPT_DIR/../..
|
||||
|
||||
./node_modules/.bin/webdriver-manager update
|
||||
|
@ -21,4 +20,10 @@ trap killServer EXIT
|
|||
# wait for server to come up!
|
||||
sleep 10
|
||||
|
||||
./node_modules/.bin/protractor protractor-js.conf.js --browsers=${E2E_BROWSERS:-Dartium}
|
||||
# Let protractor use default browser unless one is specified.
|
||||
OPTIONS="";
|
||||
if [[ -n "$E2E_BROWSERS" ]]; then
|
||||
OPTIONS="--browsers=$E2E_BROWSERS";
|
||||
fi
|
||||
|
||||
./node_modules/.bin/protractor protractor-js.conf.js $OPTIONS
|
||||
|
|
|
@ -6,6 +6,11 @@ echo ===========================================================================
|
|||
SCRIPT_DIR=$(dirname $0)
|
||||
cd $SCRIPT_DIR/../..
|
||||
|
||||
${SCRIPT_DIR}/test_unit_js.sh
|
||||
# ${SCRIPT_DIR}/test_server_js.sh # JS doesn't yet have server tests
|
||||
# Issue #945 Travis still uses Dartium, and hence needs the env setup.
|
||||
# For local tests, when a developer doesn't have Dart, don't source env_dart.sh
|
||||
if ${SCRIPT_DIR}/env_dart.sh 2>&1 > /dev/null ; then
|
||||
source $SCRIPT_DIR/env_dart.sh
|
||||
fi
|
||||
|
||||
./node_modules/.bin/gulp test.js --browsers=${KARMA_BROWSERS:-ChromeCanary}
|
||||
${SCRIPT_DIR}/test_e2e_js.sh
|
||||
|
|
|
@ -4,7 +4,6 @@ set -e
|
|||
echo =============================================================================
|
||||
# go to project dir
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
source $SCRIPT_DIR/env_dart.sh
|
||||
cd $SCRIPT_DIR/../..
|
||||
|
||||
./node_modules/.bin/webdriver-manager update
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo =============================================================================
|
||||
# go to project dir
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
source $SCRIPT_DIR/env_dart.sh
|
||||
cd $SCRIPT_DIR/../..
|
||||
|
||||
./node_modules/.bin/gulp test.transpiler.unittest
|
||||
./node_modules/.bin/gulp test.unit.dart/ci --browsers=$KARMA_BROWSERS
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo =============================================================================
|
||||
# go to project dir
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
source $SCRIPT_DIR/env_dart.sh
|
||||
cd $SCRIPT_DIR/../..
|
||||
|
||||
./node_modules/.bin/gulp test.transpiler.unittest
|
||||
./node_modules/.bin/gulp docs/test
|
||||
./node_modules/.bin/gulp test.unit.js/ci --browsers=$KARMA_BROWSERS
|
||||
./node_modules/.bin/gulp test.unit.cjs/ci
|
|
@ -2,7 +2,21 @@ var util = require('./util');
|
|||
var spawn = require('child_process').spawn;
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function(gulp, plugins, config) {
|
||||
module.exports = {
|
||||
dir: pubGetDir,
|
||||
subDir: pubGetSubDir
|
||||
};
|
||||
|
||||
function pubGetDir(gulp, plugins, config) {
|
||||
return function() {
|
||||
return util.processToPromise(spawn(config.command, ['get'], {
|
||||
stdio: 'inherit',
|
||||
cwd: config.dir
|
||||
}));
|
||||
};
|
||||
};
|
||||
|
||||
function pubGetSubDir(gulp, plugins, config) {
|
||||
return function() {
|
||||
// We need to execute pubspec serially as otherwise we can get into trouble
|
||||
// with the pub cache...
|
||||
|
@ -14,4 +28,3 @@ module.exports = function(gulp, plugins, config) {
|
|||
});
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue