| 1 |
project('unit-test', 'c', version : '1.0') |
| 2 |
|
| 3 |
write_file = find_program('write_file.py') |
| 4 |
|
| 5 |
# A test that consumes and verifies the output generated by a custom target. |
| 6 |
# Should work even if target is not built by default. Makes sure that foo.out |
| 7 |
# is actually created before the test command that uses foo_out is run. |
| 8 |
foo_out = custom_target('foo.out', |
| 9 |
output : 'foo.out', |
| 10 |
command : [write_file, '@OUTPUT@']) |
| 11 |
|
| 12 |
# Also verify that a build_by_default : false BuildTarget added to a test is |
| 13 |
# built before the test is run. |
| 14 |
exe_out = executable('out', 'main.c', build_by_default : false) |
| 15 |
|
| 16 |
py_file_exists = '''import os, sys |
| 17 |
if not os.path.exists(sys.argv[1]) or not os.path.exists(sys.argv[2]): |
| 18 |
print("could not find {!r} or {!r} in {!r}" |
| 19 |
"".format(sys.argv[1], sys.argv[2], os.getcwd())) |
| 20 |
sys.exit(1)''' |
| 21 |
|
| 22 |
python = import('python3').find_python() |
| 23 |
test('output-check', python, args : ['-c', py_file_exists, foo_out, exe_out]) |