-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.test.js
63 lines (50 loc) · 1.89 KB
/
main.test.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const { Lexer } = require("./src/lexer")
const { Parser } = require("./src/parser")
const { Interpreter, TabelSimbol, Konteks } = require("./src/interpreter")
const { BooLean } = require("./lib/TipeData")
const { executeFileSync, executeSync, runTerminal } = require("./main")
const { downloadModule } = require("./cmd/projek")
const utility = require("./cmd/utility");
const fs = require("fs")
const path = require("path")
const chalk = require("chalk")
const { inspect } = require("util")
const TESTFOLDER = "./test"
//const glfw = require('glfw-raub');
//var hasil = executeFileSync("./test/index.gblk")
//if (hasil.error) console.log(hasil.error.toString());
var testResults = []
fs.readdir(TESTFOLDER, (err, files) => {
if (err) return;
console.log(files)
files.forEach(file => {
var filepath = path.resolve(TESTFOLDER, file)
var projek = utility.getPackageFromDirectory(filepath);
var hasil = executeFileSync(projek ? path.join(projek.lokasi, "..", projek.script) : filepath)
if (hasil.error) console.log(hasil.error.toString());
testResults.push({ filepath, hasil })
})
console.log("========= TEST =========")
testResults.forEach((test, i) => {
console.log(i + 1 + ".", test.filepath, "\t", test.hasil.error ? chalk.red("Fail ❌") : chalk.green("Success ✔️"))
})
});
//executeSync("print('hai')", "ae.gblk")
//const skrip = `print("Hello world")`
//runTerminal(skrip, "./indeks.gblk", {runArgs: {"timeout": 1000}}).then(console.log).catch(console.error)
/* cek jumlah baris
const fs = require("fs");
const pt = require("path")
function getss(fin) {
var nl = 0
fs.readdirSync(fin).forEach((v,i) => {
if (v.endsWith(".js")) {
nl += fs.readFileSync(pt.join(fin, v)).toString().split("").length
} else if (["cmd","lib","src","test"].includes(v)) {
nl += getss(v)
}
})
return nl
}
console.log(getss("."))
*/