cli: handle leftovers in the same loop as components
[babeltrace.git] / tests / cli / test_convert_args
index 475f9052a2c664e22c1975118381ff47f988a74b..74c32252fe30daa7a6d6aa4fe475fc7f522723fd 100755 (executable)
@@ -27,6 +27,7 @@ fi
 source "$UTILSSH"
 
 test_head_comment=0
+tmp_stderr=$(mktemp)
 
 test_bt_convert_run_args() {
        local what="$1"
@@ -54,9 +55,10 @@ test_bt_convert_run_args() {
 test_bt_convert_fails() {
        local what="$1"
        local convert_args="$2"
+       local expected_error_str="${3:-}"
 
        # execute convert command
-       "$BT_TESTS_BT2_BIN" convert --run-args $convert_args >/dev/null 2>&1
+       "$BT_TESTS_BT2_BIN" convert --run-args $convert_args >/dev/null 2>"${tmp_stderr}"
 
        local status=$?
 
@@ -71,6 +73,16 @@ test_bt_convert_fails() {
        else
                pass "FAILS: $what"
        fi
+
+       if [ -n "${expected_error_str}" ]; then
+               grep --quiet "$expected_error_str" "$tmp_stderr"
+               status=$?
+               ok "$status" "FAILS: $what, error message"
+               if [ "$status" -ne 0 ]; then
+                       diag "Expected error string '${expected_error_str}' not found in stderr:"
+                       diag "$(cat ${tmp_stderr})"
+               fi
+       fi
 }
 
 comment() {
@@ -90,7 +102,7 @@ if [ "$BT_OS_TYPE" = "mingw" ]; then
        output_path=$(cygpath -m "$output_path")
 fi
 
-plan_tests 71
+plan_tests 75
 
 test_bt_convert_run_args 'path leftover' "$path_to_trace" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
 test_bt_convert_run_args 'path leftovers' "$path_to_trace $path_to_trace2" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\", \"${path_to_trace2}\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
@@ -164,3 +176,7 @@ test_bt_convert_fails 'no source' '-o text'
 test_bt_convert_fails '-o ctf without --output' 'my-trace -o ctf'
 test_bt_convert_fails '-o ctf + --output with implicit sink.text.pretty' "my-trace -o ctf --output $output_path --no-delta"
 test_bt_convert_fails '--stream-intersection' "$path_to_trace --stream-intersection"
+test_bt_convert_fails '--params after leftover' "--component src.ctf.fs $path_to_trace --params=a=2" 'No current component (--component option) of which to set parameters'
+test_bt_convert_fails '--log-level after leftover' "--component src.ctf.fs $path_to_trace --log-level=W" 'No current component (--component option) to assign a log level to'
+
+rm -f "${tmp_stderr}"
This page took 0.023993 seconds and 4 git commands to generate.