summaryrefslogtreecommitdiff
path: root/test/runtest.rc
blob: e6aaf5a65ad3ec1490e28eb9b25796973c3a38a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/rc

rfork e
MYR_MC=`{cd .. ; pwd}^/6/6.out
MYR_MUSE=`{cd .. ; pwd}^/muse/6.out
fn build {
	dir=`{echo $1 | grep '.*/'}
	if(~ $dir '') {
		rm -f $1 $1^.6 $1^.use
		../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
	}
	if not {
		target=`{echo $1 | grep -o '[^/]*$'}
		top=`{pwd}
		mkdir -p out/$dir
		cd $dir
		$top/../obj/mbld/mbld -Bnone -o $top/out/$dir -I$top/../obj/lib/std -I$top/../obj/lib/sys -I$top/../obj/lib/regex -r$top/../rt/_myrrt.o clean
		$top/../obj/mbld/mbld -Bnone -o $top/out/$dir -I$top/../obj/lib/std -I$top/../obj/lib/sys -I$top/../obj/lib/regex -r$top/../rt/_myrrt.o :$target
	}
}

fn pass {
	echo '!}>> ok'
}

fn fail {
	echo '!}>> fail '
}

fn expectstatus {
	st='*'^$2
	if(~ $2 0)
		st=''''''
	./out/$1 $3
	if(eval '~ $status '$st)
		pass $1
	if not
		fail $1
}

fn expectprint {
	ifs='
'
	if(~ `{./out/$1 $3} $2)
		pass $1
	if not
		fail $1
}

fn expectcmp {
	t=/tmp/myrtest-^$1
	rm -f $t
	./out/$1 $3 > $t
	if (cmp $t data/$1-expected)
		pass $1
	if not
		fail $1
}

fn expectfcmp {
	t=/tmp/myrtest-^$1
	rm -f $t
	./out/$1 $3
	if (cmp $2 data/$1-expected)
		pass $1
	if not
		fail $1
}

fn B {
	test=$1; shift
	type=$1; shift
	res=$1; shift

	echo 'test' $test '<<{!'
	here=`{pwd}
	build $test
	cd $here
	switch($type) {
	case E
		expectstatus $test $res
	case P
		expectprint $test $res
	case C
		expectcmp $test $res
	case F
		expectfcmp $test $res
	}
}

fn F {
	echo 'test ' ^ $1 '<<{!'
	here=`{pwd}
	@{ build $1 } >[2=1]
	if (~ $status '')
		fail $1
	if not
		pass $1
	cd $here
}

echo 'MTEST ' `{grep '^[BF]' tests | wc -l}

. tests