]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Add newlines with VIR_TEST_REGENERATE_OUTPUT
authorCole Robinson <crobinso@redhat.com>
Mon, 4 Jan 2016 19:31:58 +0000 (14:31 -0500)
committerCole Robinson <crobinso@redhat.com>
Sat, 9 Jan 2016 02:21:34 +0000 (21:21 -0500)
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.

tests/testutils.c

index 6645d61494fa2cc8348c787a7f6d58bb58e263f3..0091fcd432a761c42aadb98672527d6905b29131 100644 (file)
@@ -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())