test(curriculum): filter test langs by an env variable

This commit is contained in:
Valeriy S
2018-12-07 14:06:07 +03:00
committed by Stuart Taylor
parent 515999070d
commit 2137da5aa6
2 changed files with 11 additions and 3 deletions

View File

@ -27,8 +27,6 @@ const { challengeTypes } = require('../../client/utils/challengeTypes');
const { supportedLangs } = require('../utils'); const { supportedLangs } = require('../utils');
const { LOCALE: lang = 'english' } = process.env;
const oldRunnerFail = Mocha.Runner.prototype.fail; const oldRunnerFail = Mocha.Runner.prototype.fail;
Mocha.Runner.prototype.fail = function(test, err) { Mocha.Runner.prototype.fail = function(test, err) {
if (err instanceof AssertionError) { if (err instanceof AssertionError) {
@ -60,7 +58,15 @@ const jQueryScript = fs.readFileSync(
runTests(); runTests();
async function runTests() { async function runTests() {
await Promise.all(supportedLangs.map(lang => populateTestsForLang(lang))); let testLangs = [...supportedLangs];
if (process.env.TEST_CHALLENGES_FOR_LANGS) {
const filterLangs = process.env.TEST_CHALLENGES_FOR_LANGS.split(',').map(
lang => lang.trim().toLowerCase()
);
testLangs = testLangs.filter(lang => filterLangs.includes(lang));
}
await Promise.all(testLangs.map(lang => populateTestsForLang(lang)));
run(); run();
} }

View File

@ -28,3 +28,5 @@ API_LOCATION='http://localhost:3000'
FORUM_LOCATION='https://forum.localhost' FORUM_LOCATION='https://forum.localhost'
FORUM_PROXY_LOCATION='https://proxy.localhost' FORUM_PROXY_LOCATION='https://proxy.localhost'
LOCALE=english LOCALE=english
TEST_CHALLENGES_FOR_LANGS=english