Load the examples using PhantomJS

This commit adds a check-examples target to check that the hosted examples load without errors.
This commit is contained in:
Éric Lemoine
2013-03-03 19:38:25 +01:00
parent bf50828a0d
commit 337fd11a05
4 changed files with 63 additions and 1 deletions

30
bin/check-example.js Normal file
View File

@@ -0,0 +1,30 @@
//
// A PhantomJS script used to check that the hosted examples load
// without errors. This script is executed by the build tool's
// check-examples target.
//
var args = require('system').args;
if (args.length != 2) {
phantom.exit(2);
}
var examplePath = args[1];
var page = require('webpage').create();
page.onError = function(msg, trace) {
var msgStack = ['JavaScript ERROR: ' + msg];
if (trace) {
msgStack.push('TRACE:');
trace.forEach(function(t) {
msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function + '")' : ''));
});
}
console.error(msgStack.join('\n'));
phantom.exit(1);
};
page.open(examplePath, function(s) {
var exitCode = 0;
if (s != 'success') {
exitCode = 1;
console.error('PAGE LOAD ERROR');
}
phantom.exit(exitCode);
});

View File

@@ -95,7 +95,7 @@ def report_sizes(t):
virtual('all', 'build-all', 'build', 'examples', 'precommit')
virtual('precommit', 'lint', 'build-all', 'test', 'build', 'build-examples', 'doc')
virtual('precommit', 'lint', 'build-all', 'test', 'build', 'build-examples', 'check-examples', 'doc')
virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-simple.js', 'build/ol-whitespace.js')
@@ -356,6 +356,17 @@ def hostexamples(t):
t.cp('examples/example-list.js', 'examples/example-list.xml', 'examples/Jugl.js', 'build/gh-pages/%(BRANCH)s/examples/')
@target('check-examples', 'hostexamples', phony=True)
def check_examples(t):
directory = 'build/gh-pages/%(BRANCH)s/'
examples = ['build/gh-pages/%(BRANCH)s/' + e for e in EXAMPLES]
all_examples = examples + \
[e + '?mode=simple' for e in examples] + \
[e + '?mode=whitespace' for e in examples]
for example in all_examples:
t.run('%(PHANTOMJS)s', 'bin/check-example.js', example)
@target(PROJ4JS, PROJ4JS_ZIP)
def proj4js(t):
from zipfile import ZipFile

View File

@@ -1,5 +1,15 @@
{
// If ambiguate-properties and disambiguate-properties are set to true
// we get function names like "ol_control_Control_prototype$setMap" in
// the compiled code when using the SIMPLE compilation. It looks like
// "ambiguate-properties" and "disambiguate-properties" are only
// appropriate for ADVANCED compilation.
"ambiguate-properties": false,
"disambiguate-properties": false,
"id": "ol-simple",
"externs": [

View File

@@ -2,6 +2,17 @@
"id": "ol-whitespace",
// If ambiguate-properties and disambiguate-properties are set to true
// we get function names like "ol_control_Control_prototype$setMap" in
// the compiled code when using the SIMPLE compilation. It looks like
// "ambiguate-properties" and "disambiguate-properties" are only
// appropriate for ADVANCED compilation. To be sure we also don't
// set them for WHITESPACE.
"ambiguate-properties": false,
"disambiguate-properties": false,
"externs": [
"externs/bingmaps.js",
"externs/proj4js.js",