forked from eth-infinitism/bundler-test-executor
-
Notifications
You must be signed in to change notification settings - Fork 4
/
create-history.sh
executable file
·43 lines (33 loc) · 1.01 KB
/
create-history.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env node
// create a full history json file
//recursively remove "@" prefix from property names
function removePrefix(obj) {
return Object.keys(obj).reduce((set,key)=>{
val = obj[key]
key = key.replace(/@/,'')
return {
...set,
[key]: typeof val == 'object' && val != null ? removePrefix(val) : val
}
}, {})
}
const fs = require('fs')
const path = require('path')
dir=process.argv[2]
allFiles = fs.readFileSync(path.join(dir,'all.txt'), 'ascii').split('\n')
allFiles.sort()
allFiles.reverse()
allResults={}
allFiles.filter(f=>f.endsWith('.json')).forEach(f=>{
const [_, filepath, name] = f.match(/^(?:\W*)(.*)\/(.*?).json/)
json = JSON.parse(fs.readFileSync(path.join(dir,f), 'ascii'))
res = removePrefix(json.testsuites.testsuite)
// delete res.testcase
d = allResults[filepath]
if (!d) {
d = allResults[filepath] = {}
}
d[name] = res
//console.log(name,res)
})
console.log(JSON.stringify(allResults,null,2))