From 825d357a467d4ca2e80d6d49e0fdd33afee07605 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mon, 4 Jan 2016 14:31:58 -0500 Subject: [PATCH] tests: Add newlines with VIR_TEST_REGENERATE_OUTPUT 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 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 6645d61494..0091fcd432 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 (expectName && actual && - virFileWriteStr(expectName, actual, 0666) < 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, regencontent, 0666) < 0) { + VIR_FREE(regencontent); + return -1; + } + VIR_FREE(regencontent); } if (!virTestGetDebug())