diff mbox

[v2] tests: Add newlines with VIR_TEST_REGENERATE_OUTPUT

Message ID 0a48e8e1defd3a69140be2e1df815142c515e37c.1452282562.git.crobinso@redhat.com
State Superseded
Headers show

Commit Message

Cole Robinson Jan. 8, 2016, 7:49 p.m. UTC
Since test files are formatted predictably nowadays, we can make
VIR_TEST_REGENERATE_OUTPUT handle most cases for us with a simple
replacement. test-wrap-argv.pl is still canon, but this bit makes
it easier to confirm test output changes during active development.
---
v2: Rebase on .git master

 tests/testutils.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

-- 
2.5.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

diff --git a/tests/testutils.c b/tests/testutils.c
index 6645d61..0091fcd 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -469,10 +469,19 @@  virtTestDifferenceFullInternal(FILE *stream,
     actualStart = actual;
     actualEnd = actual + (strlen(actual)-1);
 
-    if (regenerate && virTestGetRegenerate() > 0) {
+    if (regenerate && (virTestGetRegenerate() > 0) && expectName && actual) {
+        char *regencontent;
+
+        /* Try to properly indent qemu argv files */
+        if (!(regencontent = virStringReplace(actual, " -", " \\\n-")))
+            return -1;
+
         if (expectName && actual &&
-            virFileWriteStr(expectName, actual, 0666) < 0)
+            virFileWriteStr(expectName, regencontent, 0666) < 0) {
+            VIR_FREE(regencontent);
             return -1;
+        }
+        VIR_FREE(regencontent);
     }
 
     if (!virTestGetDebug())