ref: d92ff16a7e9ba2919746620fac40c798b06955ce
parent: 666970ff83272349c1713169bf7cb49964366fb1
author: Ori Bernstein <[email protected]>
date: Sun Oct 28 08:54:47 EDT 2018
Respect outdir and use it for tests. This makes our gitignore nicer.
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@
# outputs
obj/**
+test/obj/**
6/6m
muse/muse
mbld/mbld
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -72,11 +72,11 @@
b = mkbuild(tags)
if targname.len != 0
- ok = buildimm(b, targname, cmd.args)
+ ok = buildimm(b, targname, cmd.args, bld.opt_objdir)
elif runsrc.len != 0
bld.opt_verbosity = -1
tmp = std.mktemppath("runmyr")
- ok = buildimm(b, tmp, [runsrc][:])
+ ok = buildimm(b, tmp, [runsrc][:], bld.opt_objdir)
if ok
pid = runcmd(tmp, cmd.args)
match std.wait(pid)
@@ -115,7 +115,7 @@
;;
}
-const buildimm = {b, targ, inputs
+const buildimm = {b, targ, inputs, objdir
var mt : bld.myrtarg
mt = [
@@ -125,7 +125,7 @@
.incpath=bld.opt_incpaths,
.libdeps=[][:]
]
- bld.opt_objdir = ""
+ bld.opt_objdir = objdir
std.slpush(&b.all, "__out__")
std.htput(b.targs, "__out__", `bld.Bin &mt)
bld.deps(b)
--- a/test/runtest.rc
+++ b/test/runtest.rc
@@ -5,7 +5,7 @@
MYR_MUSE=../muse/6.out
fn build {
rm -f $1 $1^.6 $1^.use
- ../obj/mbld/mbld -Bnone -o '' -b $1 -I../obj/lib/std -I../obj/lib/sys -I../obj/lib/regex -r../rt/_myrrt.6 $1^.myr
+ ../obj/mbld/mbld -Bnone -o 'out' -b $1 -I../obj/lib/std -I../obj/lib/sys -I../obj/lib/regex -r../rt/_myrrt.6 $1^.myr
}
fn pass {
@@ -20,7 +20,7 @@
st='*'^$2
if(~ $2 0)
st=''''''
- ./$1 $3
+ ./out/$1 $3
if(eval '~ $status '$st)
pass $1
if not
@@ -30,7 +30,7 @@
fn expectprint {
ifs='
'
- if(~ `{./$1 $3} $2)
+ if(~ `{./out/$1 $3} $2)
pass $1
if not
fail $1
@@ -39,7 +39,7 @@
fn expectcmp {
t=/tmp/myrtest-^$1
rm -f $t
- ./$1 $3 > $t
+ ./out/$1 $3 > $t
if (cmp $t data/$1-expected)
pass $1
if not
@@ -49,7 +49,7 @@
fn expectfcmp {
t=/tmp/myrtest-^$1
rm -f $t
- ./$1 $3
+ ./out/$1 $3
if (cmp $2 data/$1-expected)
pass $1
if not
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-#set -x
export PATH=.:$PATH
export MYR_MC=../6/6m
export MYR_MUSE=../muse/muse
@@ -8,8 +7,9 @@
NPASSES=0
build() {
- rm -f $1 $1.o $1.s $1.use
- ../obj/mbld/mbld -Bnone -o '' -b $1 -I../obj/lib/std -I../obj/lib/sys -I../obj/lib/regex -r../rt/_myrrt.o $1.myr
+ rm -f out/$1 out/$1.o out/$1.s out/$1.use
+ mkdir -p out
+ ../obj/mbld/mbld -Bnone -o 'out' -b $1 -I../obj/lib/std -I../obj/lib/sys -I../obj/lib/regex -r../rt/_myrrt.o $1.myr
}
pass() {
@@ -25,7 +25,7 @@
}
expectstatus() {
- ./$1 $3
+ ./out/$1 $3
if [ $? -eq $2 ]; then
pass $1
return
@@ -35,7 +35,7 @@
}
expectprint() {
- if [ "`./$1 $3`" != "$2" ]; then
+ if [ "`./out/$1 $3`" != "$2" ]; then
fail $1
else
pass $1
@@ -48,7 +48,7 @@
else
t=/tmp/myrtest-$1-$RANDOM
fi
- ./$1 $3 > $t
+ ./out/$1 $3 > $t
if cmp $t data/$1-expected; then
pass $1
else
@@ -58,7 +58,7 @@
}
expectfcompare() {
- ./$1 $3
+ ./out/$1 $3
if cmp data/$1-expected $2; then
pass $1
else