ci(language-service): enable language service tests in bazel (#23001)
PR Close #23001
This commit is contained in:

committed by
Alex Rickabaugh

parent
de0b13d41d
commit
9fb08e2377
@ -512,6 +512,9 @@ class PipesTable implements SymbolTable {
|
|||||||
values(): Symbol[] { return this.pipes.map(pipe => new PipeSymbol(pipe, this.context)); }
|
values(): Symbol[] { return this.pipes.map(pipe => new PipeSymbol(pipe, this.context)); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This matches .d.ts files that look like ".../<package-name>/<package-name>.d.ts",
|
||||||
|
const INDEX_PATTERN = /[\\/]([^\\/]+)[\\/]\1\.d\.ts$/;
|
||||||
|
|
||||||
class PipeSymbol implements Symbol {
|
class PipeSymbol implements Symbol {
|
||||||
private _tsType: ts.Type;
|
private _tsType: ts.Type;
|
||||||
public readonly kind: DeclarationKind = 'pipe';
|
public readonly kind: DeclarationKind = 'pipe';
|
||||||
@ -600,7 +603,18 @@ class PipeSymbol implements Symbol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function findClassSymbolInContext(type: StaticSymbol, context: TypeContext): ts.Symbol|undefined {
|
function findClassSymbolInContext(type: StaticSymbol, context: TypeContext): ts.Symbol|undefined {
|
||||||
const sourceFile = context.program.getSourceFile(type.filePath);
|
let sourceFile = context.program.getSourceFile(type.filePath);
|
||||||
|
if (!sourceFile) {
|
||||||
|
// This handles a case where an <packageName>/index.d.ts and a <packageName>/<packageName>.d.ts
|
||||||
|
// are in the same directory. If we are looking for <packageName>/<packageName> and didn't
|
||||||
|
// find it, look for <packageName>/index.d.ts as the program might have found that instead.
|
||||||
|
const p = type.filePath as string;
|
||||||
|
const m = p.match(INDEX_PATTERN);
|
||||||
|
if (m) {
|
||||||
|
const indexVersion = path.join(path.dirname(p), 'index.d.ts');
|
||||||
|
sourceFile = context.program.getSourceFile(indexVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (sourceFile) {
|
if (sourceFile) {
|
||||||
const moduleSymbol = (sourceFile as any).module || (sourceFile as any).symbol;
|
const moduleSymbol = (sourceFile as any).module || (sourceFile as any).symbol;
|
||||||
const exports = context.checker.getExportsOfModule(moduleSymbol);
|
const exports = context.checker.getExportsOfModule(moduleSymbol);
|
||||||
|
@ -10,7 +10,10 @@ ts_library(
|
|||||||
"mocks.ts",
|
"mocks.ts",
|
||||||
"test_support.ts",
|
"test_support.ts",
|
||||||
],
|
],
|
||||||
visibility = [":__subpackages__"],
|
visibility = [
|
||||||
|
":__subpackages__",
|
||||||
|
"//packages/language-service/test:__subpackages__",
|
||||||
|
],
|
||||||
deps = [
|
deps = [
|
||||||
"//packages:types",
|
"//packages:types",
|
||||||
"//packages/compiler",
|
"//packages/compiler",
|
||||||
|
@ -8,6 +8,7 @@ ts_library(
|
|||||||
deps = [
|
deps = [
|
||||||
"//packages:types",
|
"//packages:types",
|
||||||
"//packages/compiler",
|
"//packages/compiler",
|
||||||
|
"//packages/compiler-cli/test:test_utils",
|
||||||
"//packages/language-service",
|
"//packages/language-service",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -15,9 +16,14 @@ ts_library(
|
|||||||
jasmine_node_test(
|
jasmine_node_test(
|
||||||
name = "test",
|
name = "test",
|
||||||
bootstrap = ["angular/tools/testing/init_node_spec.js"],
|
bootstrap = ["angular/tools/testing/init_node_spec.js"],
|
||||||
|
data = [
|
||||||
|
"//packages/common:npm_package",
|
||||||
|
"//packages/core:npm_package",
|
||||||
|
"//packages/forms:npm_package",
|
||||||
|
],
|
||||||
# disable since tests are running but not yet passing
|
# disable since tests are running but not yet passing
|
||||||
tags = ["manual"],
|
|
||||||
deps = [
|
deps = [
|
||||||
|
":test_lib",
|
||||||
"//tools/testing:node",
|
"//tools/testing:node",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {isInBazel, setup} from '@angular/compiler-cli/test/test_support';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
@ -75,12 +76,19 @@ export class MockTypescriptHost implements ts.LanguageServiceHost {
|
|||||||
private scriptNames: string[], private data: MockData,
|
private scriptNames: string[], private data: MockData,
|
||||||
private node_modules: string = 'node_modules', private myPath: typeof path = path) {
|
private node_modules: string = 'node_modules', private myPath: typeof path = path) {
|
||||||
const moduleFilename = module.filename.replace(/\\/g, '/');
|
const moduleFilename = module.filename.replace(/\\/g, '/');
|
||||||
let angularIndex = moduleFilename.indexOf('@angular');
|
if (isInBazel()) {
|
||||||
if (angularIndex >= 0)
|
const support = setup();
|
||||||
this.angularPath = moduleFilename.substr(0, angularIndex).replace('/all/', '/all/@angular/');
|
this.nodeModulesPath = path.join(support.basePath, 'node_modules');
|
||||||
let distIndex = moduleFilename.indexOf('/dist/all');
|
this.angularPath = path.join(this.nodeModulesPath, '@angular');
|
||||||
if (distIndex >= 0)
|
} else {
|
||||||
this.nodeModulesPath = myPath.join(moduleFilename.substr(0, distIndex), 'node_modules');
|
const angularIndex = moduleFilename.indexOf('@angular');
|
||||||
|
if (angularIndex >= 0)
|
||||||
|
this.angularPath =
|
||||||
|
moduleFilename.substr(0, angularIndex).replace('/all/', '/all/@angular/');
|
||||||
|
const distIndex = moduleFilename.indexOf('/dist/all');
|
||||||
|
if (distIndex >= 0)
|
||||||
|
this.nodeModulesPath = myPath.join(moduleFilename.substr(0, distIndex), 'node_modules');
|
||||||
|
}
|
||||||
this.options = {
|
this.options = {
|
||||||
target: ts.ScriptTarget.ES5,
|
target: ts.ScriptTarget.ES5,
|
||||||
module: ts.ModuleKind.CommonJS,
|
module: ts.ModuleKind.CommonJS,
|
||||||
|
Reference in New Issue
Block a user