Trigger tox from package.json, if necessary.

This patch adds several fixes to improve karma test handling.

* A postinstall hook was added to package.json, which tests for
  the existence of .venv. If it is not found, it will invoke
  tox -e py27 --notest.
* Both karma.conf files were taught to automatically detect the
  directories in which the xstatic dependencies might live, and
  pick the appropriate directory.

postinstall was chosen, because setting up a virtual environment
is likely to be useful for more than one type of npm job.

Change-Id: I822cb020bd8b2ca8d4f994b9734af5636e4bd144
This commit is contained in:
Michael Krotscheck 2015-06-03 16:16:18 -07:00
parent 4ffd55c7c9
commit 76ea1f1837
3 changed files with 45 additions and 6 deletions

View File

@ -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({

View File

@ -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({

View File

@ -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": {}