angular-cn/packages/compiler-cli/test/transformers
Pete Bacon Darwin 7186f9c016 refactor(ivy): implement a virtual file-system layer in ngtsc + ngcc (#30921)
To improve cross platform support, all file access (and path manipulation)
is now done through a well known interface (`FileSystem`).

For testing a number of `MockFileSystem` implementations are provided.
These provide an in-memory file-system which emulates operating systems
like OS/X, Unix and Windows.

The current file system is always available via the static method,
`FileSystem.getFileSystem()`. This is also used by a number of static
methods on `AbsoluteFsPath` and `PathSegment`, to avoid having to pass
`FileSystem` objects around all the time. The result of this is that one
must be careful to ensure that the file-system has been initialized before
using any of these static methods. To prevent this happening accidentally
the current file system always starts out as an instance of `InvalidFileSystem`,
which will throw an error if any of its methods are called.

You can set the current file-system by calling `FileSystem.setFileSystem()`.
During testing you can call the helper function `initMockFileSystem(os)`
which takes a string name of the OS to emulate, and will also monkey-patch
aspects of the TypeScript library to ensure that TS is also using the
current file-system.

Finally there is the `NgtscCompilerHost` to be used for any TypeScript
compilation, which uses a given file-system.

All tests that interact with the file-system should be tested against each
of the mock file-systems. A series of helpers have been provided to support
such tests:

* `runInEachFileSystem()` - wrap your tests in this helper to run all the
wrapped tests in each of the mock file-systems.
* `addTestFilesToFileSystem()` - use this to add files and their contents
to the mock file system for testing.
* `loadTestFilesFromDisk()` - use this to load a mirror image of files on
disk into the in-memory mock file-system.
* `loadFakeCore()` - use this to load a fake version of `@angular/core`
into the mock file-system.

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

PR Close #30921
2019-06-25 16:25:24 -07:00
..
BUILD.bazel build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871) 2019-02-28 12:06:36 -08:00
compiler_host_spec.ts build: add moduleName to ngFactory sourcefiles (#29385) 2019-03-19 01:10:49 -04:00
inline_resources_spec.ts fix(compiler-cli): enableResourceInlining handles both styles and styleUrls (#22688) 2018-03-11 22:14:32 -07:00
lower_expressions_spec.ts feat(ivy): @NgModule -> ngInjectorDef compilation (#22458) 2018-03-16 12:57:11 -07:00
metadata_reader_spec.ts refactor(compiler): remove old ngtools api and add listLazyRoutes to new api (#19836) 2017-10-23 18:46:04 -04:00
nocollapse_hack_spec.ts fix(ivy): add @nocollapse when writing closure-annotated code (#25775) 2018-09-11 06:53:21 -07:00
node_emitter_spec.ts build(bazel): use bazel managed node_modules for downstream angular from source build support (#24663) 2018-07-26 17:02:21 -07:00
program_spec.ts refactor(ivy): implement a virtual file-system layer in ngtsc + ngcc (#30921) 2019-06-25 16:25:24 -07:00
r3_metadata_transform_spec.ts feat(compiler-cli): reflect static methods added to classes in metadata (#21926) 2018-02-01 08:30:58 -08:00
r3_transform_spec.ts ci(compiler-cli): run compiler-cli tests in bazel (#22997) 2018-03-28 10:02:53 -07:00