Skip to content

How to use an executable made by a custom_target() as command for test() ? #6567

Closed

Description

@lambda-code

with meson 0.53.1
I've a custom_target() that generate an executable.
I want to give it as the command to execute for the test() command.
How can I do that (if possible)?

Activity

  1. xclaesse commented on Feb 1, 2020

    @xclaesse
    Member

    I think the short answer is it's not supported. That being said, judging by the code I think something like that could work around it:

    target = custom_target()
    exe = files([target.full_path()])[0]
    test('mytest', exe)
  2. lambda-code commented on Feb 2, 2020

    @lambda-code
    Author

    @xclaesse yes this trick works fine. It fun to see that the string returned by full_path() doesn't work directly with test(), but with files() yes.
    thanks!

    I wonder if it could be an improvement to let test() works with full_path() directly.

  3. xclaesse commented on Feb 3, 2020

    @xclaesse
    Member

    Yes I think it should accept target[0] at least. Would be a nice contribution if you can make a pr ;)

  4. eli-schwartz commented on Aug 31, 2021

    @eli-schwartz
    Member

    It doesn't seem to work at all for me, File @target@ does not exist.

    find_program() doesn't work either...

    This seems to be still relevant

  5. amcn commented on Mar 23, 2023

    @amcn
    Contributor

    I recently tried to do this assuming that it would work, and after a few searches ended up here. Is there a wide desire for this?

    I looked into seeing what it would take to implement this and to my surprise it's a simple two line change to get the most basic example working (adding build.CustomTarget into the accepted types for Interpretor.func_test and Interpretor.make_test) but that's probably not a good idea as not all custom targets will be executable.

    If the output of custom_target is something that can be executed as a test, then it should probably be an build.Executable, right? Would it make sense to add a new boolean kwarg to custom_target that users can set to true if the output is intended to be executable and which defaults to false?

  6. added 4 commits that reference this issue on Feb 23, 2024
    c8ce885
    f137891
    c7b219c
    9f73d01
  7. added a commit that references this issue on Feb 24, 2024
    11f2e07
  8. added a commit that references this issue on Jun 4, 2024
    baa1d37
  9. added a commit that references this issue on May 1, 2025
    f51cba2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions