Merge pull request #3470 from tsauerwein/rendering-tests
Add rendering tests
This commit is contained in:
+19
-7
@@ -23,7 +23,10 @@ var createServer = exports.createServer = function(callback) {
|
||||
lib: [
|
||||
'src/**/*.js',
|
||||
'build/ol.ext/*.js',
|
||||
'test/spec/**/*.test.js'
|
||||
'test/spec/**/*.test.js',
|
||||
'test_rendering/spec/**/*.test.js',
|
||||
'build/test_requires.js',
|
||||
'build/test_rendering_requires.js'
|
||||
],
|
||||
main: 'examples/*.js'
|
||||
});
|
||||
@@ -41,12 +44,21 @@ var createServer = exports.createServer = function(callback) {
|
||||
getMain: function(req) {
|
||||
var main;
|
||||
var query = url.parse(req.url, true).query;
|
||||
if (query.id) {
|
||||
var referer = req.headers.referer;
|
||||
if (referer) {
|
||||
var from = path.join(process.cwd(),
|
||||
path.dirname(url.parse(referer).pathname));
|
||||
main = path.resolve(from, query.id + '.js');
|
||||
var referer = req.headers.referer;
|
||||
var pathName = url.parse(referer).pathname;
|
||||
if (pathName.indexOf('/test/') === 0) {
|
||||
main = path.resolve(
|
||||
path.join(process.cwd(), 'build'), 'test_requires.js');
|
||||
} else if (pathName.indexOf('/test_rendering/') === 0) {
|
||||
main = path.resolve(
|
||||
path.join(process.cwd(), 'build'), 'test_rendering_requires.js');
|
||||
} else {
|
||||
if (query.id) {
|
||||
if (referer) {
|
||||
var from = path.join(process.cwd(),
|
||||
path.dirname(url.parse(referer).pathname));
|
||||
main = path.resolve(from, query.id + '.js');
|
||||
}
|
||||
}
|
||||
}
|
||||
return main;
|
||||
|
||||
@@ -13,7 +13,7 @@ var wrench = require('wrench');
|
||||
var path = require('path');
|
||||
var glob = require('glob');
|
||||
|
||||
var runTestsuite = require('./test');
|
||||
var runTestsuite = require('./test').runTests;
|
||||
|
||||
// setup some pathes
|
||||
var dir = path.join(__dirname, '../src');
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* This task starts a dev server that provides a script loader for OpenLayers
|
||||
* and Closure Library and runs rendering tests in SlimerJS.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
var slimerjs = require('slimerjs-edge');
|
||||
|
||||
var serve = require('./serve');
|
||||
var listen = require('./test').listen;
|
||||
|
||||
|
||||
/**
|
||||
* Create the debug server and run tests.
|
||||
*/
|
||||
serve.createServer(function(err, server) {
|
||||
if (err) {
|
||||
process.stderr.write(err.message + '\n');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
listen(3001, 3005, server, function(err) {
|
||||
if (err) {
|
||||
process.stderr.write('Server failed to start: ' + err.message + '\n');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var address = server.address();
|
||||
var url = 'http://' + address.address + ':' + address.port;
|
||||
var profile = path.join(__dirname, '../build/slimerjs-profile');
|
||||
var args = [
|
||||
'-profile',
|
||||
profile,
|
||||
path.join(__dirname,
|
||||
'../test_rendering/test.js'),
|
||||
url + '/test_rendering/index.html'
|
||||
];
|
||||
|
||||
var child = spawn(slimerjs.path, args, {stdio: 'inherit'});
|
||||
child.on('exit', function(code) {
|
||||
// FIXME SlimerJS has a problem with returning the correct return
|
||||
// code when using a custom profile, see
|
||||
// https://github.com/laurentj/slimerjs/issues/333
|
||||
// as a work-around we are currently reading the return code from
|
||||
// a file created in the profile directory.
|
||||
// if this issue is fixed we should use the npm package 'slimerjs'
|
||||
// instead of the nightly build 'slimerjs-edge'.
|
||||
var exitstatus = path.join(profile, 'exitstatus');
|
||||
fs.readFile(exitstatus, {encoding: 'utf-8'}, function(err, data) {
|
||||
if (err) {
|
||||
process.stderr.write(
|
||||
'Error getting the exit status of SlimerJS' + '\n');
|
||||
process.stderr.write(err);
|
||||
process.exit(1);
|
||||
} else {
|
||||
process.exit(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
+4
-1
@@ -81,6 +81,9 @@ if (require.main === module) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = runTests;
|
||||
module.exports = {
|
||||
runTests: runTests,
|
||||
listen: listen
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user