Skip to content

Expose generate_test_runner.rb as program from meson build file #835

@alexhrao

Description

@alexhrao

Right now, the repository is bundled with a generate_test_runner.rb file in the auto directory. It's what allows us to automatically generate test suite runners for test files, and it works well out of the box. The meson build file even exposes this as a generator:

# Create a generator that can be used by consumers of our build system to generate
# test runners.
gen_test_runner = generator(
  find_program('auto/generate_test_runner.rb'),
  output: '@BASENAME@_Runner.c',
  arguments: ['@INPUT@', '@OUTPUT@']
)

While this is great for simple uses, there are two problems for more "advanced" (if you can call them that) use cases:

  1. generate_test_runner.rb has a lot of great options, like changing the setUp/tearDown names, etc. The generator doesn't expose a way to use these options
  2. The output is fixed to have the _Runner.c ending. Honestly this isn't a big deal, since this name really should be just an implementation detail as part of the build system.

I don't see a clean way to just get args from the parent build file, but I also don't think it's necessary; advanced users will have to know how to invoke this program anyway. Instead, I'd like to expose the runner as an executable; something like

gen_test_runner_exe = find_program('auto/generate_test_runner.rb')

# Create a generator that can be used by consumers of our build system to generate
# test runners.
gen_test_runner = generator(
  gen_test_runner_exe,
  output: '@BASENAME@_Runner.c',
  arguments: ['@INPUT@', '@OUTPUT@']
)

This still allows simple use cases to use the generator directly, while also allowing advanced use cases to invoke the ruby script directly.

I'd love to submit a PR that does this if you all think this is acceptable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions