diff --git a/package.json b/package.json index 4764b880b..a702fd45b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "scripts": { "lint": "node ./node_modules/eslint/bin/eslint.js -c ./.eslintrc features/step_definitions/ features/support/", - "test": "npm run lint && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify", + "test": "npm run lint && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify && node ./node_modules/cucumber/bin/cucumber.js features/ -p mld", "clean": "rm -rf test/cache", "docs": "./scripts/build_api_docs.sh", "install": "node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh", diff --git a/scripts/timer.js b/scripts/timer.js index 47fb280a9..daeb5b512 100755 --- a/scripts/timer.js +++ b/scripts/timer.js @@ -6,8 +6,12 @@ var fs = require('fs'); var name = process.argv[2]; var cmd = process.argv.slice(3).join(' '); var start = Date.now(); -exec(cmd, (err) => { - if (err) return console.log(err); +exec(cmd, (err, stdout, stderr) => { + if (err) { + console.log(stdout); + console.log(stderr); + return process.exit(err.code); + } var stop = +new Date(); var time = (stop - start) / 1000.; fs.appendFileSync('/tmp/osrm.timings', `${name}\t${time}`, 'utf-8'); diff --git a/test/data/Makefile b/test/data/Makefile index 7a710f861..3c6adc7d2 100755 --- a/test/data/Makefile +++ b/test/data/Makefile @@ -74,11 +74,11 @@ benchmark: data $(DATA_NAME).requests $(TIMER) "queries\tCoreCH" "cat $(DATA_NAME).requests | xargs curl &> /dev/null" @cat osrm-routed.pid | xargs kill @rm osrm-routed.pid - # @/bin/sh -c '$(OSRM_ROUTED) --algorithm=MLD mld/$(DATA_NAME).osrm > /dev/null & echo "$$!" > osrm-routed.pid' - # @sleep 1 - # $(TIMER) "queries\tMLD" "cat $(DATA_NAME).requests | xargs curl &> /dev/null" - # @cat osrm-routed.pid | xargs kill - # @rm osrm-routed.pid + @/bin/sh -c '$(OSRM_ROUTED) --algorithm=MLD mld/$(DATA_NAME).osrm > /dev/null & echo "$$!" > osrm-routed.pid' + @sleep 1 + $(TIMER) "queries\tMLD" "cat $(DATA_NAME).requests | xargs curl &> /dev/null" + @cat osrm-routed.pid | xargs kill + @rm osrm-routed.pid @echo "**** timings ***" @cat /tmp/osrm.timings @echo "****************" diff --git a/test/nodejs/index.js b/test/nodejs/index.js index 671b46efd..bbe58849f 100644 --- a/test/nodejs/index.js +++ b/test/nodejs/index.js @@ -23,14 +23,14 @@ test('constructor: does not accept more than one parameter', function(assert) { /Only accepts one parameter/); }); -// test('constructor: throws if necessary files do not exist', function(assert) { -// assert.plan(2); -// assert.throws(function() { new OSRM('missing.osrm'); }, -// /Required files are missing, cannot continue/); +test('constructor: throws if necessary files do not exist', function(assert) { + assert.plan(2); + assert.throws(function() { new OSRM('missing.osrm'); }, + /Required files are missing, cannot continue/); -// assert.throws(function() { new OSRM({path: 'missing.osrm', algorithm: 'MLD'}); }, -// /Required files are missing, cannot continue/); -// }); + assert.throws(function() { new OSRM({path: 'missing.osrm', algorithm: 'MLD'}); }, + /Required files are missing, cannot continue/); +}); test('constructor: takes a shared memory argument', function(assert) { assert.plan(1); @@ -74,11 +74,11 @@ test('constructor: throws if given an invalid algorithm', function(assert) { /algorithm option must be a string and one of 'CH', 'CoreCH', or 'MLD'/); }); -// test('constructor: loads MLD if given as algorithm', function(assert) { -// assert.plan(1); -// var osrm = new OSRM({algorithm: 'MLD', path: monaco_mld_path}); -// assert.ok(osrm); -// }); +test('constructor: loads MLD if given as algorithm', function(assert) { + assert.plan(1); + var osrm = new OSRM({algorithm: 'MLD', path: monaco_mld_path}); + assert.ok(osrm); +}); test('constructor: loads CH if given as algorithm', function(assert) { assert.plan(1); @@ -98,12 +98,12 @@ test('constructor: autoswitches to CoreCH for a CH dataset if capable', function assert.ok(osrm); }); -// test('constructor: throws if data doesn\'t match algorithm', function(assert) { -// assert.plan(3); -// assert.throws(function() { new OSRM({algorithm: 'CoreCH', path: monaco_mld_path}); }, /Could not find any metrics for CH/, 'CoreCH with MLD data'); -// assert.ok(new OSRM({algorithm: 'CoreCH', path: monaco_path}), 'CoreCH with CH data'); - // assert.throws(function() { new OSRM({algorithm: 'MLD', path: monaco_path}); }, /Could not find any metrics for MLD/, 'MLD with CH data'); -// }); +test('constructor: throws if data doesn\'t match algorithm', function(assert) { + assert.plan(3); + assert.throws(function() { new OSRM({algorithm: 'CoreCH', path: monaco_mld_path}); }, /Could not find any metrics for CH/, 'CoreCH with MLD data'); + assert.ok(new OSRM({algorithm: 'CoreCH', path: monaco_path}), 'CoreCH with CH data'); + assert.throws(function() { new OSRM({algorithm: 'MLD', path: monaco_path}); }, /Could not find any metrics for MLD/, 'MLD with CH data'); +}); test('constructor: throws if dataset_name is not a string', function(assert) { assert.plan(3); @@ -112,36 +112,36 @@ test('constructor: throws if dataset_name is not a string', function(assert) { assert.throws(function() { new OSRM({dataset_name: "unsued_name___", shared_memory: true}); }, /Could not find shared memory region/, 'Does not accept wrong name'); }); -// test('constructor: parses custom limits', function(assert) { -// assert.plan(1); -// var osrm = new OSRM({ -// path: monaco_mld_path, -// algorithm: 'MLD', -// max_locations_trip: 1, -// max_locations_viaroute: 1, -// max_locations_distance_table: 1, -// max_locations_map_matching: 1, -// max_results_nearest: 1, -// max_alternatives: 1, -// }); -// assert.ok(osrm); -// }); +test('constructor: parses custom limits', function(assert) { + assert.plan(1); + var osrm = new OSRM({ + path: monaco_mld_path, + algorithm: 'MLD', + max_locations_trip: 1, + max_locations_viaroute: 1, + max_locations_distance_table: 1, + max_locations_map_matching: 1, + max_results_nearest: 1, + max_alternatives: 1, + }); + assert.ok(osrm); +}); -// test('constructor: throws on invalid custom limits', function(assert) { -// assert.plan(1); -// assert.throws(function() { -// var osrm = new OSRM({ -// path: monaco_mld_path, -// algorithm: 'MLD', -// max_locations_trip: 'unlimited', -// max_locations_viaroute: true, -// max_locations_distance_table: false, -// max_locations_map_matching: 'a lot', -// max_results_nearest: null, -// max_alternatives: '10' -// }) -// }); -// }); +test('constructor: throws on invalid custom limits', function(assert) { + assert.plan(1); + assert.throws(function() { + var osrm = new OSRM({ + path: monaco_mld_path, + algorithm: 'MLD', + max_locations_trip: 'unlimited', + max_locations_viaroute: true, + max_locations_distance_table: false, + max_locations_map_matching: 'a lot', + max_results_nearest: null, + max_alternatives: '10' + }) + }); +}); require('./route.js'); require('./trip.js'); diff --git a/test/nodejs/match.js b/test/nodejs/match.js index 1d1c3df2f..da4d7853b 100644 --- a/test/nodejs/match.js +++ b/test/nodejs/match.js @@ -247,29 +247,29 @@ test('match: throws on invalid tidy param', function(assert) { /tidy must be of type Boolean/); }); -// test('match: throws on invalid config param', function(assert) { -// assert.plan(1); -// var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); -// var options = { -// coordinates: three_test_coordinates, -// }; -// assert.throws(function() { osrm.match(options, { format: 'invalid' }, function(err, response) {}) }, -// /format must be a string:/); -// }); +test('match: throws on invalid config param', function(assert) { + assert.plan(1); + var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); + var options = { + coordinates: three_test_coordinates, + }; + assert.throws(function() { osrm.match(options, { format: 'invalid' }, function(err, response) {}) }, + /format must be a string:/); +}); -// test('match: match in Monaco without motorways', function(assert) { -// assert.plan(3); -// var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); -// var options = { -// coordinates: three_test_coordinates, -// exclude: ['motorway'] -// }; -// osrm.match(options, function(err, response) { -// assert.ifError(err); -// assert.equal(response.tracepoints.length, 3); -// assert.equal(response.matchings.length, 1); -// }); -// }); +test('match: match in Monaco without motorways', function(assert) { + assert.plan(3); + var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); + var options = { + coordinates: three_test_coordinates, + exclude: ['motorway'] + }; + osrm.match(options, function(err, response) { + assert.ifError(err); + assert.equal(response.tracepoints.length, 3); + assert.equal(response.matchings.length, 1); + }); +}); test('match: throws on invalid waypoints values needs at least two', function(assert) { assert.plan(1); diff --git a/test/nodejs/nearest.js b/test/nodejs/nearest.js index ecd1910dc..1fce37af0 100644 --- a/test/nodejs/nearest.js +++ b/test/nodejs/nearest.js @@ -73,15 +73,15 @@ test('nearest: throws on invalid args', function(assert) { /format must be a string:/); }); -// test('nearest: nearest in Monaco without motorways', function(assert) { -// assert.plan(2); -// var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); -// var options = { -// coordinates: [two_test_coordinates[0]], -// exclude: ['motorway'] -// }; -// osrm.nearest(options, function(err, response) { -// assert.ifError(err); -// assert.equal(response.waypoints.length, 1); -// }); -// }); +test('nearest: nearest in Monaco without motorways', function(assert) { + assert.plan(2); + var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); + var options = { + coordinates: [two_test_coordinates[0]], + exclude: ['motorway'] + }; + osrm.nearest(options, function(err, response) { + assert.ifError(err); + assert.equal(response.waypoints.length, 1); + }); +}); diff --git a/test/nodejs/route.js b/test/nodejs/route.js index dedef3737..67679d498 100644 --- a/test/nodejs/route.js +++ b/test/nodejs/route.js @@ -592,17 +592,17 @@ test('route: throws on bad approaches', function(assert) { // }); // }); -// test('route: route in Monaco without motorways', function(assert) { -// assert.plan(3); -// var osrm = new OSRM({path: monaco_mld_path, algorithm: 'MLD'}); -// var options = { -// coordinates: two_test_coordinates, -// exclude: ['motorway'] -// }; -// osrm.route(options, function(err, response) { -// assert.ifError(err); -// assert.equal(response.waypoints.length, 2); -// assert.equal(response.routes.length, 1); -// }); -// }); +test('route: route in Monaco without motorways', function(assert) { + assert.plan(3); + var osrm = new OSRM({path: monaco_mld_path, algorithm: 'MLD'}); + var options = { + coordinates: two_test_coordinates, + exclude: ['motorway'] + }; + osrm.route(options, function(err, response) { + assert.ifError(err); + assert.equal(response.waypoints.length, 2); + assert.equal(response.routes.length, 1); + }); +}); diff --git a/test/nodejs/table.js b/test/nodejs/table.js index c5f1c5178..e763eea86 100644 --- a/test/nodejs/table.js +++ b/test/nodejs/table.js @@ -233,17 +233,17 @@ tables.forEach(function(annotation) { }); }); - // test('table: ' + annotation + ' table in Monaco without motorways', function(assert) { - // assert.plan(1); - // var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); - // var options = { - // coordinates: two_test_coordinates, - // exclude: ['motorway'], - // annotations: [annotation.slice(0,-1)] - // }; - // osrm.table(options, function(err, response) { - // assert.equal(response[annotation].length, 2); - // }); - // }); + test('table: ' + annotation + ' table in Monaco without motorways', function(assert) { + assert.plan(1); + var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); + var options = { + coordinates: two_test_coordinates, + exclude: ['motorway'], + annotations: [annotation.slice(0,-1)] + }; + osrm.table(options, function(err, response) { + assert.equal(response[annotation].length, 2); + }); + }); }); diff --git a/test/nodejs/trip.js b/test/nodejs/trip.js index e8010cba3..f26d97b83 100644 --- a/test/nodejs/trip.js +++ b/test/nodejs/trip.js @@ -342,17 +342,17 @@ test('trip: fixed start and end combinations', function(assert) { assert.end(); }); -// test('trip: trip in Monaco without motorways', function(assert) { -// assert.plan(3); -// var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); -// var options = { -// coordinates: two_test_coordinates, -// exclude: ['motorway'] -// }; -// osrm.trip(options, function(err, response) { -// assert.ifError(err); -// assert.equal(response.waypoints.length, 2); -// assert.equal(response.trips.length, 1); -// }); -// }); +test('trip: trip in Monaco without motorways', function(assert) { + assert.plan(3); + var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); + var options = { + coordinates: two_test_coordinates, + exclude: ['motorway'] + }; + osrm.trip(options, function(err, response) { + assert.ifError(err); + assert.equal(response.waypoints.length, 2); + assert.equal(response.trips.length, 1); + }); +}); diff --git a/unit_tests/library/extract.cpp b/unit_tests/library/extract.cpp index e085d4eee..11720f941 100644 --- a/unit_tests/library/extract.cpp +++ b/unit_tests/library/extract.cpp @@ -16,13 +16,13 @@ BOOST_AUTO_TEST_CASE(test_extract_with_invalid_config) std::exception); // including osrm::util::exception, osmium::io_error, etc. } -// BOOST_AUTO_TEST_CASE(test_extract_with_valid_config) -// { -// osrm::ExtractorConfig config; -// config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf"; -// config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf"); -// config.requested_num_threads = tbb::task_scheduler_init::default_num_threads(); -// BOOST_CHECK_NO_THROW(osrm::extract(config)); -// } +BOOST_AUTO_TEST_CASE(test_extract_with_valid_config) +{ + osrm::ExtractorConfig config; + config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf"; + config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf"); + config.requested_num_threads = tbb::task_scheduler_init::default_num_threads(); + BOOST_CHECK_NO_THROW(osrm::extract(config)); +} BOOST_AUTO_TEST_SUITE_END()