mirror of https://github.com/japl-lang/japl.git
Minor fixes and cleanups
This commit is contained in:
parent
a5371ea25b
commit
b67ec65a33
4
build.py
4
build.py
|
@ -86,6 +86,7 @@ def run_command(command: str, mode: str = "Popen", **kwargs):
|
|||
return code, stderr and stdout
|
||||
"""
|
||||
|
||||
logging.debug(f"Running '{command}'")
|
||||
if mode == "Popen":
|
||||
process = Popen(shlex.split(command, posix=os.name != "nt"), **kwargs)
|
||||
stdout, stderr = process.communicate()
|
||||
|
@ -165,7 +166,6 @@ def build(path: str, flags: Optional[Dict[str, str]] = {}, options: Optional[Dic
|
|||
logging.debug(f"Compiling '{main_path}'")
|
||||
nim_flags = " ".join(f"-{name}:{value}" if len(name) == 1 else f"--{name}:{value}" for name, value in flags.items())
|
||||
command = "nim {flags} compile {path}".format(flags=nim_flags, path=main_path)
|
||||
logging.debug(f"Running '{command}'")
|
||||
logging.info("Compiling JAPL")
|
||||
start = time()
|
||||
_, stderr, status = run_command(command, stdout=DEVNULL, stderr=PIPE)
|
||||
|
@ -187,7 +187,7 @@ def build(path: str, flags: Optional[Dict[str, str]] = {}, options: Optional[Dic
|
|||
if status != 0:
|
||||
logging.error(f"Command '{command}' exited with non-0 exit code {status}, output below:\n{stderr.decode()}")
|
||||
else:
|
||||
command = f"nim compile {tests_path}"
|
||||
command = f"nim compile --opt:speed {tests_path}"
|
||||
_, stderr, status = run_command(command, stdout=DEVNULL, stderr=PIPE)
|
||||
if status != 0:
|
||||
logging.error(f"Command '{command}' exited with non-0 exit code {status}, output below:\n{stderr.decode()}")
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
},
|
||||
"verbose": true,
|
||||
"override_config": true,
|
||||
"skip_tests": true,
|
||||
"install": true,
|
||||
"ignore_binary": true,
|
||||
"options": {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"gc": "none",
|
||||
"d": "danger"
|
||||
},
|
||||
"skip_tests": true,
|
||||
"verbose": true,
|
||||
"override_config": true,
|
||||
"install": true,
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"gc": "none",
|
||||
"d": "danger"
|
||||
},
|
||||
"skip_tests": true,
|
||||
"verbose": true,
|
||||
"override_config": true,
|
||||
"install": true,
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"gc": "none",
|
||||
"d": "danger"
|
||||
},
|
||||
"skip_tests": true,
|
||||
"verbose": true,
|
||||
"override_config": true,
|
||||
"install": true,
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"gc": "none",
|
||||
"d": "danger"
|
||||
},
|
||||
"skip_tests": true,
|
||||
"verbose": true,
|
||||
"override_config": true,
|
||||
"install": true,
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"gc": "none",
|
||||
"d": "danger"
|
||||
},
|
||||
"skip_tests": true,
|
||||
"verbose": true,
|
||||
"override_config": true,
|
||||
"install": true,
|
||||
|
|
Binary file not shown.
|
@ -14,24 +14,21 @@
|
|||
|
||||
import testobject
|
||||
import logutils
|
||||
import testconfig
|
||||
|
||||
import os
|
||||
import strutils
|
||||
import sequtils
|
||||
import strformat
|
||||
|
||||
|
||||
proc parseModalLine(line: string): tuple[modal: bool, mode: string, detail: string, comment: bool] =
|
||||
|
||||
# when non modal, mode becomes the line
|
||||
# when comment is true, it must not do anything to whenever it is exported
|
||||
|
||||
let line = line
|
||||
result.modal = false
|
||||
result.mode = ""
|
||||
result.detail = ""
|
||||
result.comment = false
|
||||
|
||||
if line.len() > 0 and line[0] == '[':
|
||||
if line.len() > 1:
|
||||
if line[1] == '[':
|
||||
|
@ -45,9 +42,7 @@ proc parseModalLine(line: string): tuple[modal: bool, mode: string, detail: stri
|
|||
else:
|
||||
result.mode = line
|
||||
return result
|
||||
|
||||
var colon = false
|
||||
|
||||
for i in countup(0, line.high()):
|
||||
let ch = line[i]
|
||||
if ch in Letters or ch in Digits or ch in {'_', '-'}:
|
||||
|
@ -73,6 +68,7 @@ proc parseModalLine(line: string): tuple[modal: bool, mode: string, detail: stri
|
|||
if line[line.high()] != ']':
|
||||
fatal &"Line <{line}> must be closed off by ']'."
|
||||
|
||||
|
||||
proc buildTest(lines: seq[string], i: var int, name: string, path: string): Test =
|
||||
result = newTest(name, path)
|
||||
# since this is a very simple parser, some state can reduce code length
|
||||
|
@ -140,13 +136,13 @@ proc buildTest(lines: seq[string], i: var int, name: string, path: string): Test
|
|||
inc i
|
||||
fatal &"Test mode unfinished (missing [end]?)."
|
||||
|
||||
|
||||
proc buildTestFile(path: string): seq[Test] =
|
||||
log(LogLevel.Debug, &"Checking {path} for tests")
|
||||
let lines = path.readFile().split('\n')
|
||||
var i = 0
|
||||
while i < lines.len():
|
||||
let parsed = lines[i].parseModalLine()
|
||||
let line = parsed.mode
|
||||
if parsed.modal and not parsed.comment:
|
||||
if parsed.mode == "test":
|
||||
let testname = parsed.detail
|
||||
|
@ -157,7 +153,8 @@ proc buildTestFile(path: string): seq[Test] =
|
|||
|
||||
# root can only contain "test" modes, anything else is just a comment (including modal and non modal comments)
|
||||
inc i
|
||||
|
||||
|
||||
|
||||
proc buildTests*(testDir: string): seq[Test] =
|
||||
for candidateObj in walkDir(testDir):
|
||||
let candidate = candidateObj.path
|
||||
|
|
Loading…
Reference in New Issue