From b6ed5f216459a859adc96161d2fc739230e0f8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 31 Jan 2013 10:04:41 +0100 Subject: [PATCH] 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. --- .gitignore | 1 + build.py | 26 ++++++++++++++++------- test/ol.html | 22 +------------------ test/spec/ol/array.test.js | 2 ++ test/spec/ol/collection.test.js | 2 ++ test/spec/ol/color.test.js | 2 ++ test/spec/ol/control/control.test.js | 8 ++++--- test/spec/ol/extent.test.js | 2 ++ test/spec/ol/layer/layer.test.js | 2 ++ test/spec/ol/map.test.js | 21 ++++++++++-------- test/spec/ol/object.test.js | 2 ++ test/spec/ol/projection.test.js | 2 ++ test/spec/ol/rectangle.test.js | 2 ++ test/spec/ol/resolutionconstraint.test.js | 2 ++ test/spec/ol/source/xyz.test.js | 2 ++ test/spec/ol/tilecoord.test.js | 2 ++ test/spec/ol/tilegrid.test.js | 2 ++ test/spec/ol/tilequeue.test.js | 2 ++ test/spec/ol/tilerange.test.js | 2 ++ test/spec/ol/tileurlfunction.test.js | 6 +++--- test/spec/ol/view2d.test.js | 4 +++- test/test.json | 16 ++++++++++++++ 22 files changed, 87 insertions(+), 45 deletions(-) create mode 100644 test/test.json diff --git a/.gitignore b/.gitignore index 26c170bec9..c5cad9d3cf 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ /examples/*.combined.js /examples/example-list.js /examples/example-list.xml +/test/requireall.js diff --git a/build.py b/build.py index 5dca545c20..797eb9e542 100755 --- a/build.py +++ b/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') -@target('build/src/internal/src/requireall.js', SRC) -def build_src_internal_src_requireall_js(t): - requires = set(('goog.dom',)) - for dependency in t.dependencies: +def _build_require_list(dependencies, output_file_name): + requires = set() + for dependency in dependencies: for line in open(dependency): match = re.match(r'goog\.provide\(\'(.*)\'\);', line) if match: 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): 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') def build_src_internal_types_js(t): 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) -@target('serve', PLOVR_JAR, INTERNAL_SRC, 'examples') +@target('serve', PLOVR_JAR, INTERNAL_SRC, 'test/requireall.js', 'examples') 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) @@ -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/') -@target('test', INTERNAL_SRC, phony=True) +@target('test', INTERNAL_SRC, 'test/requireall.js', phony=True) def test(t): t.run('%(PHANTOMJS)s', 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html') + @target('fixme', phony=True) def find_fixme(t): regex = re.compile(".(FIXME|TODO).") diff --git a/test/ol.html b/test/ol.html index c490d01fd1..d4e3191ac9 100644 --- a/test/ol.html +++ b/test/ol.html @@ -37,7 +37,7 @@ // Create the script tag which includes the derived variables from above var script = '' + + 'src="http://' + plovrHost + '/compile?id=test&mode=RAW">' + ''; // this function will fix the links of the result to also include @@ -69,26 +69,6 @@ - - - - - - - - - - - - - - - - - - - -