From 587bafc771f49e8af545e2e08632a59fd9a1db9d Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 23 Nov 2022 14:57:12 +0100 Subject: [PATCH] Utils: Make errors from CommandLine test better readable Change-Id: Ibea4bbe7c1f7e502849f0ef6985cbf107fc236f0 Reviewed-by: Marcus Tillmanns Reviewed-by: hjk --- .../utils/commandline/tst_commandline.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/auto/utils/commandline/tst_commandline.cpp b/tests/auto/utils/commandline/tst_commandline.cpp index 6fd65546cb2..100e3fcbb25 100644 --- a/tests/auto/utils/commandline/tst_commandline.cpp +++ b/tests/auto/utils/commandline/tst_commandline.cpp @@ -23,7 +23,10 @@ private slots: cmd.addCommandLineWithAnd(cmd2); - QCOMPARE(cmd.toUserOutput(), QString("echo foo && echo bar blizz")); + const QString actual = cmd.toUserOutput(); + const QString wanted = "echo foo && echo bar blizz"; + + QCOMPARE(actual, wanted); } void testAndComplex() @@ -33,9 +36,12 @@ private slots: cmd.addCommandLineWithAnd(cmd2); - QCOMPARE(cmd.toUserOutput(), - QString("/tmp/space path/\"echo foo 'long with space' && '/tmp/space \"path/echo' " - "'bar\"' 'blizz is '\\''great'")); + const QString actual = cmd.toUserOutput(); + const QString wanted = + "/tmp/space path/\"echo foo 'long with space' && '/tmp/space \"path/echo' " + "'bar\"' 'blizz is '\\''great'"; + + QCOMPARE(actual, wanted); } void testAndAdd() @@ -47,10 +53,13 @@ private slots: CommandLine shell("bash", {"-c"}); shell.addCommandLineAsSingleArg(cmd); - QCOMPARE(shell.toUserOutput(), + const QString actual = shell.toUserOutput(); + const QString wanted = "bash -c ''\\''/tmp/space path/\"echo'\\'' foo '\\''long with space'\\'' && " "'\\''/tmp/space \"path/echo'\\'' '\\''bar\"'\\'' '\\''blizz is " - "'\\''\\'\\'''\\''great'\\'''"); + "'\\''\\'\\'''\\''great'\\'''"; + + QCOMPARE(actual, wanted); } };