test(ivy): update //packages/compiler tests for Ivy (#27301)

Most of the specs in these tests are not relevant to Ivy:

//packages/compiler/test:test
//packages/compiler/test:test_web_chromium-local

However, a few test pieces of the compiler infrastructure that are used in
Ivy, and new BUILD.bazel files are created to separate them from the above
disabled targets:

//packages/compiler/test/css_parser:css_parser
//packages/compiler/test/css_parser:css_parser_web
//packages/compiler/test/expression_parser:expression_parser
//packages/compiler/test/expression_parser:expression_parser_web
//packages/compiler/test/ml_parser:ml_parser
//packages/compiler/test/ml_parser:ml_parser_web
//packages/compiler/test/selector:selector
//packages/compiler/test/selector:selector_web

PR Close #27301
This commit is contained in:
Alex Rickabaugh 2018-11-27 12:32:14 -08:00 committed by Igor Minar
parent 49537458ea
commit 4effb89ae8
11 changed files with 185 additions and 45 deletions

View File

@ -38,6 +38,7 @@ ts_library(
"//packages/common",
"//packages/compiler",
"//packages/compiler/test/expression_parser/utils",
"//packages/compiler/test/ml_parser/util",
"//packages/compiler/testing",
"//packages/core",
"//packages/core/testing",
@ -75,7 +76,8 @@ jasmine_node_test(
"//packages/core:npm_package",
],
tags = [
"fixme-ivy-aot",
# Disabled as these tests pertain to the old ngc compilation and are not relevant in Ivy.
"no-ivy-aot",
],
deps = [
":test_lib",
@ -90,7 +92,8 @@ jasmine_node_test(
ts_web_test_suite(
name = "test_web",
tags = [
"fixme-ivy-aot",
# Disabled as these tests pertain to the old ngc compilation and are not relevant in Ivy.
"no-ivy-aot",
],
deps = [
":test_lib",

View File

@ -0,0 +1,30 @@
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library", "ts_web_test_suite")
ts_library(
name = "css_parser_lib",
testonly = True,
srcs = glob(["**/*.ts"]),
deps = [
"//packages:types",
"//packages/compiler/testing",
"//packages/core/testing",
"//packages/platform-browser",
"//packages/platform-browser/testing",
],
)
jasmine_node_test(
name = "css_parser",
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":css_parser_lib",
"//tools/testing:node",
],
)
ts_web_test_suite(
name = "css_parser_web",
deps = [
":css_parser_lib",
],
)

View File

@ -0,0 +1,30 @@
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library", "ts_web_test_suite")
ts_library(
name = "expression_parser_lib",
testonly = True,
srcs = glob(["**/*.ts"]),
deps = [
"//packages:types",
"//packages/compiler",
"//packages/compiler/test/expression_parser/utils",
"//packages/compiler/testing",
"//packages/platform-browser/testing",
],
)
jasmine_node_test(
name = "expression_parser",
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":expression_parser_lib",
"//tools/testing:node",
],
)
ts_web_test_suite(
name = "expression_parser_web",
deps = [
":expression_parser_lib",
],
)

View File

@ -14,7 +14,7 @@ import {extractMessages, mergeTranslations} from '../../src/i18n/extractor_merge
import * as i18n from '../../src/i18n/i18n_ast';
import {TranslationBundle} from '../../src/i18n/translation_bundle';
import * as html from '../../src/ml_parser/ast';
import {serializeNodes as serializeHtmlNodes} from '../ml_parser/ast_serializer_spec';
import {serializeNodes as serializeHtmlNodes} from '../ml_parser/util/util';
{
describe('Extractor', () => {

View File

@ -12,7 +12,7 @@ import * as i18n from '../../src/i18n/i18n_ast';
import {TranslationBundle} from '../../src/i18n/translation_bundle';
import * as html from '../../src/ml_parser/ast';
import {ParseLocation, ParseSourceFile, ParseSourceSpan} from '../../src/parse_util';
import {serializeNodes} from '../ml_parser/ast_serializer_spec';
import {serializeNodes} from '../ml_parser/util/util';
import {_extractMessages} from './i18n_parser_spec';

View File

@ -0,0 +1,28 @@
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library", "ts_web_test_suite")
ts_library(
name = "ml_parser_lib",
testonly = True,
srcs = glob(["**/*.ts"]),
deps = [
"//packages:types",
"//packages/compiler",
"//packages/compiler/test/ml_parser/util",
],
)
jasmine_node_test(
name = "ml_parser",
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":ml_parser_lib",
"//tools/testing:node",
],
)
ts_web_test_suite(
name = "ml_parser_web",
deps = [
":ml_parser_lib",
],
)

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import * as html from '@angular/compiler/src/ml_parser/ast';
import {HtmlParser} from '@angular/compiler/src/ml_parser/html_parser';
import {getHtmlTagDefinition} from '@angular/compiler/src/ml_parser/html_tags';
import {serializeNodes} from './util/util';
{
describe('Node serializer', () => {
@ -59,42 +58,3 @@ import {getHtmlTagDefinition} from '@angular/compiler/src/ml_parser/html_tags';
});
});
}
class _SerializerVisitor implements html.Visitor {
visitElement(element: html.Element, context: any): any {
if (getHtmlTagDefinition(element.name).isVoid) {
return `<${element.name}${this._visitAll(element.attrs, ' ')}/>`;
}
return `<${element.name}${this._visitAll(element.attrs, ' ')}>${this._visitAll(element.children)}</${element.name}>`;
}
visitAttribute(attribute: html.Attribute, context: any): any {
return `${attribute.name}="${attribute.value}"`;
}
visitText(text: html.Text, context: any): any { return text.value; }
visitComment(comment: html.Comment, context: any): any { return `<!--${comment.value}-->`; }
visitExpansion(expansion: html.Expansion, context: any): any {
return `{${expansion.switchValue}, ${expansion.type},${this._visitAll(expansion.cases)}}`;
}
visitExpansionCase(expansionCase: html.ExpansionCase, context: any): any {
return ` ${expansionCase.value} {${this._visitAll(expansionCase.expression)}}`;
}
private _visitAll(nodes: html.Node[], join: string = ''): string {
if (nodes.length == 0) {
return '';
}
return join + nodes.map(a => a.visit(this, null)).join(join);
}
}
const serializerVisitor = new _SerializerVisitor();
export function serializeNodes(nodes: html.Node[]): string[] {
return nodes.map(node => node.visit(serializerVisitor, null));
}

View File

@ -0,0 +1,12 @@
load("//tools:defaults.bzl", "ts_library")
ts_library(
name = "util",
testonly = True,
srcs = glob(["**/*.ts"]),
visibility = ["//visibility:public"],
deps = [
"//packages:types",
"//packages/compiler",
],
)

View File

@ -0,0 +1,49 @@
/**
* @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 * as html from '@angular/compiler/src/ml_parser/ast';
import {getHtmlTagDefinition} from '@angular/compiler/src/ml_parser/html_tags';
class _SerializerVisitor implements html.Visitor {
visitElement(element: html.Element, context: any): any {
if (getHtmlTagDefinition(element.name).isVoid) {
return `<${element.name}${this._visitAll(element.attrs, ' ')}/>`;
}
return `<${element.name}${this._visitAll(element.attrs, ' ')}>${this._visitAll(element.children)}</${element.name}>`;
}
visitAttribute(attribute: html.Attribute, context: any): any {
return `${attribute.name}="${attribute.value}"`;
}
visitText(text: html.Text, context: any): any { return text.value; }
visitComment(comment: html.Comment, context: any): any { return `<!--${comment.value}-->`; }
visitExpansion(expansion: html.Expansion, context: any): any {
return `{${expansion.switchValue}, ${expansion.type},${this._visitAll(expansion.cases)}}`;
}
visitExpansionCase(expansionCase: html.ExpansionCase, context: any): any {
return ` ${expansionCase.value} {${this._visitAll(expansionCase.expression)}}`;
}
private _visitAll(nodes: html.Node[], join: string = ''): string {
if (nodes.length == 0) {
return '';
}
return join + nodes.map(a => a.visit(this, null)).join(join);
}
}
const serializerVisitor = new _SerializerVisitor();
export function serializeNodes(nodes: html.Node[]): string[] {
return nodes.map(node => node.visit(serializerVisitor, null));
}

View File

@ -0,0 +1,28 @@
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library", "ts_web_test_suite")
ts_library(
name = "selector_lib",
testonly = True,
srcs = glob(["**/*.ts"]),
deps = [
"//packages:types",
"//packages/compiler/testing",
"//packages/core/testing",
],
)
jasmine_node_test(
name = "selector",
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":selector_lib",
"//tools/testing:node",
],
)
ts_web_test_suite(
name = "selector_web",
deps = [
":selector_lib",
],
)