Enable npm and library tests on windows

This commit is contained in:
Michael Krasnyk
2016-12-26 19:00:08 +01:00
committed by Moritz Kobitzsch
parent bd2a5ebe10
commit f48bbb78de
8 changed files with 48 additions and 36 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ module.exports = function() {
// converts the scenario titles in file prefixes
this.getScenarioID = (scenario) => {
let name = scenario.getName().toLowerCase().replace(/[\/\-'=,\(\)]/g, '').replace(/\s/g, '_').replace(/__/g, '_').replace(/\.\./g, '.');
let name = scenario.getName().toLowerCase().replace(/[\/\-'=,\(\):\*#]/g, '').replace(/\s/g, '_').replace(/__/g, '_').replace(/\.\./g, '.');
return util.format('%d_%s', scenario.getLine(), name);
};
+15 -26
View File
@@ -42,44 +42,33 @@ module.exports = function () {
this.OSRM_PORT = process.env.OSRM_PORT && parseInt(process.env.OSRM_PORT) || 5000;
this.HOST = 'http://127.0.0.1:' + this.OSRM_PORT;
// TODO make sure this works on win
if (process.platform.match(/indows.*/)) {
if (process.platform.match(/^win.*/)) {
this.TERMSIGNAL = 9;
this.EXE = '.exe';
this.LIB = '.dll';
this.QQ = '"';
} else {
this.TERMSIGNAL = 'SIGTERM';
this.EXE = '';
}
// heuristically detect .so/.a suffix
this.LIB = null;
// heuristically detect .so/.a/.dll/.lib suffix
this.LIB = ['lib%s.a', 'lib%s.so', '%s.dll', '%s.lib'].find((format) => {
try {
const dot_a = util.format('%s/libosrm%s', this.BIN_PATH, '.a');
fs.accessSync(dot_a, fs.F_OK);
this.LIB = '.a';
} catch(e) { /*nop*/ }
const lib = this.BIN_PATH + '/' + util.format(format, 'osrm');
fs.accessSync(lib, fs.F_OK);
} catch(e) { return false; }
return true;
});
try {
const dot_so = util.format('%s/libosrm%s', this.BIN_PATH, '.so');
fs.accessSync(dot_so, fs.F_OK);
this.LIB = '.so';
} catch(e) { /*nop*/ }
if (!this.LIB) {
throw new Error('*** Unable to detect dynamic or static libosrm libraries');
}
this.QQ = '';
if (this.LIB === undefined) {
throw new Error('*** Unable to detect dynamic or static libosrm libraries');
}
this.OSRM_EXTRACT_PATH = path.resolve(util.format('%s/%s%s', this.BIN_PATH, 'osrm-extract', this.EXE));
this.OSRM_CONTRACT_PATH = path.resolve(util.format('%s/%s%s', this.BIN_PATH, 'osrm-contract', this.EXE));
this.OSRM_ROUTED_PATH = path.resolve(util.format('%s/%s%s', this.BIN_PATH, 'osrm-routed', this.EXE));
this.LIB_OSRM_EXTRACT_PATH = util.format('%s/libosrm_extract%s', this.BIN_PATH, this.LIB),
this.LIB_OSRM_CONTRACT_PATH = util.format('%s/libosrm_contract%s', this.BIN_PATH, this.LIB),
this.LIB_OSRM_PATH = util.format('%s/libosrm%s', this.BIN_PATH, this.LIB);
this.LIB_OSRM_EXTRACT_PATH = util.format('%s/' + this.LIB, this.BIN_PATH, 'osrm_extract'),
this.LIB_OSRM_CONTRACT_PATH = util.format('%s/' + this.LIB, this.BIN_PATH, 'osrm_contract'),
this.LIB_OSRM_PATH = util.format('%s/' + this.LIB, this.BIN_PATH, 'osrm');
// eslint-disable-next-line no-console
console.info(util.format('Node Version', process.version));
@@ -108,7 +97,7 @@ module.exports = function () {
var verify = (binPath, cb) => {
fs.exists(binPath, (exists) => {
if (!exists) return cb(new Error(util.format('%s is missing. Build failed?', binPath)));
var helpPath = util.format('%s --help > /dev/null 2>&1', binPath);
var helpPath = util.format('%s --help', binPath);
child_process.exec(helpPath, (err) => {
if (err) {
return cb(new Error(util.format('*** %s exited with code %d', helpPath, err.code)));
+2 -1
View File
@@ -1,5 +1,6 @@
'use strict';
const path = require('path');
const fs = require('fs');
const util = require('util');
const child_process = require('child_process');
@@ -36,7 +37,7 @@ module.exports = function () {
};
this.runBin = (bin, options, env, callback) => {
let cmd = util.format('%s%s/%s%s%s', this.QQ, this.BIN_PATH, bin, this.EXE, this.QQ);
let cmd = path.resolve(util.format('%s/%s%s', this.BIN_PATH, bin, this.EXE));
let opts = options.split(' ').filter((x) => { return x && x.length > 0; });
let log = fs.createWriteStream(this.scenarioLogFile, {'flags': 'a'});
log.write(util.format('*** running %s %s\n', cmd, options));