tests: remove carriage return when using diff
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 19 Jun 2019 17:27:34 +0000 (13:27 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 27 Jun 2019 04:55:27 +0000 (00:55 -0400)
Carriage return are a problem when running tests on cross execution
platform such as Windows. This only happen when diffing text generated
on Windows and text from a linux file.

The removal of mid-sentence '\r' is not a problem here since we do not
expect bt to generate this kind of string.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I107c5487bf3aa0f5cbd1fdfd1e948ee93f830d2f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1521
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
tests/utils/diff.sh.in

index 57f88e1847832ca400f8da67363d9d6cb6d62647..7a38c7a4297cc98b2adb29db5f3836f876f9f97f 100644 (file)
@@ -32,8 +32,10 @@ bt_diff_cli() {
        temp_output_file="$(mktemp)"
        temp_diff="$(mktemp)"
 
-       # Run the CLI to get a detailed file
-       echo "$args" | xargs "$BT_BIN" 2>/dev/null >"$temp_output_file"
+       # Run the CLI to get a detailed file. Strip any \r present due to
+       # Windows (\n -> \r\n). "diff --string-trailing-cr" is not used since it
+       # is not present on Solaris.
+       echo "$args" | xargs "$BT_BIN" 2>/dev/null | tr -d "\r" > "$temp_output_file"
 
        # Compare output with expected output
        if ! diff "$temp_output_file" "$expected_file" 2>/dev/null >"$temp_diff"; then
This page took 0.027108 seconds and 4 git commands to generate.