diff options
author | Dimitry <dimitry@ethdev.com> | 2017-02-17 20:19:07 +0800 |
---|---|---|
committer | Dimitry <dimitry@ethdev.com> | 2017-02-17 20:19:07 +0800 |
commit | 0e7c51bb0a4755a2bebe11c72a579a962b3c205b (patch) | |
tree | 98d45d474f720014f348e7f5ba85a975b135e22c /RPCTests/modules | |
parent | a20bb807ab40fb06277ca278a00c77eac57d551a (diff) | |
download | dexon-tests-0e7c51bb0a4755a2bebe11c72a579a962b3c205b.tar dexon-tests-0e7c51bb0a4755a2bebe11c72a579a962b3c205b.tar.gz dexon-tests-0e7c51bb0a4755a2bebe11c72a579a962b3c205b.tar.bz2 dexon-tests-0e7c51bb0a4755a2bebe11c72a579a962b3c205b.tar.lz dexon-tests-0e7c51bb0a4755a2bebe11c72a579a962b3c205b.tar.xz dexon-tests-0e7c51bb0a4755a2bebe11c72a579a962b3c205b.tar.zst dexon-tests-0e7c51bb0a4755a2bebe11c72a579a962b3c205b.zip |
move tests to separate folders
Diffstat (limited to 'RPCTests/modules')
-rw-r--r-- | RPCTests/modules/testutils.js | 49 | ||||
-rw-r--r-- | RPCTests/modules/utils.js | 21 |
2 files changed, 47 insertions, 23 deletions
diff --git a/RPCTests/modules/testutils.js b/RPCTests/modules/testutils.js index 7128c6972..54cd64525 100644 --- a/RPCTests/modules/testutils.js +++ b/RPCTests/modules/testutils.js @@ -26,31 +26,40 @@ generateCustomGenesis: function generateCustomGenesis(path, originalPath, accoun readTestsInFolder: function readTestsInFolder(path) { - var res = utils.listFiles(path); - res.forEach(function(file) { - var testn = file.indexOf("test"); - var slashn = file.indexOf("_"); - if (testn != -1 && slashn != -1) - { - testNumber = parseInt(file.substring(testn + 4, slashn)); - var noden = file.indexOf("node"); - var slashn = file.indexOf("_", slashn+1); - var tmpFile = file.indexOf("~"); - if (noden != -1 && slashn != -1 && tmpFile == -1) + var testNumber = 0; + var folders = utils.listFolders(path); + folders.forEach(function(folder) { + + var res = utils.listFiles(folder); + res.forEach(function(file) { + + var testn = file.indexOf("step"); + var slashn = file.indexOf("_"); + if (testn != -1 && slashn != -1) { - if (tests[testNumber]) - console.log("Error: dublicate test found " + file); - else + //testNumber = parseInt(file.substring(testn + 4, slashn)); + var noden = file.indexOf("node"); + var slashn = file.indexOf("_", slashn+1); + var tmpFile = file.indexOf("~"); + if (noden != -1 && slashn != -1 && tmpFile == -1) { - var testObject = {}; - testObject.file = file; - testObject.node = file.substring(noden + 4, slashn); - tests[testNumber] = testObject; - testCount++; + if (tests[testNumber]) + console.log("Error: dublicate test found " + file); + else + { + var testObject = {}; + testObject.file = file; + testObject.node = file.substring(noden + 4, slashn); + tests[testNumber] = testObject; + testCount++; + testNumber++; + } } } - } + }); }); + + //console.log(tests); }, getTestCount: function getTestCount() diff --git a/RPCTests/modules/utils.js b/RPCTests/modules/utils.js index 24e9bd811..5d32ec771 100644 --- a/RPCTests/modules/utils.js +++ b/RPCTests/modules/utils.js @@ -45,19 +45,34 @@ module.exports = { fs.writeFile(path, data, (err) => { if (err) throw err;}); }, - listFiles: function listFiles(dir) { + listFiles: function listFiles(dir, recursive = false) { var results = []; fs.readdirSync(dir).forEach(function(file) { file = dir+'/'+file; var stat = fs.statSync(file); - if (stat && stat.isDirectory()) { - results = results.concat(listFiles(file)) + if (stat && stat.isDirectory() && recursive) { + results = results.concat(listFiles(file, recursive)) } else results.push(file); }); return results; + }, + + listFolders: function listFolders(dir) { + + var results = []; + fs.readdirSync(dir).forEach(function(file) { + file = dir+'/'+file; + var stat = fs.statSync(file); + + if (stat && stat.isDirectory()) { + results.push(file); + } + }); + + return results; } } //exports |