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
This commit is contained in:
Tobias Bosch
2014-09-28 13:55:01 -07:00
parent 817c005845
commit c79f0c3472
47 changed files with 338 additions and 508 deletions

View File

@ -1,5 +1,6 @@
// Karma configuration
// Generated on Thu Sep 25 2014 11:52:02 GMT-0700 (PDT)
var file2moduleName = require('./file2modulename');
module.exports = function(config) {
config.set({
@ -7,11 +8,12 @@ module.exports = function(config) {
frameworks: ['dart-unittest'],
files: [
{pattern: 'packages/**/*.dart', included: false},
{pattern: 'modules/*/src/**/*.js', included: false},
{pattern: 'modules/*/test/**/*.js', included: true},
{pattern: 'modules/**/*.dart', included: false},
'packages/browser/dart.js'
{pattern: 'modules/**/*_spec.js', included: true},
{pattern: 'modules/*/src/**/*', included: false},
{pattern: 'modules/*/test/**/*', included: false},
{pattern: 'tools/transpiler/spec/**/*_spec.js', included: true},
{pattern: 'tools/transpiler/spec/**/*', included: false},
'test-main.dart'
],
karmaDartImports: {
@ -19,18 +21,9 @@ module.exports = function(config) {
},
preprocessors: {
'modules/**/*.js': ['traceur']
'modules/**/*.js': ['traceur'],
'tools/**/*.js': ['traceur']
},
customFileHandlers: [{
urlRegex: /.*\/packages\/.*$/,
handler: function(request, response, fa, fb, basePath) {
var url = request.url;
var path = url.indexOf('?') > -1 ? url.substring(0, url.indexOf('?')) : url;
var contets = fs.readFileSync(basePath + path);
response.writeHead(200);
response.end(contets);
}
}],
traceurPreprocessor: {
options: {
outputLanguage: 'dart',
@ -41,13 +34,7 @@ module.exports = function(config) {
// typeAssertionModule: 'assert',
annotations: true
},
resolveModuleName: function(fileName) {
var moduleName = fileName
.replace(/.*\/modules\//, '')
.replace(/\/src\//, '/')
.replace(/\/test\//, '/');
return moduleName;
},
resolveModuleName: file2moduleName,
transformPath: function(fileName) {
return fileName.replace('.js', '.dart');
}