diff --git a/features/support/config.js b/features/support/config.js index 169cf434e..769755f4f 100644 --- a/features/support/config.js +++ b/features/support/config.js @@ -50,21 +50,27 @@ module.exports = function () { }; var hashExtract = (cb) => { - this.hashOfFiles(util.format('%s/osrm-extract%s', this.BIN_PATH, this.EXE), (hash) => { + var files = [ util.format('%s/osrm-extract%s', this.BIN_PATH, this.EXE), + util.format('%s/libosrm_extract%s', this.BIN_PATH, this.LIB) ]; + this.hashOfFiles(files, (hash) => { this.binExtractHash = hash; cb(); }); }; var hashContract = (cb) => { - this.hashOfFiles(util.format('%s/osrm-contract%s', this.BIN_PATH, this.EXE), (hash) => { + var files = [ util.format('%s/osrm-contract%s', this.BIN_PATH, this.EXE), + util.format('%s/libosrm_contract%s', this.BIN_PATH, this.LIB) ]; + this.hashOfFiles(files, (hash) => { this.binContractHash = hash; cb(); }); }; var hashRouted = (cb) => { - this.hashOfFiles(util.format('%s/osrm-routed%s', this.BIN_PATH, this.EXE), (hash) => { + var files = [ util.format('%s/osrm-routed%s', this.BIN_PATH, this.EXE), + util.format('%s/libosrm%s', this.BIN_PATH, this.LIB) ]; + this.hashOfFiles(files, (hash) => { this.binRoutedHash = hash; this.fingerprintRoute = this.hashString(this.binRoutedHash); cb(); diff --git a/features/support/env.js b/features/support/env.js index 8684cc687..32ff82d04 100644 --- a/features/support/env.js +++ b/features/support/env.js @@ -32,10 +32,12 @@ module.exports = function () { if (process.platform.match(/indows.*/)) { this.TERMSIGNAL = 9; this.EXE = '.exe'; + this.LIB = '.dll'; this.QQ = '"'; } else { this.TERMSIGNAL = 'SIGTERM'; this.EXE = ''; + this.LIB = '.so'; this.QQ = ''; } diff --git a/features/support/hash.js b/features/support/hash.js index 6ab44ad20..399dd51ca 100644 --- a/features/support/hash.js +++ b/features/support/hash.js @@ -6,14 +6,19 @@ var d3 = require('d3-queue'); module.exports = function () { this.hashOfFiles = (paths, cb) => { paths = Array.isArray(paths) ? paths : [paths]; - var shasum = crypto.createHash('sha1'); + var shasum = crypto.createHash('sha1'), hashedFiles = false; var q = d3.queue(1); var addFile = (path, cb) => { fs.readFile(path, (err, data) => { - shasum.update(data); - cb(err); + if (err && err.code === 'ENOENT') cb(); // ignore non-existing files + else if (err) cb(err); + else { + shasum.update(data); + hashedFiles = true; + cb(); + } }); }; @@ -21,6 +26,7 @@ module.exports = function () { q.awaitAll(err => { if (err) throw new Error('*** Error reading files:', err); + if (!hashedFiles) throw new Error('*** No files found: [' + paths.join(', ') + ']'); cb(shasum.digest('hex')); }); };