Better separate headless tests that require webgl and headed tests.
Move example-cases to headed-cases.  Move the two-map test from gl-cases to the headed-cases directory.  Change the glheadless test to use headless Chrome.  The headless tests can be run without xvfb.
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -134,14 +134,14 @@ if(WEBGLHEADLESS_TESTS)
set_property(TEST "webglheadless" APPEND PROPERTY DEPENDS "build_examples")
add_test(
- NAME "examplesheadless"
+ NAME "headed"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- COMMAND "${NPM_EXECUTABLE}" run examplesci
+ COMMAND "${NPM_EXECUTABLE}" run headedci
)
- set_property(TEST "examplesheadless" APPEND PROPERTY ENVIRONMENT "CTEST_IMAGE_PATH=${CMAKE_CURRENT_BINARY_DIR}/images")
- set_property(TEST "examplesheadless" APPEND PROPERTY ENVIRONMENT "TEST_SAVE_IMAGE=${TEST_SAVE_IMAGE}")
- set_property(TEST "total-coverage" APPEND PROPERTY DEPENDS "examplesheadless")
- set_property(TEST "examplesheadless" APPEND PROPERTY DEPENDS "build_examples")
+ set_property(TEST "headed" APPEND PROPERTY ENVIRONMENT "CTEST_IMAGE_PATH=${CMAKE_CURRENT_BINARY_DIR}/images")
+ set_property(TEST "headed" APPEND PROPERTY ENVIRONMENT "TEST_SAVE_IMAGE=${TEST_SAVE_IMAGE}")
+ set_property(TEST "total-coverage" APPEND PROPERTY DEPENDS "headed")
+ set_property(TEST "headed" APPEND PROPERTY DEPENDS "build_examples")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/testing/test-runners/baseline_images.py"
@@ -158,8 +158,8 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/base-images.tgz"
COMMAND TEST_SAVE_IMAGE=all "${NPM_EXECUTABLE}" run glci
# Build examples to make sure that they are available.
COMMAND "${NPM_EXECUTABLE}" run build-examples
- # Run the examplesheadless test, asking to save all images
- COMMAND TEST_SAVE_IMAGE=all "${NPM_EXECUTABLE}" run examplesci
+ # Run the headed test, asking to save all images
+ COMMAND TEST_SAVE_IMAGE=all "${NPM_EXECUTABLE}" run headedci
# If optipng is available, reduce the size of the images
# COMMAND bash -c "optipng '${CMAKE_CURRENT_BINARY_DIR}'/images/*.png || true"
COMMAND bash -c "find '${CMAKE_CURRENT_BINARY_DIR}'/images -name '*.png' -a -not -name '*-test.png' -a -not -name '*-diff.png' -a -not -name '*-base.png' -a -not -name '*-screen.png' -print0 | xargs -0 -n 1 -P 8 optipng || true"

MODIFY
docs/developers.rst
docs/developers.rst
@@ -81,9 +81,9 @@ will run the headless WebGL tests. After the data for tests is downloaded,
the tests can also be run via ``npm run test-webgl``, which assumes that
``xvfb-run`` is available.
-The headless unit tests that require WebGL or should run in a standard browser
-should be placed in the ``tests/gl-cases/`` directory. When tests are run in a
-normal browser via ``npm run start``, the webgl tests are included.
+The headless unit tests that require WebGL should be placed in the
+``tests/gl-cases/`` directory. When tests are run in a normal browser via
+``npm run start``, the webgl tests are included.
Many of these tests compare against a baseline image. If a test is changed or
added, new baselines can be generated and optionally uploaded via the script
@@ -109,9 +109,10 @@ test command or set this parameter in CMake.
build correctly. Try running ``ccmake /path/to/geojs`` for a full
list of configuration options.
-Examples should be tested by creating an entry in the ``tests/example-cases/``
-directory. To run these tests in a normal browser, run
-``npm run start`` and browse to `<http://localhost:9876/debug.html?test=all>`_.
-Since the browser's direct screen output is used, the browser must be running
-on the same machine as the ``npm run start`` command.
+Examples and tests that need to run in a standard browser should be tested by
+creating an entry in the ``tests/headed-cases/`` directory. To run these tests
+in a normal browser, run ``npm run start`` and browse to
+`<http://localhost:9876/debug.html?test=all>`_. Since the browser's direct
+screen output is used, the browser must be running on the same machine as the
+``npm run start`` command.

