inline-c-rs icon indicating copy to clipboard operation
inline-c-rs copied to clipboard

Add a mean to pass arguments to the embedded Command

Open lu-zero opened this issue 2 years ago • 2 comments

This would make much simpler to pass arguments to tests.

lu-zero avatar Aug 24 '22 08:08 lu-zero

Thanks for the feature proposal.

The C code is a total blackbox from the Rust point of view.

I see 2 solutions to not violate this blackbox feature:

  1. Use environment variables to pass values from Rust to C,
  2. Pass values onto C's main function.

Whatever we go for, the values are going to be pretty simple, like integers, floats, strings, maybe booleans (but those don't exist in C), but probably not more, or not without difficulties and for sure unvoluntary edge cases.

Can you share to me your usecase please?

Hywan avatar Aug 31 '22 06:08 Hywan

I'm porting to inline-c some tests that had been written using meson, passing arguments using https://doc.rust-lang.org/std/process/struct.Command.html#method.args and having access to https://doc.rust-lang.org/std/process/struct.Command.html#method.envs and friends would make it easier.

Pushing it further would be even better to have the run() machinery exposed, then I could keep the C code available for the users and just include!() it so it would be fed to the test runner.

lu-zero avatar Aug 31 '22 07:08 lu-zero