build(ngc): run integration test hermetically
This ensures we run in a clean directory, using our real distribution. It finds bugs like @internal APIs needed to type-check in the offline compiler, as well as problems in package.json. Also move tsc-wrapped under tools/@angular
This commit is contained in:
parent
c6064a30a1
commit
3331321f64
2
build.sh
2
build.sh
|
@ -35,7 +35,7 @@ cd -
|
|||
TSCONFIG=./modules/tsconfig.json
|
||||
echo "====== (all)COMPILING: \$(npm bin)/tsc -p ${TSCONFIG} ====="
|
||||
# compile ts code
|
||||
TSC="node dist/tools/tsc-wrapped/src/main"
|
||||
TSC="node dist/tools/@angular/tsc-wrapped/src/main"
|
||||
$TSC -p modules/tsconfig.json
|
||||
|
||||
rm -rf ./dist/packages-dist
|
||||
|
|
|
@ -52,7 +52,6 @@ module.exports = function(config) {
|
|||
'karma-sauce-launcher',
|
||||
'karma-chrome-launcher',
|
||||
'karma-sourcemap-loader',
|
||||
'karma-dart',
|
||||
internalAngularReporter
|
||||
],
|
||||
|
||||
|
|
|
@ -78,18 +78,16 @@ At a high level, this program
|
|||
- these `.ts` files are written to the `genDir` path, then compiled together with the application.
|
||||
|
||||
## For developers
|
||||
Run the compiler from source:
|
||||
```
|
||||
# Build angular2 and the compiler
|
||||
./node_modules/.bin/tsc -p modules
|
||||
# Run it on the test project
|
||||
$ ./modules/@angular/compiler_cli./integrationtest.sh
|
||||
```
|
||||
|
||||
Release:
|
||||
```
|
||||
$ ./modules/@angular/compiler_cli./integrationtest.sh
|
||||
$ cp modules/@angular/compiler_cli/README.md modules/@angular/compiler_cli/package.json dist/all/@angular/compiler_cli
|
||||
# npm login as angular
|
||||
$ npm publish dist/all/@angular/compiler_cli --access=public
|
||||
./build.sh
|
||||
# Run the test once
|
||||
# (First edit the LINKABLE_PKGS to use npm link instead of npm install)
|
||||
$ ./scripts/ci-lite/offline_compiler_test.sh
|
||||
# Keep a package fresh in watch mode
|
||||
./node_modules/.bin/tsc -p modules/@angular/compiler/tsconfig-es5.json -w
|
||||
# Iterate on the test
|
||||
cd /tmp/wherever/e2e_test.1464388257/
|
||||
./node_modules/.bin/ngc
|
||||
./node_modules/.bin/jasmine test/*_spec.js
|
||||
```
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export {CodeGenerator} from './src/codegen';
|
||||
export {NodeReflectorHost} from './src/reflector_host';
|
||||
export * from 'tsc-wrapped';
|
||||
export * from '@angular/tsc-wrapped';
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
cd $(dirname $0)
|
||||
cd $(pwd)/../../..
|
||||
export NODE_PATH=$NODE_PATH:$(pwd)/dist/all:$(pwd)/dist/tools
|
||||
readonly TESTDIR="@angular/compiler_cli/integrationtest"
|
||||
rm -f modules/$TESTDIR/src/*.{ngfactory,css.shim}.ts
|
||||
node dist/all/@angular/compiler_cli/src/main -p modules/$TESTDIR
|
||||
node dist/tools/cjs-jasmine -- $TESTDIR/**/*_spec.js
|
|
@ -1,3 +1,11 @@
|
|||
// Only needed to satisfy the check in core/src/util/decorators.ts
|
||||
// TODO(alexeagle): maybe remove that check?
|
||||
require('reflect-metadata');
|
||||
|
||||
require('@angular/platform-server/src/parse5_adapter.js').Parse5DomAdapter.makeCurrent();
|
||||
require('zone.js/dist/zone-node.js');
|
||||
require('zone.js/dist/long-stack-trace-zone.js');
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import {BasicNgFactory} from '../src/basic.ngfactory';
|
||||
|
@ -6,7 +14,7 @@ import {ReflectiveInjector, DebugElement, getDebugNode} from '@angular/core';
|
|||
import {browserPlatform, BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
|
||||
|
||||
describe("template codegen output", () => {
|
||||
const outDir = path.join('dist', 'all', '@angular', 'compiler_cli', 'integrationtest', 'src');
|
||||
const outDir = 'src';
|
||||
|
||||
it("should lower Decorators without reflect-metadata", () => {
|
||||
const jsOutput = path.join(outDir, 'basic.js');
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
"angularCompilerOptions": {
|
||||
// For TypeScript 1.8, we have to lay out generated files
|
||||
// in the same source directory with your code.
|
||||
"genDir": ".",
|
||||
"legacyPackageLayout": false
|
||||
"genDir": "."
|
||||
},
|
||||
|
||||
"compilerOptions": {
|
||||
|
@ -11,13 +10,9 @@
|
|||
"experimentalDecorators": true,
|
||||
"noImplicitAny": true,
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../../../../dist/all/@angular/compiler_cli/integrationtest",
|
||||
"rootDir": "",
|
||||
"declaration": true,
|
||||
"lib": ["es6", "dom"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@angular/*": ["../../../../dist/all/@angular/*"]
|
||||
}
|
||||
"baseUrl": "."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
/// <reference path="../../../../node_modules/@types/node/index.d.ts" />
|
||||
/// <reference path="../../../../node_modules/@types/jasmine/index.d.ts" />
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
import * as ts from 'typescript';
|
||||
import * as path from 'path';
|
||||
import {AngularCompilerOptions} from 'tsc-wrapped';
|
||||
import {AngularCompilerOptions} from '@angular/tsc-wrapped';
|
||||
|
||||
import * as compiler from '@angular/compiler';
|
||||
import {ViewEncapsulation} from '@angular/core';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import 'reflect-metadata';
|
||||
|
||||
import * as ts from 'typescript';
|
||||
import * as tsc from 'tsc-wrapped';
|
||||
import * as tsc from '@angular/tsc-wrapped';
|
||||
|
||||
import {CodeGenerator} from './codegen';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {StaticReflectorHost, StaticSymbol} from './static_reflector';
|
||||
import * as ts from 'typescript';
|
||||
import {AngularCompilerOptions, MetadataCollector, ModuleMetadata} from 'tsc-wrapped';
|
||||
import {AngularCompilerOptions, MetadataCollector, ModuleMetadata} from '@angular/tsc-wrapped';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import {ImportGenerator, AssetUrl} from './compiler_private';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"@angular/compiler": ["../../../dist/packages-dist/compiler"],
|
||||
"@angular/platform-server": ["../../../dist/packages-dist/platform-server"],
|
||||
"@angular/platform-browser": ["../../../dist/packages-dist/platform-browser"],
|
||||
"tsc-wrapped": ["../../../dist/tools/tsc-wrapped"]
|
||||
"@angular/tsc-wrapped": ["../../../dist/tools/@angular/tsc-wrapped"]
|
||||
},
|
||||
"experimentalDecorators": true,
|
||||
"rootDir": ".",
|
||||
|
|
|
@ -434,9 +434,6 @@ export const PLATFORM_CORE_PROVIDERS =
|
|||
/* @ts2dart_Provider */ {provide: PlatformRef, useExisting: PlatformRef_})
|
||||
];
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const APPLICATION_CORE_PROVIDERS = /*@ts2dart_const*/[
|
||||
/* @ts2dart_Provider */ {provide: NgZone, useFactory: createNgZone, deps: []},
|
||||
ApplicationRef_,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"selenium-webdriver": ["../node_modules/@types/selenium-webdriver/index.d.ts"],
|
||||
"rxjs/*": ["../node_modules/rxjs/*"],
|
||||
"@angular/*": ["./@angular/*"],
|
||||
"tsc-wrapped": ["../dist/tools/tsc-wrapped"]
|
||||
"@angular/tsc-wrapped": ["../dist/tools/@angular/tsc-wrapped"]
|
||||
},
|
||||
"rootDir": ".",
|
||||
"inlineSourceMap": true,
|
||||
|
|
|
@ -9,11 +9,8 @@ cd `dirname $0`
|
|||
source ./env.sh
|
||||
cd ../..
|
||||
|
||||
$(npm bin)/tsc -p ./tools/tsconfig.json
|
||||
|
||||
node dist/tools/tsc-wrapped/src/main -p modules/tsconfig.json
|
||||
|
||||
# Compile the compiler_cli integration tests
|
||||
node dist/all/@angular/compiler_cli/src/main -p modules/@angular/compiler_cli/integrationtest
|
||||
$(npm bin)/tsc -p tools
|
||||
cp tools/@angular/tsc-wrapped/package.json dist/tools/@angular/tsc-wrapped
|
||||
node dist/tools/@angular/tsc-wrapped/src/main -p modules
|
||||
|
||||
echo 'travis_fold:end:BUILD'
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env bash
|
||||
set -ex -o pipefail
|
||||
|
||||
# These ones can be `npm link`ed for fast development
|
||||
LINKABLE_PKGS=(
|
||||
$(pwd)/dist/packages-dist/{common,core,compiler,compiler_cli,platform-{browser,server}}
|
||||
$(pwd)/dist/tools/@angular/tsc-wrapped
|
||||
)
|
||||
PKGS=(
|
||||
reflect-metadata
|
||||
typescript@next
|
||||
zone.js
|
||||
rxjs
|
||||
@types/{node,jasmine}
|
||||
jasmine
|
||||
)
|
||||
|
||||
TMPDIR=${TMPDIR:-.}
|
||||
readonly TMP=$TMPDIR/e2e_test.$(date +%s)
|
||||
mkdir -p $TMP
|
||||
cp -R -v modules/@angular/compiler_cli/integrationtest/* $TMP
|
||||
# Try to use the same versions as angular, in particular, this will
|
||||
# cause us to install the same rxjs version.
|
||||
cp -v package.json $TMP
|
||||
|
||||
# run in subshell to avoid polluting cwd
|
||||
(
|
||||
cd $TMP
|
||||
npm install ${PKGS[*]}
|
||||
# TODO(alexeagle): allow this to be npm link instead
|
||||
npm install ${LINKABLE_PKGS[*]}
|
||||
|
||||
# Compile the compiler_cli integration tests
|
||||
./node_modules/.bin/ngc
|
||||
|
||||
./node_modules/.bin/jasmine init
|
||||
# Run compiler_cli integration tests in node
|
||||
./node_modules/.bin/jasmine test/*_spec.js
|
||||
)
|
|
@ -22,6 +22,8 @@ echo 'travis_fold:start:test.buildPackages'
|
|||
echo 'travis_fold:end:test.buildPackages'
|
||||
|
||||
|
||||
./scripts/ci-lite/offline_compiler_test.sh
|
||||
|
||||
echo 'travis_fold:start:test.e2e.localChrome'
|
||||
cd dist/
|
||||
$(npm bin)/gulp serve &
|
||||
|
|
|
@ -31,18 +31,11 @@ node ./dist/tools/tsc-watch/ node runCmdsOnly
|
|||
echo 'travis_fold:end:test.unit.node'
|
||||
|
||||
|
||||
echo 'travis_fold:start:test.compiler_cli.node'
|
||||
|
||||
# Run compiler_cli integration tests in node
|
||||
node dist/tools/cjs-jasmine -- @angular/compiler_cli/integrationtest/**/*_spec.js
|
||||
|
||||
echo 'travis_fold:end:test.compiler_cli.node'
|
||||
|
||||
# rebuild since codegen has overwritten some files.
|
||||
node dist/all/@angular/compiler_cli/src/main -p modules/tsconfig.json
|
||||
|
||||
echo 'travis_fold:start:test.unit.localChrome'
|
||||
|
||||
# rebuild to codegen files in @angular/compiler/test
|
||||
node dist/all/@angular/compiler_cli/src/main -p modules/tsconfig.json
|
||||
|
||||
# Run unit tests in local chrome
|
||||
if [[ ${TRAVIS} ]]; then
|
||||
sh -e /etc/init.d/xvfb start
|
||||
|
|
|
@ -24,7 +24,7 @@ emit.
|
|||
## Releasing
|
||||
```
|
||||
$ $(npm bin)/tsc -p tools
|
||||
$ cp tools/tsc-wrapped/package.json dist/tools/tsc-wrapped/
|
||||
$ cp tools/tsc-wrapped/package.json dist/tools/@angular/tsc-wrapped/
|
||||
$ npm login [angular]
|
||||
$ npm publish dist/tools/tsc-wrapped
|
||||
$ npm publish dist/tools/@angular/tsc-wrapped
|
||||
```
|
|
@ -3,7 +3,7 @@ import fse = require('fs-extra');
|
|||
import path = require('path');
|
||||
import * as ts from 'typescript';
|
||||
import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';
|
||||
import {MetadataCollector} from '../tsc-wrapped';
|
||||
import {MetadataCollector} from '../@angular/tsc-wrapped';
|
||||
|
||||
type FileRegistry = ts.Map<{version: number}>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue