Skip to content

Request for support to pass extra arguments to the testing program #3132

New issue

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

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

Already on GitHub? # to your account

Closed
KKoovalsky opened this issue Oct 16, 2019 · 3 comments
Closed

Request for support to pass extra arguments to the testing program #3132

KKoovalsky opened this issue Oct 16, 2019 · 3 comments

Comments

@KKoovalsky
Copy link

KKoovalsky commented Oct 16, 2019

Feature Request.

I would like to be able to pass extra arguments to a binary e.g. when running on a native platform.

Possible usage, when running Catch2 tests:

platformio test -e native --program-arg="[testA][testB]"
@nbolton
Copy link

nbolton commented Apr 29, 2022

From #4248:

Within my project, I have many test functions. When one fails, finding out which one is tedious. Unity has command line support (when UNITY_USE_COMMAND_LINE_ARGS is defined) through it's -n or -f arg, but I couldn't see how to pass args to Unity via pio. The test_filter option in the .ini isn't useful in this situation, because it filters on test library, not test function.

Idea: Provide a way of filtering by Unity test function, or maybe have a way of passing args to Unity.

@ivankravets ivankravets changed the title Request for support to pass extra arguments to the target Request for support to pass extra arguments to the testing program May 7, 2022
@ivankravets
Copy link
Member

Resolved in daa3481

The new -a, --program-arg option has been added to the pio test command. Please re-test. See also updated docs.

@robsonos
Copy link

robsonos commented Nov 2, 2023

Hi all

I know this is an old ticked, but I think my comments are relevant here.
I need to parse args from pio test in a non-native environment, and it looks like the solution here provided that. However, in the latest version of PlatromIO , calling --program-arg with pio test does not set PROGRAM_ARGS.
Did you guys create an alternative for that that I am missing or my understanding is correct?

For completeness, the following makes pio test -a work as I expected:

import os
from platformio.public import UnityTestRunner


class CustomTestRunner(UnityTestRunner):
    def setup(self):
        if self.options.program_args:
            os.environ['PROGRAM_ARGS'] = ' '.join(self.options.program_args)


Then I can access that from my extra script:

program_args = os.environ.get('PROGRAM_ARGS', "")

Cheers

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

No branches or pull requests

4 participants