Merge pull request #257 from elemoine/verify-examples

Verify hosted examples at precommit time
This commit is contained in:
Éric Lemoine
2013-03-03 15:06:11 -08:00
6 changed files with 66 additions and 10 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')
@@ -378,6 +378,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",

View File

@@ -1,6 +1,3 @@
goog.require('goog.debug.Console');
goog.require('goog.debug.Logger');
goog.require('goog.debug.Logger.Level');
goog.require('ol.Collection');
goog.require('ol.Coordinate');
goog.require('ol.Map');
@@ -11,11 +8,6 @@ goog.require('ol.projection');
goog.require('ol.source.TiledWMS');
if (goog.DEBUG) {
goog.debug.Console.autoInstall();
goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
}
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
// We give the single image source a set of resolutions. This prevents the

View File

@@ -119,7 +119,9 @@ ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) {
* @protected
* @return {ol.renderer.Layer} layerRenderer Layer renderer.
*/
ol.renderer.Map.prototype.createLayerRenderer = goog.functions.NULL;
ol.renderer.Map.prototype.createLayerRenderer = function(layer) {
return new ol.renderer.Layer(this, layer);
};
/**