summaryrefslogtreecommitdiff
path: root/py/waf/test.py
blob: 4070e3c10ef6258aeb232125ed8b21a12cbe0c0b (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
from waflib.Logs import pprint

def test_write_log(ctx):
	file_out = "%s/test.log" % ctx.bldnode.abspath()

	log = lst = getattr(ctx, 'utest_results', [])

	if not log:
		return

	with open(file_out, "w") as fp:
		for binary, retval, lines, error in ctx.utest_results:
			fp.write("BINARY      : %s\n" % binary)
			fp.write("RETURN VALUE: %s\n" % retval)
			fp.write("\n*** stdout ***\n")
			fp.write(lines)
			fp.write("\n*** stderr ***\n")
			fp.write(error)
			fp.write("\n\n\n")

	pprint("BLUE", "Wrote test log to: ", file_out)


def test_print_log(ctx):
	for binary, retval, lines, error in ctx.utest_results:
		pprint("YELLOW", "BINARY      :", binary)
		pprint("YELLOW", "RETURN VALUE:", retval)
		print("")

		if retval or error:
			pprint("RED", "****** ERROR ******\n")

			print(error or lines)

		if (not retval) and (not error):
			pprint("GREEN", "****** LOG ******\n", lines)

		print