Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Note: karma with dart is still not working because of how `karma-dart` loads `package:…` dependencies. Usage: ``` karma start karma-js.conf.js karma start karma-dart.conf.js ``` Make sure to set `DARTIUM_BIN` env variable. Refactors `js2dart`: - live outside of the traceur module (`tools/js2dart/index.js`) so it can be reused by gulp and karma - automatically build the sources in memory, so that `js2dart` can be used without running `gulp build` first - provide a way to specify the moduleName of a compilation run independently of the input filename. This helps error messages and source maps (not yet enabled) to report the correct file name Changes project setup: - add module `test_lib` that contains the primitives for tests (e.g. `describe`, `it`, …) - clean up some sources that had errors in them - module names in transpiled js and dart files don’t contain `lib`, `test` nor `src` any more (e.g. `di/di`).
- Loading branch information
Showing
26 changed files
with
335 additions
and
235 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
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,61 @@ | ||
// Karma configuration | ||
// Generated on Thu Sep 25 2014 11:52:02 GMT-0700 (PDT) | ||
|
||
module.exports = function(config) { | ||
config.set({ | ||
|
||
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' | ||
], | ||
|
||
karmaDartImports: { | ||
guinness: 'package:guinness/guinness_html.dart' | ||
}, | ||
|
||
preprocessors: { | ||
'modules/**/*.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', | ||
script: false, | ||
modules: 'register', | ||
types: true, | ||
// typeAssertions: true, | ||
// typeAssertionModule: 'assert', | ||
annotations: true | ||
}, | ||
resolveModuleName: function(fileName) { | ||
var moduleName = fileName | ||
.replace(/.*\/modules\//, '') | ||
.replace(/\/src\//, '/') | ||
.replace(/\/test\//, '/'); | ||
return moduleName; | ||
}, | ||
transformPath: function(fileName) { | ||
return fileName.replace('.js', '.dart'); | ||
} | ||
}, | ||
|
||
browsers: ['Dartium'] | ||
}); | ||
|
||
|
||
config.plugins.push(require('./tools/js2dart/karma-traceur-preprocessor')); | ||
}; |
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,50 @@ | ||
// Karma configuration | ||
// Generated on Thu Sep 25 2014 11:52:02 GMT-0700 (PDT) | ||
|
||
module.exports = function(config) { | ||
config.set({ | ||
|
||
frameworks: ['jasmine'], | ||
|
||
files: [ | ||
'node_modules/traceur/bin/traceur-runtime.js', | ||
'./karma-mock-annotations.js', | ||
'modules/**/test_lib/**/*.es6', | ||
'modules/**/*.js', | ||
'modules/**/*.es6', | ||
'test-main.js' | ||
], | ||
|
||
preprocessors: { | ||
'modules/**/*.js': ['traceur'], | ||
'modules/**/*.es6': ['traceur'] | ||
}, | ||
|
||
traceurPreprocessor: { | ||
options: { | ||
outputLanguage: 'es5', | ||
script: false, | ||
modules: 'register', | ||
types: true, | ||
// TODO: turn this on! | ||
// typeAssertions: true, | ||
// typeAssertionModule: 'assert', | ||
annotations: true | ||
}, | ||
resolveModuleName: function(fileName) { | ||
var moduleName = fileName | ||
.replace(/.*\/modules\//, '') | ||
.replace(/\/src\//, '/') | ||
.replace(/\/test\//, '/'); | ||
return moduleName; | ||
}, | ||
transformPath: function(fileName) { | ||
return fileName.replace('.es6', ''); | ||
} | ||
}, | ||
|
||
browsers: ['Chrome'] | ||
}); | ||
|
||
config.plugins.push(require('./tools/js2dart/karma-traceur-preprocessor')); | ||
}; |
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,3 @@ | ||
|
||
// TODO: Remove these annotations in the JS traceur build as they are only needed in Dart | ||
window.FIELD = function() {}; |
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 |
---|---|---|
|
@@ -9,4 +9,5 @@ dependencies: | |
facade: | ||
path: ../facade | ||
dev_dependencies: | ||
unittest: '>=0.10.1 <0.12.0' | ||
test_lib: | ||
path: ../test_lib |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ dependencies: | |
facade: | ||
path: ../facade | ||
dev_dependencies: | ||
unittest: '>=0.10.1 <0.12.0' | ||
test_lib: | ||
path: ../test_lib |
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,3 @@ | ||
export class Key { | ||
|
||
} |
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 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,6 @@ | ||
name: test_lib | ||
environment: | ||
sdk: '>=1.4.0' | ||
dependencies: | ||
dev_dependencies: | ||
guinness: ">=0.1.5 <0.2.0" |
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 @@ | ||
export 'package:guinness/guinness.dart' show describe, it, beforeEach, afterEach, expect; |
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,8 @@ | ||
export var describe = window.describe; | ||
export var it = window.it; | ||
export var beforeEach = window.beforeEach; | ||
export var afterEach = window.afterEach; | ||
export var expect = window.expect; | ||
|
||
// To make testing consistent between dart and js | ||
window.print = window.dump || window.console.log; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var TEST_REGEXP = /^\/base\/modules\/[^\/]*\/test\/.*/; | ||
|
||
Object.keys(window.__karma__.files).forEach(function(path) { | ||
if (TEST_REGEXP.test(path)) { | ||
var moduleName = path | ||
.replace(/.*\/modules\//, '') | ||
.replace(/\/src\//, '/') | ||
.replace(/\/test\//, '/') | ||
.replace(/\.\w*$/, ''); | ||
System.get(moduleName).main(); | ||
} | ||
}); |
Oops, something went wrong.