-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add update -all-test-.js command to main menu
- Loading branch information
1 parent
72e5a6e
commit dfe0137
Showing
7 changed files
with
151 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// ---------------------- | ||
// - get all test files - | ||
// ---------------------- | ||
|
||
let walk = require('walk') // file system walker (get file names) | ||
|
||
let getAllTestFiles = function() { | ||
return new Promise(function(resolve, reject) { | ||
let allTestFileNames = [] | ||
let walker = walk.walk('./bivariate_data/test_scripts', { followLinks: true }) | ||
|
||
walker.on('file', function(root, stat, next) { | ||
let currentFile = stat.name | ||
if(currentFile.charAt(0) === "_" && currentFile.charAt(1) !== "_") { | ||
currentFile = currentFile.slice(0, -3) | ||
currentFile = root + '\/' + currentFile | ||
currentFile = currentFile.replace(/\\/g, "/") | ||
currentFile = currentFile.replace(/\.\/bivariate_data\/test_scripts\//g, "") | ||
allTestFileNames.push(currentFile) | ||
} | ||
next() | ||
}) | ||
|
||
walker.on('end', function() { | ||
resolve(allTestFileNames) | ||
}) | ||
|
||
}) | ||
} | ||
|
||
|
||
// ************* | ||
// ** Exports ** | ||
// ************* | ||
module.exports = getAllTestFiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// ----------------------------- | ||
// -- update -all- test group -- | ||
// ----------------------------- | ||
// jshint esversion: 6 | ||
|
||
let updateAllTestGroup = function updateAllTestGroup() { | ||
let colors = require("colors") // pretty console colors | ||
let forEach = require('mout/array/forEach') // foreach array util | ||
let getAllTestFiles = require('./_getAllTestFiles') | ||
let path = require('path') | ||
|
||
return new Promise(function(resolve, reject) { | ||
getAllTestFiles() | ||
.then(function(testGroups) { | ||
let allTestFilePath = path.join(process.cwd(), "./bivariate_data/test_scripts/-all-tests-.js") | ||
let scenariosStringStart = "\"scenarios\": \[" | ||
let scenariosStringEnd = "\n\t\t\]" | ||
let scenarioList = "" | ||
|
||
/// loop trough tests and create regex replace string for -all- scenario | ||
forEach(testGroups, function(val) { | ||
val = val.replace(/\\/g,"\/") | ||
scenarioList += "\n\t\t\trequire\(\'\.\/" + val + "\'\)\(baseURLs\)," | ||
}) | ||
|
||
let scenariosString = scenariosStringStart + scenarioList + scenariosStringEnd | ||
|
||
const copy = require('recursive-copy') | ||
const replaceInFile = require('replace-in-file') | ||
|
||
let templateTest = path.join(__dirname, '../init-bivariate-data/templates/-all-tests-.js') | ||
let allTestFile = path.join(process.cwd(), './bivariate_data/test_scripts/-all-tests-.js') | ||
|
||
copy(templateTest, allTestFile, { overwrite: true }, function(error, results) { | ||
if (error) { | ||
console.error('failed to create Test file: ' + error) | ||
} | ||
else { | ||
let templateOptions = { | ||
files: allTestFilePath, | ||
from: [ | ||
/\"scenarios\"\: \[[\s\S]*\]/gm | ||
], | ||
to: [ | ||
scenariosString | ||
] | ||
} | ||
|
||
try { | ||
// update -all-tests-.js script scenario with all test files | ||
const changes = replaceInFile.sync(templateOptions) | ||
// console.log('Modified files:', changes.join(', ')) | ||
|
||
if (changes) { | ||
// console.log(("test files:").yellow.bold) | ||
// console.log(testGroups) | ||
resolve('UPDATED -all-tests-.js scenario with all test files') | ||
} | ||
} | ||
catch (error) { | ||
console.error('Error occurred:', error) | ||
} | ||
} | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
|
||
// ************* | ||
// ** Exports ** | ||
// ************* | ||
module.exports = updateAllTestGroup |
8 changes: 4 additions & 4 deletions
8
...e-data/test_scripts/example-test-group.js → init-bivariate-data/templates/-all-tests-.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// ---------------------- | ||
// -- -all- Test Group -- | ||
// ---------------------- | ||
|
||
let mixIn = require("../libs/mout-mixin/mixIn") | ||
let testGroup = __filename.slice(__dirname.length + 1, -3) | ||
let configCommon = require('./__config-common')(testGroup) | ||
let baseURLs = require("./__config-baseURLs") | ||
|
||
|
||
module.exports = mixIn( | ||
{ | ||
// --------------- | ||
// -- Scenarios -- | ||
// --------------- | ||
"scenarios": [ | ||
require('./_example-test--home')(baseURLs), | ||
require('./_example-test--paints')(baseURLs) | ||
], | ||
}, | ||
configCommon | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters