ref: e70e83ae4362b60e9eb2134fb5d388576ee90bdf
parent: d92ff16a7e9ba2919746620fac40c798b06955ce
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Oct 28 09:16:56 EDT 2018
Emit test logs into the obj/ directory.
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -15,13 +15,8 @@
const main = {args : byte[:][:]
var b : bld.build#
- var targname
- var runsrc
- var path
- var tmp
- var cmd
- var tags
- var pid
+ var runsrc, objdir, path, tmp, cmd
+ var targname, tags, pid
var ok, r
cmd = std.optparse(args, &[
@@ -56,7 +51,7 @@
| ('T', tag): std.slpush(&bld.opt_alltags, tag)
| ('j', arg): bld.opt_maxproc = std.getv(std.intparse(arg), 1)
| ('R', arg): runsrc = arg
- | ('o', arg): bld.opt_objdir = arg
+ | ('o', arg): objdir = arg
| ('b', arg): targname = arg
| ('r', arg): bld.opt_runtime = arg
| ('v', _): bld.opt_verbosity++
@@ -72,11 +67,13 @@
b = mkbuild(tags)
if targname.len != 0
- ok = buildimm(b, targname, cmd.args, bld.opt_objdir)
+ bld.opt_objdir = objdir
+ ok = buildimm(b, targname, cmd.args)
elif runsrc.len != 0
+ bld.opt_objdir = objdir
bld.opt_verbosity = -1
tmp = std.mktemppath("runmyr")
- ok = buildimm(b, tmp, [runsrc][:], bld.opt_objdir)
+ ok = buildimm(b, tmp, [runsrc][:])
if ok
pid = runcmd(tmp, cmd.args)
match std.wait(pid)
@@ -86,6 +83,9 @@
;;
std.remove(tmp)
else
+ if objdir.len > 0
+ bld.opt_objdir = objdir
+ ;;
findproj(b)
bld.load(b)
bld.deps(b)
@@ -115,7 +115,7 @@
;;
}
-const buildimm = {b, targ, inputs, objdir
+const buildimm = {b, targ, inputs
var mt : bld.myrtarg
mt = [
@@ -125,7 +125,6 @@
.incpath=bld.opt_incpaths,
.libdeps=[][:]
]
- bld.opt_objdir = objdir
std.slpush(&b.all, "__out__")
std.htput(b.targs, "__out__", `bld.Bin &mt)
bld.deps(b)
@@ -198,6 +197,7 @@
while dir.len > 0 && !std.eq(dir, "/")
if std.chdir(dir) && std.fexists("bld.proj")
b.basedir = dir
+ b.rootdir = dir
break
;;
dir = std.dirname(dir)
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -22,7 +22,7 @@
}
const go = {b, targs, kind, isbench
- var failed, ok
+ var logdir, failed, ok
var tests
if !buildtarg(b, kind)
@@ -32,9 +32,12 @@
ok = true
failed = [][:]
for t : tests
- if !runtest(b, t, targs, isbench, &failed)
+ logdir = std.fmt("{}/{}/{}", b.basedir, opt_objdir, t.wdir)
+ std.mkpath(logdir)
+ if !runtest(b, t, targs, logdir, isbench, &failed)
ok = false
;;
+ std.slfree(logdir)
;;
std.chdir(b.basedir)
@@ -61,7 +64,7 @@
;;
}
-const runtest = {b, n, targs, isbench, failed
+const runtest = {b, n, targs, logdir, isbench, failed
var dir, res, log, logfd
var sub, found
@@ -93,7 +96,7 @@
log = ""
logfd = std.try(std.dup(std.Out))
else
- log = std.strcat(std.basename(n.lbl), ".log")
+ log = std.fmt("{}/{}.log", logdir, std.basename(n.lbl))
logfd = std.try(std.openmode(log, std.Owrite | std.Ocreat, 0o644))
;;
sub = showsub(b, n.lbl, outfd, logfd, failed)
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -3,6 +3,7 @@
pkg bld =
type build = struct
/* build state */
+ rootdir : byte[:]
basedir : byte[:]
tags : std.htab(byte[:], (int, int, int))#
libs : std.htab(byte[:], libdep#)#