Permalink
Browse files

try to use a postinstall hook for ci.testling. see #10

the hook generates "bundles" with all source files and specs to avoid a timeout
and circunvent testling limitations.
  • Loading branch information...
1 parent 35f204d commit 19a569e5d08990868b7262d9bb12da1b4f720c1c @millermedeiros millermedeiros committed Feb 28, 2013
Showing with 65 additions and 2 deletions.
  1. +5 −0 .gitignore
  2. +0 −2 .npmignore
  3. +57 −0 build.js
  4. +3 −0 package.json
View
@@ -12,6 +12,8 @@ ehthumbs.db
Icon?
Thumbs.db
+npm-debug.log
+
# ================
# project specific
@@ -26,6 +28,9 @@ coverage/
# ignore HTML docs since they are only useful for gh-pages branch
doc_html/
+# these files are only needed by testling
+tests/testling/
+
# -----------------------------------
# ignore files added by `npm publish`
View
@@ -27,6 +27,4 @@ coverage/
# after build (see issue #102)
component.json
-updateDocs.sh
-clean.sh
build.js
View
@@ -41,6 +41,10 @@ _cli
.description('bump version number, update packages and run tests')
.action( cmd(release) );
+_cli
+ .command('ci')
+ .description('prepare files for ci.testling.')
+ .action( cmd(generateTestBundle) );
_cli.parse(process.argv);
@@ -153,3 +157,56 @@ function updateJsonVersion(path, version) {
fs.writeFileSync(path, JSON.stringify(target, null, ' '), _config.ENCODING);
}
+
+// ci.testling.com can't load relative resources so we need to bundle all the
+// source files and tests into few files to make it work properly.
+// we can't use rawgithub.com to load the files dynamically since it can
+// timeout and was causing more issues (see #10).
+function generateTestBundle(){
+ // tests folder is on .npmignore so it should only exist if user cloned
+ // the repository directly which is enough to avoid running this action if
+ // not necessary
+ // ---
+ // this is just a quick hack to circunvent testling limitations until they
+ // update npm to 1.2.0, provide some environment variable, or support dynamic
+ // load of specs/modules.
+
+ var fs = require('fs');
+ fs.exists('tests', function(exists){
+ if (exists) {
+
+ var rjs = require('requirejs');
+ _helpers.echo('generateTestBundle: generating AMD bundles...');
+
+ // yes, it's ugly but works for now.
+ rjs.optimize({
+ logLevel : 3,
+ baseUrl : '.',
+ optimize: 'none',
+ name : 'mout/index',
+ paths : {
+ 'mout' : 'src'
+ },
+ out : 'tests/testling/src.js'
+ }, function(){
+
+ rjs.optimize({
+ logLevel : 3,
+ baseUrl : '.',
+ optimize: 'none',
+ name : 'spec/spec-index',
+ paths : {
+ 'mout' : 'empty:',
+ 'spec' : 'tests/spec'
+ },
+ out : 'tests/testling/specs.js'
+ }, function(){
+ _helpers.echo('generateTestBundle: done.');
+ });
+
+ });
+
+ }
+ });
+}
+
View
@@ -33,6 +33,7 @@
},
"main": "./index.js",
"scripts": {
+ "postinstall": "node build ci",
"prepublish": "node build cjs .",
"pretest": "node build pkg",
"test": "node node_modules/istanbul/lib/cli test tests/runner.js --hook-run-in-context"
@@ -65,6 +66,8 @@
"tests/lib/jasmine/jasmine.async.js",
"tests/lib/jasmine/jasmine-tap.js",
"tests/lib/requirejs/require.js",
+ "tests/testling/src.js",
+ "tests/testling/specs.js",
"tests/runner.js"
]
}

0 comments on commit 19a569e

Please sign in to comment.