forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: simplify and make tests work in JS and Dart
* remove `wraps` syntax enhancements for imports and support new `import * as module from ...` syntax - default imports are the wrong construct for importing everything from a module * moved tests from transpiler to jasmine and karma - transpiler tests are included when running karma in main project folder - transpiler is reloaded after every test run in karma, so no need to restart karma when the transpiler has been changed. - removed own gulp build for transpiler and `postinstall.sh` as they are no more needed. - transpiler tests are now executed in Dart AND JavaScript (used to be executed only in Dart), which allowed to catch some bugs (see the bug with the import specification above). * made tests work in dart as well by using the following hack: - dependencies are loaded from the `build` folder, which makes running `gulp build` necessary before running karma for dart - for this to work, the dependencies are included in main `pubspec.yaml` of project - reason for the hack: `karma-dart` loads all `packages` urls directly from disc (should rather use the karma file list) * added explicit annotations `FIELD`, `ABSTRACT`, ... to `facade/lang.*` - needed for now that we can run tests and don't get errors for undefined annotations. * added `README.md` with details about the build and tests
- Loading branch information
Showing
47 changed files
with
339 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## Build | ||
|
||
### Prerequisites: | ||
|
||
1. `npm install` | ||
2. `pub get` | ||
3. `install -g gulp` | ||
4. `install -g karma` | ||
|
||
### Folder structure | ||
|
||
* `modules/*`: modules that will be loaded in the browser | ||
* `tools/*`: tools that are needed to build Angular | ||
|
||
### File endings | ||
|
||
* `*.js`: javascript files that get transpiled to Dart and EcmaScript 5 | ||
* `*.es6`: javascript files that get transpiled only to EcmaScript 5 | ||
* `*.es5`: javascript files that don't get transpiled | ||
* `*.dart`: dart files that don't get transpiled | ||
|
||
### Build: | ||
|
||
1. `gulp build` -> result is in `build` folder | ||
|
||
* will also to `pubg get` for the subfolders in `modules` | ||
and run `dartanalyzer` for every file that matches | ||
`<module>/src/<module>.dart`, e.g. `di/src/di.dart` | ||
|
||
2. `gulp clean` -> cleans the `build` folder | ||
|
||
### Tests: | ||
|
||
1. `karma start karma-js.conf.js`: JS tests | ||
2. `karma start karma-dart.conf.js`: JS tests | ||
|
||
Notes for all tests: | ||
|
||
The karma preprocessor is setup in a way so that after every test run | ||
the transpiler is reloaded. With that it is possible to make changes | ||
to the preprocessor and run the tests without exiting karma | ||
(just touch a test file that you would like to run). | ||
|
||
Restriction for Dart tests (for now): | ||
|
||
* Due to a bug `karma-dart` plugin, | ||
this will use the files in the `build` folder for resolving | ||
`package:` dependencies (created e.g. for `import ... from 'di:di'`). | ||
So you need to execute `gulp build` before this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function file2moduleName(filePath) { | ||
return filePath | ||
// module name should not include non word characters (e.g. '-') | ||
// -> important for Dart | ||
.replace(/[^\w.\/]/g, '_') | ||
// module name should be relative to `modules` and `tools` folder | ||
.replace(/.*\/modules\//, '') | ||
.replace(/.*\/tools\//, '') | ||
// module name should not include `src`, `test`, `lib` | ||
.replace(/\/src\//, '/') | ||
.replace(/\/lib\//, '/') | ||
.replace(/\/test\//, '/') | ||
// module name should not have a suffix | ||
.replace(/\.\w*$/, ''); | ||
} | ||
if (typeof module !== 'undefined') { | ||
module.exports = file2moduleName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ dependencies: | |
dev_dependencies: | ||
test_lib: | ||
path: ../test_lib | ||
facade: | ||
path: ../facade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.