tests: build_by_default : false targets used in tests should be built

The next commit fixes this.
pull/1335/head
Tim-Philipp Müller 8 years ago committed by Nirbheek Chauhan
parent 0e078adf5a
commit b98599ad96
  1. 3
      test cases/common/136 build by default targets in tests/main.c
  2. 23
      test cases/common/136 build by default targets in tests/meson.build
  3. 6
      test cases/common/136 build by default targets in tests/write_file.py

@ -0,0 +1,3 @@
int main (int argc, char *argv[]) {
return 0;
}

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

@ -0,0 +1,6 @@
#!/usr/bin/env python3
import sys
with open(sys.argv[1], 'w') as f:
f.write('Test')
Loading…
Cancel
Save