Skip to content
Permalink
Browse files
CB-9429 Removes tests from resultant bundle
  • Loading branch information
Vladimir Kotikov committed Jul 31, 2015
1 parent d028966 commit 085167ffe2bd250b78b4cb0d6eedcbc3d25b3297
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
@@ -70,6 +70,6 @@ module.exports = function(grunt) {
grunt.registerTask('test', ['compile:test', 'jshint', '_test']);
grunt.registerTask('btest', ['compile:test', 'jshint', '_btest']);
grunt.registerTask('cover', ['compile', '_cover']);
grunt.registerTask('test-browserify', ['compile-browserify:test', 'jshint', '_test:skip-tests']);
grunt.registerTask('btest-browserify', ['compile-browserify:test', 'jshint', '_btest:skip-tests']);
grunt.registerTask('test-browserify', ['compile-browserify:test', 'jshint', '_test']);
grunt.registerTask('btest-browserify', ['compile-browserify:test', 'jshint', '_btest']);
};
@@ -19,7 +19,6 @@
var fs = require('fs');
var path = require('path');
var util = require('util');
var requireTr = require('./require-tr');
var bundle = require('./bundle-browserify');
var computeCommitId = require('./compute-commit-id');
var writeLicenseHeader = require('./write-license-header');
@@ -52,4 +51,4 @@ module.exports = function generate(platform, useWindowsLineEndings, platformVers
done();
});
});
}
};
@@ -35,8 +35,6 @@ var pathToVendor = path.join(__dirname, '..', 'vendor');
var pathToJasmine = path.join(__dirname, '..', '..', 'node_modules', 'jasmine-node', 'lib', 'jasmine-node');
var pathToTests = path.join(__dirname, '..', '..', 'test');

var SKIP_TESTS = false;

var template = fs.readFileSync(pathToTemplate, "utf-8");

// middlewar for GET '/cordova.test.js'
@@ -55,20 +53,16 @@ function root(req, res) {
"Content-Type": "text/html"
});

// When we testing browserify bundle, we don't need to include
// tests since they're already bundled with cordova.
if (!SKIP_TESTS) {
//FIXME in place collect thing is atrocious
//create the script tags to include
var tests = [];
collect(path.join(__dirname, '..', '..', 'test'), tests);
var specs = tests.map(function (file, path) {
return '<script src="' + file.replace(/\\/g, '/').replace(/^.*\/test\//, "/") +
'" type="text/javascript" charset="utf-8"></script>';
}).join('\n');

template = template.replace(/<!-- ##TESTS## -->/g, specs);
}
//FIXME in place collect thing is atrocious
//create the script tags to include
var tests = [];
collect(path.join(__dirname, '..', '..', 'test'), tests);
var specs = tests.map(function (file, path) {
return '<script src="' + file.replace(/\\/g, '/').replace(/^.*\/test\//, "/") +
'" type="text/javascript" charset="utf-8"></script>';
}).join('\n');

template = template.replace(/<!-- ##TESTS## -->/g, specs);

// write the document
res.end(template);
@@ -80,8 +74,7 @@ function routes(app) {
app.get('/', root);
}

module.exports = function(skipTests) {
SKIP_TESTS = skipTests;
module.exports = function() {
console.log('starting browser-based tests');

var vendor = connect.static(pathToVendor);
@@ -30,7 +30,7 @@ var jsdom = require("node-jsdom").jsdom;
var document = jsdom(undefined, { url: 'file:///jsdomtest.info/a?b#c' });
var window = document.parentWindow;

module.exports = function(callback, skipTests) {
module.exports = function(callback) {

console.log('starting node-based tests');

@@ -57,13 +57,11 @@ module.exports = function(callback, skipTests) {
// Set up dummy navigator object
navigator = window.navigator || {};

if (!skipTests) {
// load in our tests
var tests = [];
collect(path.join(__dirname, '..', '..', 'test'), tests);
for (var x in tests) {
eval(fs.readFileSync(tests[x], "utf-8"));
}
// load in our tests
var tests = [];
collect(path.join(__dirname, '..', '..', 'test'), tests);
for (var x in tests) {
eval(fs.readFileSync(tests[x], "utf-8"));
}

var env = jasmine.getEnv();
@@ -26,11 +26,11 @@ try {
module.exports = function(grunt) {
grunt.registerTask('_test', 'Runs test in node', function() {
var done = this.async();
require('./lib/test-jsdom')(done, arguments[0] === ('skip-tests'));
require('./lib/test-jsdom')(done);
});

grunt.registerTask('_btest', 'Runs tests in the browser', function() {
require('./lib/test-browser')(arguments[0] === ('skip-tests'));
require('./lib/test-browser')();
this.async(); // never finish.
});
};

0 comments on commit 085167f

Please sign in to comment.