ci(compiler-cli): run compiler-cli tests in bazel (#22997)

PR Close #22997
This commit is contained in:
Chuck Jazdzewski
2018-03-21 14:22:06 -07:00
committed by Alex Rickabaugh
parent d9dc46e651
commit 4e004f3783
15 changed files with 618 additions and 219 deletions
@@ -0,0 +1,99 @@
load("//tools:defaults.bzl", "ts_library", "ts_web_test")
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
ts_library(
name = "mocks",
testonly = 1,
srcs = [
"mocks.ts",
],
deps = [
"//packages:types",
"//packages/compiler",
"//packages/compiler-cli",
"//packages/compiler-cli/test:test_utils",
"//packages/core",
],
)
# check_types_spec
ts_library(
name = "check_types_lib",
testonly = 1,
srcs = ["check_types_spec.ts"],
deps = [
":mocks",
"//packages/compiler-cli",
"//packages/compiler-cli/test:test_utils",
],
)
jasmine_node_test(
name = "check_types",
bootstrap = ["angular/tools/testing/init_node_spec.js"],
data = [
"//packages/common:npm_package",
"//packages/core:npm_package",
],
deps = [
":check_types_lib",
"//packages/core",
"//tools/testing:node",
],
)
# expression_diagnostics_spec
ts_library(
name = "expression_diagnostics_lib",
testonly = 1,
srcs = ["expression_diagnostics_spec.ts"],
deps = [
":mocks",
"//packages/compiler",
"//packages/compiler-cli",
"//packages/compiler-cli/test:test_utils",
"//packages/language-service",
],
)
jasmine_node_test(
name = "expression_diagnostics",
bootstrap = ["angular/tools/testing/init_node_spec.js"],
data = [
"//packages/common:npm_package",
"//packages/core:npm_package",
"//packages/forms:npm_package",
],
deps = [
":expression_diagnostics_lib",
"//packages/core",
"//tools/testing:node",
],
)
# symbol_query_spec
ts_library(
name = "symbol_query_lib",
testonly = 1,
srcs = ["symbol_query_spec.ts"],
deps = [
":mocks",
"//packages/compiler",
"//packages/compiler-cli",
"//packages/compiler-cli/test:test_utils",
"//packages/compiler/test:test_utils",
"//packages/language-service",
],
)
jasmine_node_test(
name = "symbol_query",
bootstrap = ["angular/tools/testing/init_node_spec.js"],
data = [
],
deps = [
":symbol_query_lib",
"//packages/core",
"//tools/testing:node",
],
)
@@ -19,6 +19,7 @@ import {DiagnosticContext, MockLanguageServiceHost, getDiagnosticTemplateInfo} f
describe('expression diagnostics', () => {
let registry: ts.DocumentRegistry;
let host: MockLanguageServiceHost;
let service: ts.LanguageService;
let context: DiagnosticContext;
@@ -15,11 +15,17 @@ import * as ts from 'typescript';
import {DiagnosticTemplateInfo} from '../../src/diagnostics/expression_diagnostics';
import {getClassFromStaticSymbol, getClassMembers, getPipesTable, getSymbolQuery} from '../../src/diagnostics/typescript_symbols';
import {Directory, MockAotContext} from '../mocks';
import {isInBazel, setup} from '../test_support';
function calcRootPath() {
const moduleFilename = module.filename.replace(/\\/g, '/');
const distIndex = moduleFilename.indexOf('/dist/all');
return moduleFilename.substr(0, distIndex);
function calculateAngularPath() {
if (isInBazel()) {
const support = setup();
return path.join(support.basePath, 'node_modules/@angular/*');
} else {
const moduleFilename = module.filename.replace(/\\/g, '/');
const distIndex = moduleFilename.indexOf('/dist/all');
return moduleFilename.substr(0, distIndex) + '/packages/*';
}
}
const realFiles = new Map<string, string>();
@@ -43,7 +49,7 @@ export class MockLanguageServiceHost implements ts.LanguageServiceHost {
strictNullChecks: true,
baseUrl: currentDirectory,
lib: ['lib.es2015.d.ts', 'lib.dom.d.ts'],
paths: {'@angular/*': [calcRootPath() + '/packages/*']}
paths: {'@angular/*': [calculateAngularPath()]}
};
this.context = new MockAotContext(currentDirectory, files);
}