Skip to content

Commit 2564b45

Browse files
devversionpkozlowski-opensource
authored andcommitted
test: replace fake_core with real @angular/core output (#54650)
This commit replaces `fake_core` with the real `@angular/core` output. See previous commit for reasons. Overall, this commit: * Replaces references of `fake_core` * Fixes tests that were testing Angular compiler detection that _would_ already be flagged by type-checking of TS directly. We keep these tests for now, and add `@ts-ignore` to verify the Angular checks, in case type checking is disabled in user applications- but it's worth considering to remove these tests. Follow-up question/non-priority. * Adds `@ts-ignore` to the tests for `defer` 1P because the property is marked as `@internal` and now is (correctly) causing failures in the compiler test environment. * Fixes a couple of tests with typos, wrong properties etc that previously weren't detected! A good sign. PR Close #54650
1 parent 5afa4f0 commit 2564b45

File tree

66 files changed

+215
-453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+215
-453
lines changed

packages/compiler-cli/src/ngtsc/file_system/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ wrapped tests in each of the mock file-systems, it calls `initMockFileSystem()`
4747
for each OS to emulate.
4848
* `loadTestFiles()` - use this to add files and their contents
4949
to the mock file system for testing.
50-
* `loadStandardTestFiles()` - use this to load a mirror image of files on
51-
disk into the in-memory mock file-system.
52-
* `loadFakeCore()` - use this to load a fake version of `@angular/core`
50+
* `loadStandardTestFiles()` - use this to load a mirror image of Angular test
51+
files on disk into the in-memory mock file-system.
52+
* `loadAngularCore()` - use this to load the npm package of `@angular/core`
5353
into the mock file-system.
5454

5555
All ngtsc source and tests now use this virtual file-system setup.

packages/compiler-cli/src/ngtsc/metadata/test/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jasmine_node_test(
2626
name = "test",
2727
bootstrap = ["//tools/testing:node_no_angular"],
2828
data = [
29-
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
29+
"//packages/core:npm_package",
3030
],
3131
deps =
3232
[

packages/compiler-cli/src/ngtsc/metadata/test/dts_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import {absoluteFrom, getFileSystem, getSourceFileOrError} from '../../file_syst
1010
import {runInEachFileSystem} from '../../file_system/testing';
1111
import {OwningModule, Reference} from '../../imports';
1212
import {isNamedClassDeclaration, TypeScriptReflectionHost} from '../../reflection';
13-
import {loadFakeCore, makeProgram} from '../../testing';
13+
import {loadAngularCore, makeProgram} from '../../testing';
1414
import {DtsMetadataReader} from '../src/dts';
1515
import {isHostDirectiveMetaForGlobalMode} from '../src/util';
1616

1717
runInEachFileSystem(() => {
1818
beforeEach(() => {
19-
loadFakeCore(getFileSystem());
19+
loadAngularCore(getFileSystem());
2020
});
2121

2222
describe('DtsMetadataReader', () => {

packages/compiler-cli/src/ngtsc/testing/fake_common/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ts_library(
99
],
1010
module_name = "@angular/common",
1111
deps = [
12-
"//packages/compiler-cli/src/ngtsc/testing/fake_core",
12+
"//packages/core",
1313
],
1414
)
1515

packages/compiler-cli/src/ngtsc/testing/fake_core/BUILD.bazel

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/compiler-cli/src/ngtsc/testing/fake_core/README.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/compiler-cli/src/ngtsc/testing/fake_core/index.ts

Lines changed: 0 additions & 237 deletions
This file was deleted.

packages/compiler-cli/src/ngtsc/testing/fake_core/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/compiler-cli/src/ngtsc/testing/src/mock_file_loading.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,16 @@ const angularFolder = new CachedFolder(loadAngularFolder);
4545
const rxjsFolder = new CachedFolder(() => loadFolder(resolveFromRunfiles('npm/node_modules/rxjs')));
4646

4747
export function loadStandardTestFiles(
48-
{fakeCore = true, fakeCommon = false, rxjs = false}:
49-
{fakeCore?: boolean, fakeCommon?: boolean, rxjs?: boolean} = {}): Folder {
48+
{fakeCommon = false, rxjs = false}: {fakeCommon?: boolean, rxjs?: boolean} = {}): Folder {
5049
const tmpFs = new MockFileSystemPosix(true);
5150
const basePath = '/' as AbsoluteFsPath;
5251

5352
tmpFs.mount(tmpFs.resolve('/node_modules/typescript'), typescriptFolder.get());
53+
tmpFs.mount(tmpFs.resolve('/node_modules/@angular'), angularFolder.get());
5454

5555
loadTsLib(tmpFs, basePath);
5656

57-
if (fakeCore) {
58-
loadFakeCore(tmpFs, basePath);
59-
} else {
60-
tmpFs.mount(tmpFs.resolve('/node_modules/@angular'), angularFolder.get());
61-
}
62-
57+
// TODO: Consider removing.
6358
if (fakeCommon) {
6459
loadFakeCommon(tmpFs, basePath);
6560
}
@@ -77,13 +72,6 @@ export function loadTsLib(fs: FileSystem, basePath: string = '/') {
7772
fs.resolve(basePath, 'node_modules/tslib'));
7873
}
7974

80-
export function loadFakeCore(fs: FileSystem, basePath: string = '/') {
81-
loadTestDirectory(
82-
fs,
83-
resolveFromRunfiles('angular/packages/compiler-cli/src/ngtsc/testing/fake_core/npm_package'),
84-
fs.resolve(basePath, 'node_modules/@angular/core'));
85-
}
86-
8775
export function loadFakeCommon(fs: FileSystem, basePath: string = '/') {
8876
loadTestDirectory(
8977
fs,
@@ -92,6 +80,11 @@ export function loadFakeCommon(fs: FileSystem, basePath: string = '/') {
9280
fs.resolve(basePath, 'node_modules/@angular/common'));
9381
}
9482

83+
export function loadAngularCore(fs: FileSystem, basePath: string = '/') {
84+
loadTestDirectory(
85+
fs, resolveFromRunfiles('angular/packages/core/npm_package'),
86+
fs.resolve(basePath, 'node_modules/@angular/core'));
87+
}
9588

9689
function loadFolder(path: string): Folder {
9790
const tmpFs = new MockFileSystemPosix(true);

packages/compiler-cli/src/ngtsc/typecheck/extended/test/checks/interpolated_signal_not_invoked/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jasmine_node_test(
2222
name = "test",
2323
bootstrap = ["//tools/testing:node_no_angular"],
2424
data = [
25-
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
25+
"//packages/core:npm_package",
2626
],
2727
deps = [
2828
":test_lib",

0 commit comments

Comments
 (0)