tests/cli/test-intersection.sh: rewrite test to avoid shellcheck warning master
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 3 Oct 2024 15:20:21 +0000 (11:20 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 4 Oct 2024 15:48:20 +0000 (11:48 -0400)
Shellcheck 0.10.0 shows:

    $ shellcheck -x test-intersection.sh

    In test-intersection.sh line 36:
     ok $? "$totalevents events in the whole trace"
               ^-- SC2319 (warning): This $? refers to a condition, not a command. Assign to a variable to avoid it being overwritten.

    For more information:
      https://www.shellcheck.net/wiki/SC2319 -- This $? refers to a condition, no...

I think that Shellcheck is confused with what we're trying to do and
that the code is actually correct. Nevertheless, change the code to
circumvent this by using `is`, which looks nicer anyway.

This is not seen on the CI, since it currently runs Shellcheck 0.9.0.

Change-Id: I7bb861b478046ab327c5950c9deefa52953bc854
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/13316
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
tests/cli/test-intersection.sh

index ff1193dcfc6f86a25572e60e79af4ebc8dffeeab..13e3b71a23c5466b124d9f4c15e34341b8bbec21 100755 (executable)
@@ -32,15 +32,13 @@ test_intersect() {
        ok $? "run without --stream-intersection"
 
        cnt=$(wc -l < "${stdout}")
-       test "${cnt// /}" = "$totalevents"
-       ok $? "$totalevents events in the whole trace"
+       is "${cnt// /}" "$totalevents" "$totalevents events in the whole trace"
 
        bt_cli "${stdout}" "/dev/null" --stream-intersection "${trace}"
        ok $? "run with --stream-intersection"
 
        cnt=$(wc -l < "${stdout}")
-       test "${cnt// /}" = "$intersect"
-       ok $? "$intersect events in streams intersecting"
+       is "${cnt// /}" "$intersect" "$intersect events in streams intersecting"
 }
 
 test_intersect_fails() {
This page took 0.02547 seconds and 4 git commands to generate.