File index.js changed (mode: 100755) (index 448c402..65c17d9) |
... |
... |
processDef(defPath); |
25 |
25 |
function processDef(defPath) { |
function processDef(defPath) { |
26 |
26 |
console.log("processing ", defPath); |
console.log("processing ", defPath); |
27 |
27 |
readDef(defPath).then((obj) => { |
readDef(defPath).then((obj) => { |
28 |
|
readDef(path.join(__dirname, "asserter/def.yml")).then((obj2) => { |
|
29 |
|
let result = [obj, obj2].join(" "); |
|
30 |
|
if (argv.common || argv.c) { |
|
31 |
|
result += " -pthread -DTARGET_TEST=1"; |
|
|
28 |
|
let result = obj; |
|
29 |
|
if (argv.common || argv.c) { |
|
30 |
|
result += ` -pthread -DTARGET_TEST=1 `; |
|
31 |
|
} |
|
32 |
|
if (argv.test || argv.t) { |
|
33 |
|
result += ` -isystem ${__dirname} ${path.join( |
|
34 |
|
__dirname, |
|
35 |
|
"asserter/src/archiver.cpp" |
|
36 |
|
)} ${path.join(__dirname, "asserter/src/asserter.cpp")} `; |
|
37 |
|
let compiler = "g++"; |
|
38 |
|
if (argv.clang || argv.llvm) { |
|
39 |
|
compiler = "clang++"; |
|
40 |
|
} else if (argv.emcc) { |
|
41 |
|
compiler = "emcc"; |
32 |
42 |
} |
} |
33 |
|
if (argv.test || argv.t) { |
|
34 |
|
let compiler = "g++"; |
|
35 |
|
if (argv.clang || argv.llvm) { |
|
36 |
|
compiler = "clang++"; |
|
37 |
|
} else if (argv.emcc) { |
|
38 |
|
compiler = "emcc"; |
|
|
43 |
|
tmp.dir((err, tmpDir) => { |
|
44 |
|
if (err) throw err; |
|
45 |
|
const execFile = path.join(tmpDir, "test"); |
|
46 |
|
console.log("test directory:", tmpDir); |
|
47 |
|
result = `${compiler} ${result} -o ${execFile}`; |
|
48 |
|
if (argv.verbose || argv.v) { |
|
49 |
|
console.log(result); |
39 |
50 |
} |
} |
40 |
|
tmp.dir((err, tmpDir) => { |
|
41 |
|
if (err) throw err; |
|
42 |
|
const execFile = path.join(tmpDir, "test"); |
|
43 |
|
console.log("test directory:", tmpDir); |
|
44 |
|
result = `${compiler} ${result} -o ${execFile}`; |
|
45 |
|
if (argv.verbose || argv.v) { |
|
46 |
|
console.log(result); |
|
|
51 |
|
shell.exec(result); |
|
52 |
|
shell.exec("./test", { cwd: tmpDir }); |
|
53 |
|
fs.readFile(path.join(tmpDir, "result.json"), "utf8", (err, result) => { |
|
54 |
|
if (!err) { |
|
55 |
|
const resultObj = JSON.parse(result); |
|
56 |
|
assertionsPassed += resultObj.passed; |
47 |
57 |
} |
} |
48 |
|
shell.exec(result); |
|
49 |
|
shell.exec("./test", { cwd: tmpDir }); |
|
50 |
|
fs.readFile( |
|
51 |
|
path.join(tmpDir, "result.json"), |
|
52 |
|
"utf8", |
|
53 |
|
(err, result) => { |
|
54 |
|
if (!err) { |
|
55 |
|
const resultObj = JSON.parse(result); |
|
56 |
|
assertionsPassed += resultObj.passed; |
|
57 |
|
} |
|
58 |
|
} |
|
59 |
|
); |
|
60 |
58 |
}); |
}); |
61 |
|
} else { |
|
62 |
|
console.log(result); |
|
63 |
|
} |
|
64 |
|
}); |
|
|
59 |
|
}); |
|
60 |
|
} else { |
|
61 |
|
console.log(result); |
|
62 |
|
} |
65 |
63 |
}); |
}); |
66 |
64 |
} |
} |
67 |
65 |
|
|
68 |
66 |
function getDef(def, defFile) { |
function getDef(def, defFile) { |
69 |
67 |
const extname = path.extname(defFile); |
const extname = path.extname(defFile); |
70 |
68 |
if (extname.toUpperCase() === ".YML") { |
if (extname.toUpperCase() === ".YML") { |
71 |
|
return YAML.parse(def); |
|
|
69 |
|
return YAML.parse(def); |
72 |
70 |
} |
} |
73 |
71 |
return JSON.parse(def); |
return JSON.parse(def); |
74 |
72 |
} |
} |