mirror of https://gitlab.com/ita1024/waf.git
Exit status must be non-zero when tests fail
This commit is contained in:
parent
2d89937205
commit
589a99fca3
|
@ -23,6 +23,17 @@ def trimquotes(s):
|
|||
return s
|
||||
|
||||
def build(bld):
|
||||
|
||||
bld.failure = 0
|
||||
def disp(color, result):
|
||||
pprint(color, result)
|
||||
if color == 'RED':
|
||||
bld.failure=1
|
||||
def stop_status(bld):
|
||||
if bld.failure:
|
||||
bld.fatal('One or several test failed, check the outputs above')
|
||||
bld.add_post_fun(stop_status)
|
||||
|
||||
defs = {
|
||||
'm1' : "m1 9 + 9",
|
||||
'fun0' : "fun0(x, y) x y",
|
||||
|
@ -44,7 +55,7 @@ def build(bld):
|
|||
color = "GREEN"
|
||||
else:
|
||||
color = "RED"
|
||||
pprint(color, "%s\t\t%r" % (ret, toks))
|
||||
disp(color, "%s\t\t%r" % (ret, toks))
|
||||
|
||||
test("1 + m1 + 1", "1+9+9+1")
|
||||
test("1 + fun0(1, +) 1", "1+1+1")
|
||||
|
@ -65,7 +76,7 @@ def build(bld):
|
|||
color = "GREEN"
|
||||
else:
|
||||
color = "RED"
|
||||
pprint(color, "%s" % str(ret))
|
||||
disp(color, "%s" % str(ret))
|
||||
|
||||
test("fun6(math, h)", ("<", "math.h"))
|
||||
|
||||
|
@ -77,7 +88,7 @@ def build(bld):
|
|||
color = "GREEN"
|
||||
else:
|
||||
color = "RED"
|
||||
pprint(color, "%s\t\t%r" % (ret, toks))
|
||||
disp(color, "%s\t\t%r" % (ret, toks))
|
||||
|
||||
test("1+1", 2)
|
||||
test("1-1", 0)
|
||||
|
@ -113,8 +124,7 @@ def build(bld):
|
|||
|
||||
def add_defs(a, b, c, expected):
|
||||
main = bld.path.find_resource('src/main.c')
|
||||
defs = ['A=%d' % a, 'B=%d' % b, 'C=%d' % c]
|
||||
bld.env['DEFINES'] = ["%s %s" %(x[0], trimquotes('='.join(x[1:]))) for x in [y.split('=') for y in defs]]
|
||||
bld.env.DEFINES = ['A=%s' % str(a), 'B=%s' % str(b), 'C=%s' % str(c)]
|
||||
gruik = c_preproc.c_parser([main.parent])
|
||||
gruik.start(main, bld.env)
|
||||
|
||||
|
@ -122,7 +132,7 @@ def build(bld):
|
|||
color = "GREEN"
|
||||
else:
|
||||
color = "RED"
|
||||
pprint(color, "%r %r %r -> header %s (got %r)" % (a, b, c, expected, gruik.nodes))
|
||||
disp(color, "%r %r %r -> header %s (got %r)" % (a, b, c, expected, gruik.nodes))
|
||||
|
||||
add_defs(1, 1, 1, 'a.h')
|
||||
add_defs(1, 1, 0, 'b.h')
|
||||
|
@ -145,15 +155,14 @@ def build(bld):
|
|||
|
||||
def test_pasting():
|
||||
main = bld.path.find_resource('src/pasting.c')
|
||||
defs = ['PREFIX_VAL=', 'SUFFIX_VAL=']
|
||||
bld.env['DEFINES'] = ["%s %s" %(x[0], trimquotes('='.join(x[1:]))) for x in [y.split('=') for y in defs]]
|
||||
bld.env.DEFINES = ['PREFIX_VAL=', 'SUFFIX_VAL=']
|
||||
gruik = c_preproc.c_parser([main.parent])
|
||||
gruik.start(main, bld.env)
|
||||
if len(gruik.nodes) == 1 and gruik.nodes[0].name == 'a.h':
|
||||
color = "GREEN"
|
||||
else:
|
||||
color = "RED"
|
||||
pprint(color, "token pasting -> %r (expected a.h)" % gruik.nodes)
|
||||
disp(color, "token pasting -> %r (expected a.h)" % gruik.nodes)
|
||||
|
||||
test_pasting()
|
||||
|
||||
|
@ -165,7 +174,7 @@ def build(bld):
|
|||
color = "GREEN"
|
||||
else:
|
||||
color = "RED"
|
||||
pprint(color, "%s\t\t%r" % (ret, toks))
|
||||
disp(color, "%s\t\t%r" % (ret, toks))
|
||||
|
||||
test('a||b||c||d', 1)
|
||||
test('a&&b&&c&&d', 0)
|
||||
|
@ -181,14 +190,13 @@ def build(bld):
|
|||
color = "GREEN"
|
||||
else:
|
||||
color = "RED"
|
||||
pprint(color, "%s\t\t%r" % (expected, gruik.nodes))
|
||||
disp(color, "%s\t\t%r" % (expected, gruik.nodes))
|
||||
|
||||
test_rec("", "a")
|
||||
test_rec("FOO=1", "aca")
|
||||
test_rec("BAR=1", "abca")
|
||||
test_rec("FOO=1 BAR=1", "aca")
|
||||
|
||||
|
||||
return
|
||||
test("1?1,(0?5:9):3,4", 0) # <- invalid expression
|
||||
|
||||
|
|
Loading…
Reference in New Issue