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)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 2 Aug 2019 15:46:54 +0000 (11:46 -0400)
commit8b4cd08a4cc2e13235c20689d74790ed3ccc6a51
treee529a4b88cefec0fce514c8a900025c6ff6bacc8
parent505d91781221dcff6f5bd9a0cd0c4fd73797d1a1
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.024506 seconds and 4 git commands to generate.