Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object returned by executable() does not expand to full path when used as argument in test() #2681

Closed
keszybz opened this issue Nov 24, 2017 · 4 comments

Comments

@keszybz
Copy link
Contributor

keszybz commented Nov 24, 2017

http://mesonbuild.com/Reference-manual.html#build-target-object says

full_path() returns a full path pointing to the result target file. NOTE: In most cases using the object itself will do the same job as this and will also allow Meson to setup inter-target dependencies correctly. Please file a bug if that doesn't work for you.

... so I'm filling this.

        exe = executable('systemd-tmpfiles',
                         'src/tmpfiles/tmpfiles.c',
                         include_directories : includes,
                         link_with : [libshared],
                         dependencies : [libacl],
                         install_rpath : rootlibexecdir,
                         install : true,
                         install_dir : rootbindir)
        public_programs += [exe]

        test('test-systemd-tmpfiles',
             test_systemd_tmpfiles_py,
             args : exe)

this expands to

--- command ---
/home/zbyszek/src/systemd-work/src/test/test-systemd-tmpfiles.py systemd-tmpfiles

i.e. it runs the system-installed binary instead of the one I want to test.

Using exe.full_path() works fine, but it will break dependency calculation when #1704 is resolved.

@jpakkane
Copy link
Member

The reason this happens is that we pass a relative path to the target. So if they are in a different directory then it expands to foo/bar.exe and correspondingly to bar.exe if they are in the same dir. Due to path expansion (and the fact that most people don't have . in their path) the latter will resolve to the system binary.

We try to avoid absolute paths when possible, since they have the tendency to break reproducible builds because paths get captured in the weirdest of ways. Maybe we should detect this case and then do ./bar.exe.

@nirbheek nirbheek added the bug label Nov 29, 2017
@nirbheek
Copy link
Member

In this case exe is passed as an argument to the test and the absolute path would only be embedded in the meson test serialization data, so we should do it automatically. In fact, this was supposed to be fixed already, see: #1094

@keszybz
Copy link
Contributor Author

keszybz commented Mar 28, 2020

FWIW, I still see the same behaviour (just the name, not an absolute path and not ./foo) with meson-0.53.2-1.git88e40c7.fc32.noarch.

mikecrowe added a commit to mikecrowe/mp3chop that referenced this issue Apr 5, 2020
mp3chop is so old that it didn't have very good tests. In the absence of
exhaustive tests, let's add a few approval tests. The expected output
files were generated using an older version of mp3chop and can be used
to show that the behaviour hasn't changed.

When we pass the mp3chop executable to our test script it is not passed
as a full path (see mesonbuild/meson#2681 )
and the current directory won't be in our path so we need to take
special action to ensure that we can run it.
@eli-schwartz
Copy link
Member

This was re-reported in #5984 and fixed in commit cb6662b (meson 0.55.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants