Use namespaces for tests
With this commit test files provide namespaces (using goog.provide). This fixes the issue reported by @bartvde where goog objects cannot be used in Jasmine "describe" functions. It also frees us from having to add script tags for the test files in test/ol.html.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@
|
|||||||
/examples/*.combined.js
|
/examples/*.combined.js
|
||||||
/examples/example-list.js
|
/examples/example-list.js
|
||||||
/examples/example-list.xml
|
/examples/example-list.xml
|
||||||
|
/test/requireall.js
|
||||||
|
|||||||
26
build.py
26
build.py
@@ -122,19 +122,28 @@ def build_src_external_src_types_js(t):
|
|||||||
t.output('%(PYTHON)s', 'bin/generate-exports.py', '--typedef', 'src/objectliterals.exports')
|
t.output('%(PYTHON)s', 'bin/generate-exports.py', '--typedef', 'src/objectliterals.exports')
|
||||||
|
|
||||||
|
|
||||||
@target('build/src/internal/src/requireall.js', SRC)
|
def _build_require_list(dependencies, output_file_name):
|
||||||
def build_src_internal_src_requireall_js(t):
|
requires = set()
|
||||||
requires = set(('goog.dom',))
|
for dependency in dependencies:
|
||||||
for dependency in t.dependencies:
|
|
||||||
for line in open(dependency):
|
for line in open(dependency):
|
||||||
match = re.match(r'goog\.provide\(\'(.*)\'\);', line)
|
match = re.match(r'goog\.provide\(\'(.*)\'\);', line)
|
||||||
if match:
|
if match:
|
||||||
requires.add(match.group(1))
|
requires.add(match.group(1))
|
||||||
with open(t.name, 'w') as f:
|
with open(output_file_name, 'w') as f:
|
||||||
for require in sorted(requires):
|
for require in sorted(requires):
|
||||||
f.write('goog.require(\'%s\');\n' % (require,))
|
f.write('goog.require(\'%s\');\n' % (require,))
|
||||||
|
|
||||||
|
|
||||||
|
@target('build/src/internal/src/requireall.js', SRC)
|
||||||
|
def build_src_internal_src_requireall_js(t):
|
||||||
|
_build_require_list(t.dependencies, t.name)
|
||||||
|
|
||||||
|
|
||||||
|
@target('test/requireall.js', SPEC)
|
||||||
|
def build_test_requireall_js(t):
|
||||||
|
_build_require_list(t.dependencies, t.name)
|
||||||
|
|
||||||
|
|
||||||
@target('build/src/internal/src/types.js', 'bin/generate-exports.py', 'src/objectliterals.exports')
|
@target('build/src/internal/src/types.js', 'bin/generate-exports.py', 'src/objectliterals.exports')
|
||||||
def build_src_internal_types_js(t):
|
def build_src_internal_types_js(t):
|
||||||
t.output('%(PYTHON)s', 'bin/generate-exports.py', '--typedef', 'src/objectliterals.exports')
|
t.output('%(PYTHON)s', 'bin/generate-exports.py', '--typedef', 'src/objectliterals.exports')
|
||||||
@@ -177,9 +186,9 @@ def examples_star_combined_js(name, match):
|
|||||||
return Target(name, action=action, dependencies=dependencies)
|
return Target(name, action=action, dependencies=dependencies)
|
||||||
|
|
||||||
|
|
||||||
@target('serve', PLOVR_JAR, INTERNAL_SRC, 'examples')
|
@target('serve', PLOVR_JAR, INTERNAL_SRC, 'test/requireall.js', 'examples')
|
||||||
def serve(t):
|
def serve(t):
|
||||||
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', glob.glob('build/*.json'), glob.glob('examples/*.json'))
|
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', glob.glob('build/*.json'), glob.glob('examples/*.json'), glob.glob('test/*.json'))
|
||||||
|
|
||||||
|
|
||||||
@target('serve-precommit', PLOVR_JAR, INTERNAL_SRC)
|
@target('serve-precommit', PLOVR_JAR, INTERNAL_SRC)
|
||||||
@@ -246,10 +255,11 @@ def hostexamples(t):
|
|||||||
t.cp('examples/example-list.js', 'examples/example-list.xml', 'examples/Jugl.js', 'build/gh-pages/%(BRANCH)s/examples/')
|
t.cp('examples/example-list.js', 'examples/example-list.xml', 'examples/Jugl.js', 'build/gh-pages/%(BRANCH)s/examples/')
|
||||||
|
|
||||||
|
|
||||||
@target('test', INTERNAL_SRC, phony=True)
|
@target('test', INTERNAL_SRC, 'test/requireall.js', phony=True)
|
||||||
def test(t):
|
def test(t):
|
||||||
t.run('%(PHANTOMJS)s', 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html')
|
t.run('%(PHANTOMJS)s', 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html')
|
||||||
|
|
||||||
|
|
||||||
@target('fixme', phony=True)
|
@target('fixme', phony=True)
|
||||||
def find_fixme(t):
|
def find_fixme(t):
|
||||||
regex = re.compile(".(FIXME|TODO).")
|
regex = re.compile(".(FIXME|TODO).")
|
||||||
|
|||||||
22
test/ol.html
22
test/ol.html
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
// Create the script tag which includes the derived variables from above
|
// Create the script tag which includes the derived variables from above
|
||||||
var script = '<sc' + 'ript type="text/javascript" '
|
var script = '<sc' + 'ript type="text/javascript" '
|
||||||
+ 'src="http://' + plovrHost + '/compile?id=ol-all&mode=RAW">'
|
+ 'src="http://' + plovrHost + '/compile?id=test&mode=RAW">'
|
||||||
+ '</scr' + 'ipt>';
|
+ '</scr' + 'ipt>';
|
||||||
|
|
||||||
// this function will fix the links of the result to also include
|
// this function will fix the links of the result to also include
|
||||||
@@ -69,26 +69,6 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- include spec files here... -->
|
|
||||||
<script type="text/javascript" src="spec/ol/array.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/collection.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/color.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/extent.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/map.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/object.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/projection.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/rectangle.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/resolutionconstraint.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/view2d.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/layer/layer.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/source/xyz.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/tilecoord.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/tilegrid.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/tilequeue.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/tilerange.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/tileurlfunction.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/control/control.test.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.array');
|
||||||
|
|
||||||
describe('ol.array', function() {
|
describe('ol.array', function() {
|
||||||
|
|
||||||
describe('binaryFindNearest', function() {
|
describe('binaryFindNearest', function() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.Collection');
|
||||||
|
|
||||||
describe('ol.collection', function() {
|
describe('ol.collection', function() {
|
||||||
var collection;
|
var collection;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.Color');
|
||||||
|
|
||||||
describe('ol.Color', function() {
|
describe('ol.Color', function() {
|
||||||
|
|
||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
goog.require('goog.dom');
|
goog.provide('ol.test.control.Control');
|
||||||
goog.require('ol.Map');
|
|
||||||
goog.require('ol.control.Control');
|
|
||||||
|
|
||||||
describe('ol.control.Control', function() {
|
describe('ol.control.Control', function() {
|
||||||
var map, control;
|
var map, control;
|
||||||
@@ -25,3 +23,7 @@ describe('ol.control.Control', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
goog.require('goog.dom');
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.control.Control');
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.Extent');
|
||||||
|
|
||||||
describe('ol.Extent', function() {
|
describe('ol.Extent', function() {
|
||||||
|
|
||||||
describe('contains', function() {
|
describe('contains', function() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.layer.Layer');
|
||||||
|
|
||||||
describe('ol.layer.Layer', function() {
|
describe('ol.layer.Layer', function() {
|
||||||
|
|
||||||
describe('constructor (defaults)', function() {
|
describe('constructor (defaults)', function() {
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
goog.require('goog.async.AnimationDelay');
|
goog.provide('ol.test.Map');
|
||||||
goog.require('goog.dom');
|
goog.provide('ol.test.RendererHints');
|
||||||
goog.require('ol.Collection');
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
goog.require('ol.Map');
|
|
||||||
goog.require('ol.RendererHint');
|
|
||||||
goog.require('ol.View2D');
|
|
||||||
goog.require('ol.layer.TileLayer');
|
|
||||||
goog.require('ol.source.XYZ');
|
|
||||||
|
|
||||||
describe('ol.RendererHints', function() {
|
describe('ol.RendererHints', function() {
|
||||||
|
|
||||||
@@ -241,3 +234,13 @@ describe('ol.Map', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
goog.require('goog.async.AnimationDelay');
|
||||||
|
goog.require('goog.dom');
|
||||||
|
goog.require('ol.Collection');
|
||||||
|
goog.require('ol.Coordinate');
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.RendererHint');
|
||||||
|
goog.require('ol.View2D');
|
||||||
|
goog.require('ol.layer.TileLayer');
|
||||||
|
goog.require('ol.source.XYZ');
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.Object');
|
||||||
|
|
||||||
describe('ol.Object', function() {
|
describe('ol.Object', function() {
|
||||||
|
|
||||||
var o;
|
var o;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.Projection');
|
||||||
|
|
||||||
describe('ol.Projection', function() {
|
describe('ol.Projection', function() {
|
||||||
|
|
||||||
describe('projection equivalence', function() {
|
describe('projection equivalence', function() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.Rectangle');
|
||||||
|
|
||||||
describe('ol.Rectangle', function() {
|
describe('ol.Rectangle', function() {
|
||||||
|
|
||||||
describe('getCenter', function() {
|
describe('getCenter', function() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.ResolutionConstraint');
|
||||||
|
|
||||||
describe('ol.ResolutionConstraint', function() {
|
describe('ol.ResolutionConstraint', function() {
|
||||||
|
|
||||||
describe('SnapToResolution', function() {
|
describe('SnapToResolution', function() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.source.XYZ');
|
||||||
|
|
||||||
describe('ol.source.XYZ', function() {
|
describe('ol.source.XYZ', function() {
|
||||||
|
|
||||||
describe('getTileCoordUrl', function() {
|
describe('getTileCoordUrl', function() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.TileCoord');
|
||||||
|
|
||||||
describe('ol.TileCoord', function() {
|
describe('ol.TileCoord', function() {
|
||||||
|
|
||||||
describe('create', function() {
|
describe('create', function() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.TileGrid');
|
||||||
|
|
||||||
describe('ol.tilegrid.TileGrid', function() {
|
describe('ol.tilegrid.TileGrid', function() {
|
||||||
var extent;
|
var extent;
|
||||||
var resolutions;
|
var resolutions;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.TileQueue');
|
||||||
|
|
||||||
describe('ol.TileQueue', function() {
|
describe('ol.TileQueue', function() {
|
||||||
|
|
||||||
// is the tile queue's array a heap?
|
// is the tile queue's array a heap?
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
goog.provide('ol.test.TileRange');
|
||||||
|
|
||||||
describe('ol.TileRange', function() {
|
describe('ol.TileRange', function() {
|
||||||
|
|
||||||
describe('contains', function() {
|
describe('contains', function() {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
goog.require('ol.TileUrlFunction');
|
goog.provide('ol.test.TileUrlFunction');
|
||||||
goog.require('ol.tilegrid.XYZ');
|
|
||||||
|
|
||||||
describe('ol.TileUrlFunction', function() {
|
describe('ol.TileUrlFunction', function() {
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ describe('ol.TileUrlFunction', function() {
|
|||||||
|
|
||||||
describe('createFromTileUrlFunctions', function() {
|
describe('createFromTileUrlFunctions', function() {
|
||||||
it('creates expected URL', function() {
|
it('creates expected URL', function() {
|
||||||
tileUrl = ol.TileUrlFunction.createFromTileUrlFunctions([
|
var tileUrl = ol.TileUrlFunction.createFromTileUrlFunctions([
|
||||||
ol.TileUrlFunction.createFromTemplate('a'),
|
ol.TileUrlFunction.createFromTemplate('a'),
|
||||||
ol.TileUrlFunction.createFromTemplate('b')
|
ol.TileUrlFunction.createFromTemplate('b')
|
||||||
]);
|
]);
|
||||||
@@ -83,3 +82,4 @@ describe('ol.TileUrlFunction', function() {
|
|||||||
|
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol.TileCoord');
|
||||||
goog.require('ol.TileUrlFunction');
|
goog.require('ol.TileUrlFunction');
|
||||||
|
goog.require('ol.tilegrid.XYZ');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
goog.require('ol.View2D');
|
goog.provide('ol.test.View2D');
|
||||||
|
|
||||||
describe('ol.View2D', function() {
|
describe('ol.View2D', function() {
|
||||||
describe('create constraints', function() {
|
describe('create constraints', function() {
|
||||||
@@ -51,3 +51,5 @@ describe('ol.View2D', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
goog.require('ol.View2D');
|
||||||
|
|||||||
16
test/test.json
Normal file
16
test/test.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
"id": "test",
|
||||||
|
|
||||||
|
"inherits": "../base.json",
|
||||||
|
|
||||||
|
"inputs": [
|
||||||
|
"test/requireall.js"
|
||||||
|
],
|
||||||
|
|
||||||
|
"paths": [
|
||||||
|
"src",
|
||||||
|
"test"
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user