cli: handle leftovers in the same loop as components
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 29 Jul 2019 18:42:23 +0000 (14:42 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 7 Aug 2019 18:05:20 +0000 (14:05 -0400)
commit551b5a52926522c1886c9c1ed25b7d93c5bd22e0
tree6339e9cd12c4f67c7bb891f18b69058a10cd11d9
parent4186b4668a4d251e415dbbaf52879808232377f9
cli: handle leftovers in the same loop as components

[this patch is better viewed with `git show -w`]

Handle leftovers (put them in the leftovers array) at the same time as
we process --component options and things that apply to components
(--params and --log-level).  When we handle a leftover, assign the
current_item_type variable, to override the previous current item.

This change makes it so that we prevent processing --params or
--log-level after a leftover.  Previously, this command line:

    babeltrace2 -c src.bon.jour some-leftover --params=a=2

Would apply the `a=2` param to the `src.bon.jour` instance, since it was
the last component declared.  This is confusing, however, because of the
some-leftover leftover in between.

With this patch, the `some-leftover` leftover becomes the "currently"
processed item when we reach it.  And since it's not possible (for the
moment) to apply --params or --log-level to a leftover, the command line
shown above now result in the error:

    No current component of which to set parameters:
        a=2

I improved test_convert_args to be able to check the error message of a
bt2 run we expect to fail.  This lets us avoid cases where babeltrace
fails for an unexpected reason, but the test still passes.

Change-Id: I0e065c1cd5f32f59292c9a40c6a8077a52d35237
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1806
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/cli/babeltrace2-cfg-cli-args.c
tests/cli/test_convert_args
This page took 0.025495 seconds and 4 git commands to generate.