MODIFY
karma-base.js
karma-base.js
@@ -212,7 +212,7 @@ module.exports = function (config) {
{pattern: 'tests/data/**/*', included: false},
{pattern: 'tests/cases/**/*.js', included: false, served: false, watched: true},
{pattern: 'tests/gl-cases/**/*.js', included: false, served: false, watched: true},
- {pattern: 'tests/example-cases/**/*.js', included: false, served: false, watched: true},
+ {pattern: 'tests/headed-cases/**/*.js', included: false, served: false, watched: true},
{pattern: 'dist/data/**/*', included: false},
{pattern: 'dist/examples/**/*', included: false},
{pattern: 'dist/tutorials/**/*', included: false},

MODIFY
package.json
package.json
"test": "GEOJS_TEST_CASE=tests/test-unit.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxTouch,PhantomJS",
"test-all": "GEOJS_TEST_CASE=tests/test-unit.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxTouch,PhantomJS",
"start": "karma start karma.conf.js",
- "glci": "GEOJS_TEST_CASE=tests/test-gl.js karma start karma-cov.conf.js --single-run --browsers ChromeFull",
- "glci-all": "GEOJS_TEST_CASE=tests/test-gl.js karma start karma-cov.conf.js --single-run --browsers ChromeFull,FirefoxTouch",
- "examplesci": "GEOJS_TEST_CASE=tests/test-examples.js karma start karma-cov.conf.js --single-run --browsers ChromeWithProxy",
- "examplesci-all": "GEOJS_TEST_CASE=tests/test-examples.js karma start karma-cov.conf.js --single-run --browsers ChromeWithProxy,FirefoxWithProxy",
+ "glci": "GEOJS_TEST_CASE=tests/test-gl.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch",
+ "glci-all": "GEOJS_TEST_CASE=tests/test-gl.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxTouch",
+ "headedci": "GEOJS_TEST_CASE=tests/test-headed.js karma start karma-cov.conf.js --single-run --browsers ChromeWithProxy",
+ "headedci-all": "GEOJS_TEST_CASE=tests/test-headed.js karma start karma-cov.conf.js --single-run --browsers ChromeWithProxy,FirefoxWithProxy",
"tutorialsci": "GEOJS_TEST_CASE=tests/tutorials.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,PhantomJS",
"tutorialsci-all": "GEOJS_TEST_CASE=tests/tutorials.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch,FirefoxTouch,PhantomJS",
- "test-webgl": "GEOJS_TEST_CASE=tests/test-gl.js xvfb-run -s '-ac -screen 0 1280x1024x24' karma start karma-cov.conf.js --single-run --browsers ChromeFull",
- "test-examples": "GEOJS_TEST_CASE=tests/test-examples.js xvfb-run -s '-ac -screen 0 1280x1024x24' karma start karma-cov.conf.js --single-run --browsers ChromeWithProxy",
+ "test-webgl": "GEOJS_TEST_CASE=tests/test-gl.js karma start karma-cov.conf.js --single-run --browsers ChromeHeadlessTouch",
+ "test-headed": "GEOJS_TEST_CASE=tests/test-headed.js xvfb-run -s '-ac -screen 0 1280x1024x24' karma start karma-cov.conf.js --single-run --browsers ChromeWithProxy",
"codecov": "codecov",
"combine-coverage": "istanbul-combine -d dist/cobertura -r cobertura 'dist/coverage/json/**/coverage-final.json'",
"examples": "webpack-dev-server --config webpack-examples.config.js --host ${HOST-127.0.0.1} --port ${PORT-8082} --content-base dist/",

MODIFY
tests/all.js
tests/all.js
@@ -16,7 +16,7 @@ if (query.test === 'all' || query.test === 'gl' || query.test === undefined) {
tests = require.context('./gl-cases', true, /.*\.js$/);
tests.keys().forEach(tests);
}
-if (query.test === 'all' || query.test === 'examples') {
- tests = require.context('./example-cases', true, /.*\.js$/);
+if (query.test === 'all' || query.test === 'headed') {
+ tests = require.context('./headed-cases', true, /.*\.js$/);
tests.keys().forEach(tests);
}

MODIFY
tests/gl-cases/map.js
tests/gl-cases/map.js
@@ -43,39 +43,3 @@ describe('map', function () {
imageTest.imageTest('mapZoom', null, 0.0015, done, myMap.onIdle, 0, 2);
});
});
-
-describe('two maps', function () {
- var imageTest = require('../image-test');
- var common = require('../test-common');
- var $ = require('jquery');
-
- var map1, map2;
-
- beforeEach(function () {
- var twomap = $('<div id="twomap"/>').css({width: '320px', height: '480px'});
- $('#map').remove();
- $('body').prepend(twomap);
- twomap.append($('<div id="map1"/>').css({width: '100%', height: '50%'}));
- twomap.append($('<div id="map2"/>').css({width: '100%', height: '50%'}));
- });
- afterEach(function () {
- map1.exit();
- map2.exit();
- $('#twomap').remove();
- });
-
- it('two maps', function (done) {
- map1 = common.createOsmMap({node: '#map1', center: {x: -70, y: 40}, zoom: 3});
- map2 = common.createOsmMap({node: '#map2', center: {x: 70, y: 40}, zoom: 3});
- map1.draw();
- map2.draw();
-
- var idle = function (callback) {
- map1.onIdle(function () {
- map2.onIdle(callback);
- });
- };
-
- imageTest.imageTest('mapTwo', '#twomap', 0.0015, done, idle, 0, 2);
- });
-});

