forked from platformio/platformio-core
Pass extra arguments to the testing program with a new "pio test --program-arg" option // Resolve # 3132
This commit is contained in:
1 parent
2d94000dd5
commit
daa3481862
6 files changed
+50
-15
No files matched your search
@@ -28,19 +28,19 @@ from platformio.test.runners.factory import TestRunnerFactory
|
||||
|
||||
|
||||
@click.command("test", short_help="Unit Testing")
|
||||
@click.option("--environment", "-e", multiple=True, metavar="<environment>")
|
||||
@click.option("--environment", "-e", multiple=True)
|
||||
@click.option(
|
||||
"--filter",
|
||||
"-f",
|
||||
multiple=True,
|
||||
metavar="<pattern>",
|
||||
metavar="PATTERN",
|
||||
help="Filter tests by a pattern",
|
||||
)
|
||||
@click.option(
|
||||
"--ignore",
|
||||
"-i",
|
||||
multiple=True,
|
||||
metavar="<pattern>",
|
||||
metavar="PATTERN",
|
||||
help="Ignore tests by a pattern",
|
||||
)
|
||||
@click.option("--upload-port")
|
||||
@@ -76,6 +76,13 @@ from platformio.test.runners.factory import TestRunnerFactory
|
||||
type=click.IntRange(0, 1),
|
||||
help="Set initial DTR line state for Serial Monitor",
|
||||
)
|
||||
@click.option(
|
||||
"-a",
|
||||
"--program-arg",
|
||||
"program_args",
|
||||
multiple=True,
|
||||
help="A program argument (multiple are allowed)",
|
||||
)
|
||||
@click.option("--output-format", type=click.Choice(["json", "junit"]))
|
||||
@click.option(
|
||||
"--output-path",
|
||||
@@ -99,6 +106,7 @@ def test_cmd( # pylint: disable=too-many-arguments,too-many-locals,redefined-bu
|
||||
no_reset,
|
||||
monitor_rts,
|
||||
monitor_dtr,
|
||||
program_args,
|
||||
output_format,
|
||||
output_path,
|
||||
verbose,
|
||||
@@ -116,7 +124,7 @@ def test_cmd( # pylint: disable=too-many-arguments,too-many-locals,redefined-bu
|
||||
if verbose:
|
||||
click.echo(" (%s)" % ", ".join(test_names))
|
||||
|
||||
test_result = TestResult(os.path.basename(project_dir))
|
||||
test_result = TestResult(project_dir)
|
||||
default_envs = config.default_envs()
|
||||
for env_name in config.envs():
|
||||
for test_name in test_names:
|
||||
@@ -159,6 +167,7 @@ def test_cmd( # pylint: disable=too-many-arguments,too-many-locals,redefined-bu
|
||||
no_reset=no_reset,
|
||||
monitor_rts=monitor_rts,
|
||||
monitor_dtr=monitor_dtr,
|
||||
program_args=program_args,
|
||||
),
|
||||
)
|
||||
click.echo()
|
||||
|
||||
@@ -38,6 +38,7 @@ class TestRunnerOptions: # pylint: disable=too-many-instance-attributes
|
||||
no_reset=False,
|
||||
monitor_rts=None,
|
||||
monitor_dtr=None,
|
||||
program_args=None,
|
||||
):
|
||||
self.verbose = verbose
|
||||
self.without_building = without_building
|
||||
@@ -49,6 +50,7 @@ class TestRunnerOptions: # pylint: disable=too-many-instance-attributes
|
||||
self.no_reset = no_reset
|
||||
self.monitor_rts = monitor_rts
|
||||
self.monitor_dtr = monitor_dtr
|
||||
self.program_args = program_args
|
||||
|
||||
|
||||
class TestRunnerBase:
|
||||
|
||||
@@ -62,9 +62,10 @@ class ProgramTestOutputReader:
|
||||
if custom_testing_command:
|
||||
return custom_testing_command
|
||||
build_dir = self.test_runner.project_config.get("platformio", "build_dir")
|
||||
return [
|
||||
os.path.join(build_dir, self.test_runner.test_suite.env_name, "program")
|
||||
]
|
||||
cmd = [os.path.join(build_dir, self.test_runner.test_suite.env_name, "program")]
|
||||
if self.test_runner.options.program_args:
|
||||
cmd.extend(self.test_runner.options.program_args)
|
||||
return cmd
|
||||
|
||||
async def gather_results(self):
|
||||
exit_future = asyncio.Future(loop=self.aio_loop)
|
||||
|
||||
Reference in new issue
Block a user