From 7ff8428ad1d8f513b8a7522c28eaef140d83435f Mon Sep 17 00:00:00 2001 From: Huyen Chau Nguyen Date: Sun, 9 Sep 2018 20:44:48 +0300 Subject: [PATCH] Revert "remove mld from moar tests..." This reverts commit ddb25cdf22b9c8b57448bbdd1d8ffde06756e5da. --- .travis.yml | 2 +- test/data/Makefile | 26 ++++++------ test/nodejs/index.js | 74 +++++++++++++++++----------------- test/nodejs/match.js | 44 ++++++++++---------- test/nodejs/route.js | 96 ++++++++++++++++++++++---------------------- test/nodejs/table.js | 24 +++++------ test/nodejs/trip.js | 26 ++++++------ 7 files changed, 146 insertions(+), 146 deletions(-) diff --git a/.travis.yml b/.travis.yml index abaa772d4..3878a1415 100644 --- a/.travis.yml +++ b/.travis.yml @@ -365,7 +365,7 @@ install: script: - if [[ $TARGET_ARCH == armhf ]] ; then echo "Skip tests for $TARGET_ARCH" && exit 0 ; fi - make -C test/data benchmark - # - ./example/build/osrm-example test/data/mld/monaco.osrm + - ./example/build/osrm-example test/data/mld/monaco.osrm # All tests assume to be run from the build directory - pushd ${OSRM_BUILD_DIR} - ./unit_tests/library-tests diff --git a/test/data/Makefile b/test/data/Makefile index cae7fdeb4..3c6adc7d2 100755 --- a/test/data/Makefile +++ b/test/data/Makefile @@ -16,7 +16,7 @@ PROFILE:=$(PROFILE_ROOT)/car.lua all: data -data: ch/$(DATA_NAME).osrm.hsgr corech/$(DATA_NAME).osrm.hsgr +data: ch/$(DATA_NAME).osrm.hsgr corech/$(DATA_NAME).osrm.hsgr mld/$(DATA_NAME).osrm.partition clean: -rm -r $(DATA_NAME).* @@ -36,9 +36,9 @@ corech/$(DATA_NAME).osrm: $(DATA_NAME).osrm mkdir -p corech cp $(DATA_NAME).osrm $(DATA_NAME).osrm.* corech/ -# mld/$(DATA_NAME).osrm: $(DATA_NAME).osrm -# mkdir -p mld -# cp $(DATA_NAME).osrm $(DATA_NAME).osrm.* mld/ +mld/$(DATA_NAME).osrm: $(DATA_NAME).osrm + mkdir -p mld + cp $(DATA_NAME).osrm $(DATA_NAME).osrm.* mld/ $(DATA_NAME).osrm: $(DATA_NAME).osm.pbf $(DATA_NAME).poly $(PROFILE) $(OSRM_EXTRACT) @echo "Verifiyng data file integrity..." @@ -54,10 +54,10 @@ corech/$(DATA_NAME).osrm.hsgr: corech/$(DATA_NAME).osrm $(PROFILE) $(OSRM_CONTRA @echo "Running osrm-contract..." $(TIMER) "osrm-contract\t$@" $(OSRM_CONTRACT) --core=0.5 $< -# mld/$(DATA_NAME).osrm.partition: mld/$(DATA_NAME).osrm $(PROFILE) $(OSRM_PARTITION) -# @echo "Running osrm-partition..." -# $(TIMER) "osrm-partition\t$@" $(OSRM_PARTITION) $< -# $(TIMER) "osrm-customize\t$@" $(OSRM_CUSTOMIZE) $< +mld/$(DATA_NAME).osrm.partition: mld/$(DATA_NAME).osrm $(PROFILE) $(OSRM_PARTITION) + @echo "Running osrm-partition..." + $(TIMER) "osrm-partition\t$@" $(OSRM_PARTITION) $< + $(TIMER) "osrm-customize\t$@" $(OSRM_CUSTOMIZE) $< $(DATA_NAME).requests: $(DATA_NAME).poly $(POLY2REQ) $(DATA_NAME).poly > $(DATA_NAME).requests @@ -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 6c19b83a3..bbe58849f 100644 --- a/test/nodejs/index.js +++ b/test/nodejs/index.js @@ -28,8 +28,8 @@ test('constructor: throws if necessary files do not exist', function(assert) { 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) { @@ -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); @@ -102,7 +102,7 @@ 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'); + 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) { @@ -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/route.js b/test/nodejs/route.js index dedef3737..011a098a3 100644 --- a/test/nodejs/route.js +++ b/test/nodejs/route.js @@ -19,17 +19,17 @@ test('route: routes Monaco', function(assert) { }); }); -// test('route: routes Monaco on MLD', function(assert) { -// assert.plan(5); -// var osrm = new OSRM({path: monaco_mld_path, algorithm: 'MLD'}); -// osrm.route({coordinates: [[13.43864,52.51993],[13.415852,52.513191]]}, function(err, route) { -// assert.ifError(err); -// assert.ok(route.waypoints); -// assert.ok(route.routes); -// assert.ok(route.routes.length); -// assert.ok(route.routes[0].geometry); -// }); -// }); +test('route: routes Monaco on MLD', function(assert) { + assert.plan(5); + var osrm = new OSRM({path: monaco_mld_path, algorithm: 'MLD'}); + osrm.route({coordinates: [[13.43864,52.51993],[13.415852,52.513191]]}, function(err, route) { + assert.ifError(err); + assert.ok(route.waypoints); + assert.ok(route.routes); + assert.ok(route.routes.length); + assert.ok(route.routes[0].geometry); + }); +}); test('route: routes Monaco on CoreCH', function(assert) { assert.plan(5); @@ -566,43 +566,43 @@ test('route: throws on bad approaches', function(assert) { /Approach must be a string: \[curb, unrestricted\] or null/); }); -// test('route: routes Monaco with custom limits on MLD', function(assert) { -// assert.plan(2); -// var osrm = new OSRM({ -// path: monaco_mld_path, -// algorithm: 'MLD', -// max_alternatives: 10, -// }); -// osrm.route({coordinates: two_test_coordinates, alternatives: 10}, function(err, route) { -// assert.ifError(err); -// assert.ok(Array.isArray(route.routes)); -// }); -// }); +test('route: routes Monaco with custom limits on MLD', function(assert) { + assert.plan(2); + var osrm = new OSRM({ + path: monaco_mld_path, + algorithm: 'MLD', + max_alternatives: 10, + }); + osrm.route({coordinates: two_test_coordinates, alternatives: 10}, function(err, route) { + assert.ifError(err); + assert.ok(Array.isArray(route.routes)); + }); +}); -// test('route: in Monaco with custom limits on MLD', function(assert) { -// assert.plan(1); -// var osrm = new OSRM({ -// path: monaco_mld_path, -// algorithm: 'MLD', -// max_alternatives: 10, -// }); -// osrm.route({coordinates: two_test_coordinates, alternatives: 11}, function(err, route) { -// console.log(err) -// assert.equal(err.message, 'TooBig'); -// }); -// }); +test('route: in Monaco with custom limits on MLD', function(assert) { + assert.plan(1); + var osrm = new OSRM({ + path: monaco_mld_path, + algorithm: 'MLD', + max_alternatives: 10, + }); + osrm.route({coordinates: two_test_coordinates, alternatives: 11}, function(err, route) { + console.log(err) + assert.equal(err.message, 'TooBig'); + }); +}); -// 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); + }); +});