summaryrefslogtreecommitdiff
path: root/mbld
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-08-24 06:07:30 -0700
committerOri Bernstein <ori@eigenstate.org>2018-08-24 06:07:30 -0700
commite54af86927ced66fb7fa8ad744cfb609390f04d8 (patch)
treebb297c1f908ef83ee6544a0bd1c7a424be0ae7c4 /mbld
parent93cff6aba077499c3693896cba43b1ceaaca7a62 (diff)
downloadmc-e54af86927ced66fb7fa8ad744cfb609390f04d8.tar.gz
Add -v option, make it print test output.
Diffstat (limited to 'mbld')
-rw-r--r--mbld/main.myr4
-rw-r--r--mbld/opts.myr4
-rw-r--r--mbld/subtest.myr9
-rw-r--r--mbld/test.myr10
-rw-r--r--mbld/util.myr2
5 files changed, 21 insertions, 8 deletions
diff --git a/mbld/main.myr b/mbld/main.myr
index d54eb4f..4d74f99 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -37,6 +37,7 @@ const main = {args : byte[:][:]
[.opt='b', .arg="bin", .desc="compile binary 'bin' from inputs"],
[.opt='r', .arg="rt", .desc="link against runtime 'rt'"],
[.opt='o', .arg="dir", .desc="output directory"],
+ [.opt='v', .desc="increase build verbosity"],
][:]
])
@@ -58,6 +59,7 @@ const main = {args : byte[:][:]
| ('o', arg): bld.opt_objdir = arg
| ('b', arg): targname = arg
| ('r', arg): bld.opt_runtime = arg
+ | ('v', _): bld.opt_verbosity++
| _: std.die("unreachable\n")
;;
;;
@@ -72,7 +74,7 @@ const main = {args : byte[:][:]
if targname.len != 0
ok = buildimm(b, targname, cmd.args)
elif runsrc.len != 0
- bld.opt_silent = true
+ bld.opt_verbosity = -1
tmp = std.mktemppath("runmyr")
ok = buildimm(b, tmp, [runsrc][:])
if ok
diff --git a/mbld/opts.myr b/mbld/opts.myr
index 5cdc93a..f111d60 100644
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -20,7 +20,7 @@ pkg bld =
var opt_objdir : byte[:]
var opt_maxproc : std.size
var opt_debug : bool
- var opt_silent : bool
+ var opt_verbosity : int
/* undocumented/unsupported opts */
var opt_mc : byte[:]
@@ -66,7 +66,7 @@ var opt_ldflags = [][:]
var opt_alltags = [][:]
var opt_objdir = "obj"
var opt_genasm = false
-var opt_silent = false
+var opt_verbosity = 0
var opt_maxproc = 1
const initopts = {
diff --git a/mbld/subtest.myr b/mbld/subtest.myr
index e69c7c9..9327fbe 100644
--- a/mbld/subtest.myr
+++ b/mbld/subtest.myr
@@ -4,6 +4,7 @@ use regex
use "types"
use "util"
+use "opts"
pkg bld =
const showsub : (b : build#, cmd : byte[:], \
@@ -27,6 +28,10 @@ const showsub = {b, cmd, fd, logfd, failed
f = auto bio.mkfile(fd, bio.Rd)
log = auto bio.mkfile(logfd, bio.Wr)
+ /* Pretty up the output a bit */
+ if opt_verbosity >= 1
+ bio.write(log, "\n")
+ ;;
res = `std.None
match bio.readln(f)
| `std.Err `bio.Eof:
@@ -36,7 +41,7 @@ const showsub = {b, cmd, fd, logfd, failed
| `std.Ok ln:
match testplan(ln)
| `std.None:
- bio.write(log, ln)
+ bio.put(log, "{}\n", ln)
showraw(fd, logfd)
| `std.Some ntests:
res = `std.Some showtests(b, cmd, failed, \
@@ -115,7 +120,7 @@ const showtests = {b, cmd, failed, f, log, ntests
;;
;;
- bio.put(log, "\t{}\n", ln)
+ bio.put(log, "{}\n", ln)
;;
if !checktests(ntests, nresults)
ok = false
diff --git a/mbld/test.myr b/mbld/test.myr
index bf666fd..a6d703e 100644
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -89,8 +89,13 @@ const runtest = {b, n, targs, isbench, failed
| `std.Err m:
std.fatal("\nunable to run test: {}\n", m)
| `std.Ok (pid, infd, outfd):
- log = std.strcat(std.basename(n.lbl), ".log")
- logfd = std.try(std.openmode(log, std.Owrite | std.Ocreat, 0o644))
+ if opt_verbosity >= 1
+ log = ""
+ logfd = std.try(std.dup(std.Out))
+ else
+ log = std.strcat(std.basename(n.lbl), ".log")
+ logfd = std.try(std.openmode(log, std.Owrite | std.Ocreat, 0o644))
+ ;;
sub = showsub(b, n.lbl, outfd, logfd, failed)
std.slfree(log)
std.close(infd)
@@ -118,6 +123,7 @@ const runtest = {b, n, targs, isbench, failed
if !res
std.slpush(failed, std.fmt("{j= }", n.cmd))
;;
+ std.close(logfd)
;;
-> res
}
diff --git a/mbld/util.myr b/mbld/util.myr
index 46fb462..b008faf 100644
--- a/mbld/util.myr
+++ b/mbld/util.myr
@@ -33,7 +33,7 @@ const run = {cmd, dir
const mbldput = {fmt, args
var ap
- if !opt_silent
+ if opt_verbosity >= 0
ap = std.vastart(&args)
std.putv(fmt, &ap)
;;