bazel: compiler codegen test

This commit is contained in:
Jason Choi
2016-08-19 23:47:32 -07:00
parent fb3b490198
commit b5f97b0410
7 changed files with 82 additions and 15 deletions

37
BUILD
View File

@ -219,6 +219,41 @@ ts_library(
module_name = "@angular/compiler/test", module_name = "@angular/compiler/test",
) )
nodejs_binary(
name = "compiler_test_codegen_bin",
srcs = [":compiler_test_module"],
deps = [
"reflect-metadata",
],
entry_point = "modules/@angular/compiler/test/output/output_emitter_codegen.js",
)
genrule(
name = "compiler_test_codegen_ts",
outs = [
"modules/@angular/compiler/test/output/output_emitter_generated_typed.ts",
"modules/@angular/compiler/test/output/output_emitter_generated_untyped.ts",
],
tools = [
# This has to be put in tools so that its runfiles tree is also built.
":compiler_test_codegen_bin",
],
cmd = "$(location :compiler_test_codegen_bin) --node_path=modules/ $(OUTS)",
output_to_bindir = True,
)
ts_library(
name = "compiler_test_codegen_js",
srcs = [":compiler_test_codegen_ts"],
deps = [
":core",
":compiler",
":compiler_test_module",
],
tsconfig = "tools/cjs-jasmine/tsconfig-output_emitter_codegen.json",
root_dir = "modules/@angular/compiler/test",
)
ts_library( ts_library(
name = "core", name = "core",
srcs = glob( srcs = glob(
@ -539,7 +574,7 @@ ts_library(
jasmine_node_test( jasmine_node_test(
name = "compiler_test", name = "compiler_test",
srcs = [":compiler_test_module"], srcs = [":compiler_test_module", ":compiler_test_codegen_js"],
helpers = [":jasmine_helper"], helpers = [":jasmine_helper"],
size = "small", size = "small",
args = ["--node_path=modules:tools"], args = ["--node_path=modules:tools"],

View File

@ -0,0 +1,26 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import 'reflect-metadata';
import {writeFileSync} from 'fs';
import {emit as typedEmit} from './output_emitter_codegen_typed';
import {emit as untypedEmit} from './output_emitter_codegen_untyped';
// Usage:
// node path/to/output_emitter_codegen [typed output file] [untyped output file]
function main(argv: string[]) {
const [typed, untyped] = argv;
writeFileSync(typed, typedEmit());
writeFileSync(untyped, untypedEmit());
}
if (require.main === module) {
main(process.argv.slice(2));
}

View File

@ -13,16 +13,8 @@ import {TypeScriptEmitter} from '@angular/compiler/src/output/ts_emitter';
import {print} from '@angular/facade/src/lang'; import {print} from '@angular/facade/src/lang';
import {assetUrl} from '@angular/compiler/src/util'; import {assetUrl} from '@angular/compiler/src/util';
function unimplemented(): any {
throw new Error('unimplemented');
}
import {SimpleJsImportGenerator, codegenExportsVars, codegenStmts} from './output_emitter_util'; import {SimpleJsImportGenerator, codegenExportsVars, codegenStmts} from './output_emitter_util';
export function getExpressions(): any {
return unimplemented();
}
// Generator // Generator
export function emit() { export function emit() {
const emitter = new TypeScriptEmitter(new SimpleJsImportGenerator()); const emitter = new TypeScriptEmitter(new SimpleJsImportGenerator());

View File

@ -14,10 +14,6 @@ import {assetUrl} from '@angular/compiler/src/util';
import {SimpleJsImportGenerator, codegenExportsVars, codegenStmts} from './output_emitter_util'; import {SimpleJsImportGenerator, codegenExportsVars, codegenStmts} from './output_emitter_util';
export function getExpressions(): any {
throw new Error('unimplemented');
}
// Generator // Generator
export function emit() { export function emit() {
var emitter = new JavaScriptEmitter(new SimpleJsImportGenerator()); var emitter = new JavaScriptEmitter(new SimpleJsImportGenerator());

View File

@ -0,0 +1,9 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
export function getExpressions(): any;

View File

@ -0,0 +1,9 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
export function getExpressions(): any;

View File

@ -15,8 +15,8 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {browserDetection} from '@angular/platform-browser/testing/browser_util'; import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {expect} from '@angular/platform-browser/testing/matchers'; import {expect} from '@angular/platform-browser/testing/matchers';
import * as typed from './output_emitter_codegen_typed'; import * as typed from './output_emitter_generated_typed';
import * as untyped from './output_emitter_codegen_untyped'; import * as untyped from './output_emitter_generated_untyped';
import {ExternalClass, codegenStmts} from './output_emitter_util'; import {ExternalClass, codegenStmts} from './output_emitter_util';
export function main() { export function main() {