-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
Description
Describe the bug
If a CustomTargetIndex is passed as an argument to a test, running meson test (with no test glob) does not automatically build the custom_target before running the test. This results in "file not found"/"no such file" errors during meson test.
To Reproduce
# meson.build
project('test')
python3 = find_program('python3')
gen_code = '''
import sys, pathlib
pathlib.Path(sys.argv[1]).write_text("foo")
pathlib.Path(sys.argv[2]).write_text("bar")'''
foobar_txt = custom_target(command: [python3, '-c', gen_code, '@OUTPUT@'], output: ['foo.txt', 'bar.txt'])
test_code = '''
import sys, pathlib
sys.exit(0 if pathlib.Path(sys.argv[1]).read_text() == sys.argv[2] else 4)'''
test('foo.txt', python3, args: ['-c', test_code, foobar_txt[0], 'foo'])
test('bar.txt', python3, args: ['-c', test_code, foobar_txt[1], 'bar'])$ meson setup builddir/
$ meson test -C builddir/ --print-errorlogs
ninja: Entering directory `/tmp/x/builddir'
ninja: no work to do.
1/2 foo.txt FAIL 0.03s exit status 1
>>> MESON_TEST_ITERATION=1 ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 MALLOC_PERTURB_=51 MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 /usr/bin/python3 -c '
import sys, pathlib
sys.exit(0 if pathlib.Path(sys.argv[1]).read_text() == sys.argv[2] else 1)' foo.txt foo
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
Traceback (most recent call last):
File "<string>", line 3, in <module>
sys.exit(0 if pathlib.Path(sys.argv[1]).read_text() == sys.argv[2] else 1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/pathlib/_local.py", line 548, in read_text
return PathBase.read_text(self, encoding, errors, newline)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/pathlib/_abc.py", line 632, in read_text
with self.open(mode='r', encoding=encoding, errors=errors, newline=newline) as f:
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/pathlib/_local.py", line 539, in open
return io.open(self, mode, buffering, encoding, errors, newline)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'foo.txt'
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
...
Summary of Failures:
1/2 foo.txt FAIL 0.03s exit status 1
2/2 bar.txt FAIL 0.03s exit status 1
Ok: 0
Fail: 2
$ meson test -C builddir/ --print-errorlogs '*'
ninja: Entering directory `/tmp/x/builddir'
[1/1] Generating foo.txt with a custom command (wrapped by meson because command contains newlines)
1/2 foo.txt OK 0.02s
2/2 bar.txt OK 0.02s
Ok: 2
Fail: 0Expected behavior
meson test should run the custom_target command to create {foo,bar}.txt before running the tests, regardless of whether a test glob was passed or not.
system parameters
- Is this a cross build or just a plain native build (for the same computer)?: Native build
- what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.): Debian Unstable
- what Python version are you using:
3.13.3 - what
meson --version:1.8.99(fea9f69) - what
ninja --versionif it's a Ninja build:1.21.1