diff --git a/horizon/karma.conf.js b/horizon/karma.conf.js index 3f6bc7d44c..8cef1246e9 100644 --- a/horizon/karma.conf.js +++ b/horizon/karma.conf.js @@ -1,7 +1,26 @@ -module.exports = function(config){ +var fs = require('fs'); +var path = require('path'); - // Path to xstatic pkg path. - var xstaticPath = '../../.venv/lib/python2.7/site-packages/xstatic/pkg/'; +module.exports = function(config){ + var xstaticPath; + var base_paths = [ + './.venv', + './.tox/py27' + ] + + for( var i = 0; i < base_paths.length; i++) { + var base_path = path.resolve(base_paths[i]); + + if( fs.existsSync(base_path) ) { + xstaticPath = base_path + '/lib/python2.7/site-packages/xstatic/pkg/'; + break; + } + } + + if( !xstaticPath) { + console.error("xStatic libraries not found, please set up venv"); + process.exit(1); + } config.set({ diff --git a/openstack_dashboard/karma.conf.js b/openstack_dashboard/karma.conf.js index 572575401f..3bdb7e0d0a 100644 --- a/openstack_dashboard/karma.conf.js +++ b/openstack_dashboard/karma.conf.js @@ -1,7 +1,26 @@ -module.exports = function(config){ +var fs = require('fs'); +var path = require('path'); - // Path to xstatic pkg path. - var xstaticPath = '../../.venv/lib/python2.7/site-packages/xstatic/pkg/'; +module.exports = function(config){ + var xstaticPath; + var base_paths = [ + './.venv', + './.tox/py27' + ] + + for( var i = 0; i < base_paths.length; i++) { + var base_path = path.resolve(base_paths[i]); + + if( fs.existsSync(base_path) ) { + xstaticPath = base_path + '/lib/python2.7/site-packages/xstatic/pkg/'; + break; + } + } + + if( !xstaticPath) { + console.error("xStatic libraries not found, please set up venv"); + process.exit(1); + } config.set({ diff --git a/package.json b/package.json index 4c283bfa8a..a431e24586 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "phantomjs": "1.9.17" }, "scripts": { + "postinstall": "if [ ! -d .venv ]; then tox -epy27 --notest; fi", "test": "karma start horizon/karma.conf.js --single-run && karma start openstack_dashboard/karma.conf.js --single-run" }, "dependencies": {}