mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
Fix setting of environment variables in gulp test tasks in Windows
See this stackoverflow link for why this is necessary http://stackoverflow.com/questions/27084392/code-coverage-for-mocha-in-windows-7/27193866#27193866
This commit is contained in:
committed by
Blade Barringer
parent
fc8c377eab
commit
5b740b1a11
@@ -11,6 +11,7 @@ import psTree from 'ps-tree';
|
||||
import gulp from 'gulp';
|
||||
import Q from 'q';
|
||||
import runSequence from 'run-sequence';
|
||||
import os from 'os';
|
||||
|
||||
const TEST_SERVER_PORT = 3003
|
||||
const TEST_DB = 'habitrpg_test'
|
||||
@@ -34,8 +35,16 @@ let testCount = (stdout, regexp) => {
|
||||
return parseInt(match && match[1] || 0);
|
||||
}
|
||||
|
||||
let testBin = (string) => {
|
||||
return `NODE_ENV=testing ${string}`;
|
||||
let testBin = (string, additionalEnvVariables = '') => {
|
||||
if(os.platform() === "win32") {
|
||||
if(additionalEnvVariables != '') {
|
||||
additionalEnvVariables = additionalEnvVariables.split(' ').join('&&set ');
|
||||
additionalEnvVariables = 'set ' + additionalEnvVariables + '&&';
|
||||
}
|
||||
return `set NODE_ENV=testing&&${additionalEnvVariables}${string}`;
|
||||
} else {
|
||||
return `NODE_ENV=testing ${additionalEnvVariables} ${string}`;
|
||||
}
|
||||
};
|
||||
|
||||
gulp.task('test:nodemon', (done) => {
|
||||
@@ -56,7 +65,7 @@ gulp.task('test:prepare:mongo', (cb) => {
|
||||
|
||||
gulp.task('test:prepare:server', ['test:prepare:mongo'], () => {
|
||||
if (!server) {
|
||||
server = exec(`NODE_ENV="TESTING" NODE_DB_URI="${TEST_DB_URI}" PORT="${TEST_SERVER_PORT}" node ./website/src/server.js`, (error, stdout, stderr) => {
|
||||
server = exec(testBin('node ./website/src/server.js', `NODE_DB_URI=${TEST_DB_URI} PORT=${TEST_SERVER_PORT} `), (error, stdout, stderr) => {
|
||||
if (error) { throw `Problem with the server: ${error}`; }
|
||||
if (stderr) { console.error(stderr); }
|
||||
});
|
||||
@@ -249,7 +258,7 @@ gulp.task('test:karma:safe', ['test:prepare:build'], (cb) => {
|
||||
gulp.task('test:e2e', ['test:prepare', 'test:prepare:server'], (cb) => {
|
||||
let support = [
|
||||
'Xvfb :99 -screen 0 1024x768x24 -extension RANDR',
|
||||
'npm run test:e2e:webdriver',
|
||||
testBin('npm run test:e2e:webdriver', 'DISPLAY=:99'),
|
||||
].map(exec);
|
||||
support.push(server);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user