ref: e54af86927ced66fb7fa8ad744cfb609390f04d8
parent: 93cff6aba077499c3693896cba43b1ceaaca7a62
author: Ori Bernstein <[email protected]>
date: Fri Aug 24 02:07:30 EDT 2018
Add -v option, make it print test output.
--- a/lib/std/syswrap+plan9.myr
+++ b/lib/std/syswrap+plan9.myr
@@ -46,6 +46,7 @@
const pwrite : (fd : fd, buf : byte[:], off : off -> result(size, errno))
const seek : (fd : fd, delta : off, whence : whence -> result(off, errno))
const pipe : (fds : fd[2]# -> errno)
+ const dup : (ofd : fd -> result(fd, errno))
const dup2 : (ofd : fd, nfd : fd -> result(fd, errno))
const nopipe : (-> void)
@@ -193,6 +194,7 @@
const pwrite = {fd, buf,off; -> check(sys.pwrite((fd : sys.fd), buf, (off : sys.off)))}
const seek = {fd, off, whence; -> check(sys.seek((fd : sys.fd), (off : sys.off), (whence : int64)))}
const pipe = {fds; -> (sys.pipe((fds : sys.fd[2]#)) : errno)}
+const dup = {ofd; -> check((sys.dup(-1, (ofd : sys.fd)) : fd))}
const dup2 = {ofd, nfd; -> check(sys.dup((ofd : sys.fd), (nfd : sys.fd)))}
/* path manipulation */
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -45,6 +45,7 @@
const pwrite : (fd : fd, buf : byte[:], off : off -> result(size, errno))
const pipe : (fds : fd[2]# -> errno)
const seek : (fd : fd, delta : off, whence : whence -> result(off, errno))
+ const dup : (ofd : fd -> result(fd, errno))
const dup2 : (ofd : fd, nfd : fd -> result(fd, errno))
const nopipe : (-> void)
@@ -88,6 +89,7 @@
const pwrite = {fd, buf,off; -> check(sys.pwrite((fd : sys.fd), buf, (off : sys.off)))}
const pipe = {fds; -> (sys.pipe((fds : sys.fd[2]#)) : errno)}
const seek = {fd, delta, whence; -> check(sys.lseek((fd : sys.fd), (delta : sys.off), (whence : sys.whence)))}
+const dup = {ofd; -> check((sys.dup((ofd : sys.fd)) : fd))}
const dup2 = {ofd, nfd; -> check((sys.dup2((ofd : sys.fd), (nfd : sys.fd)) : fd))}
const nopipe = {
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -37,6 +37,7 @@
[.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 @@
| ('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 @@
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
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -20,7 +20,7 @@
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_alltags = [][:]
var opt_objdir = "obj"
var opt_genasm = false
-var opt_silent = false
+var opt_verbosity = 0
var opt_maxproc = 1
const initopts = {
--- a/mbld/subtest.myr
+++ b/mbld/subtest.myr
@@ -4,6 +4,7 @@
use "types"
use "util"
+use "opts"
pkg bld =
const showsub : (b : build#, cmd : byte[:], \
@@ -27,6 +28,10 @@
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 @@
| `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 @@
;;
;;
- bio.put(log, "\t{}\n", ln)
+ bio.put(log, "{}\n", ln)
;;
if !checktests(ntests, nresults)
ok = false
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -89,8 +89,13 @@
| `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 @@
if !res
std.slpush(failed, std.fmt("{j= }", n.cmd))
;;
+ std.close(logfd)
;;
-> res
}
--- a/mbld/util.myr
+++ b/mbld/util.myr
@@ -33,7 +33,7 @@
const mbldput = {fmt, args
var ap
- if !opt_silent
+ if opt_verbosity >= 0
ap = std.vastart(&args)
std.putv(fmt, &ap)
;;