RENAME
tests/example-cases/blog-lines.js
tests/headed-cases/blog-lines.js
RENAME
tests/example-cases/lines.js
tests/headed-cases/lines.js
ADD
tests/headed-cases/map.js
+describe('two maps', function () {
+ var imageTest = require('../image-test');
+ var common = require('../test-common');
+ var $ = require('jquery');
+
+ var map1, map2;
+
+ beforeEach(function () {
+ var twomap = $('<div id="twomap"/>').css({width: '320px', height: '480px'});
+ $('#map').remove();
+ $('body').prepend(twomap);
+ twomap.append($('<div id="map1"/>').css({width: '100%', height: '50%'}));
+ twomap.append($('<div id="map2"/>').css({width: '100%', height: '50%'}));
+ });
+ afterEach(function () {
+ map1.exit();
+ map2.exit();
+ $('#twomap').remove();
+ });
+
+ it('two maps', function (done) {
+ map1 = common.createOsmMap({node: '#map1', center: {x: -70, y: 40}, zoom: 3});
+ map2 = common.createOsmMap({node: '#map2', center: {x: 70, y: 40}, zoom: 3});
+ map1.draw();
+ map2.draw();
+
+ var idle = function (callback) {
+ map1.onIdle(function () {
+ map2.onIdle(callback);
+ });
+ };
+
+ imageTest.imageTest('mapTwo', '#twomap', 0.0015, done, idle, 0, 2);
+ });
+});

RENAME
tests/test-examples.js
tests/test-headed.js
/**
- * Entry point for all tests in ./example-cases/*
+ * Entry point for all tests in ./headed-cases/*
* This is here to prevent webpack from creating a seperate bundle for each
* test case. See: https://github.com/webpack/karma-webpack/issues/23
*/
-var tests = require.context('./example-cases', true, /.*\.js$/);
+var tests = require.context('./headed-cases', true, /.*\.js$/);
tests.keys().forEach(tests);
-

Better separate headless tests that require webgl and headed tests.

Move example-cases to headed-cases.  Move the two-map test from gl-cases to the headed-cases directory.  Change the glheadless test to use headless Chrome.  The headless tests can be run without xvfb.