Testsuite: do not write empty files on 'make accept'
authorThomas Miedema <thomasmiedema@gmail.com>
Tue, 23 Feb 2016 20:29:59 +0000 (21:29 +0100)
committerThomas Miedema <thomasmiedema@gmail.com>
Thu, 25 Feb 2016 22:26:06 +0000 (23:26 +0100)
Also prevent showing '\ No newline at end of file' in diff output.

testsuite/driver/testlib.py
testsuite/tests/typecheck/should_compile/tc162.stderr [deleted file]

index 1ebe6a7..2a9f141 100644 (file)
@@ -1647,10 +1647,14 @@ def compare_outputs(way, kind, normaliser, expected_file, actual_file,
                               way in getTestOpts().expect_fail_for):
             if_verbose(1, 'Test is expected to fail. Not accepting new output.')
             return 0
-        elif config.accept:
+        elif config.accept and actual_raw:
             if_verbose(1, 'Accepting new output.')
             write_file(expected_path, actual_raw)
             return 1
+        elif config.accept:
+            if_verbose(1, 'No output. Deleting {0}.'.format(expected_path))
+            rm_no_fail(expected_path)
+            return 1
         else:
             return 0
 
@@ -2306,4 +2310,8 @@ def printFailingTestInfosSummary(file, testInfos):
     file.write('\n')
 
 def modify_lines(s, f):
-    return '\n'.join([f(l) for l in s.splitlines()])
+    s = '\n'.join([f(l) for l in s.splitlines()])
+    if s and s[-1] != '\n':
+        # Prevent '\ No newline at end of file' warnings when diffing.
+        s += '\n'
+    return s
diff --git a/testsuite/tests/typecheck/should_compile/tc162.stderr b/testsuite/tests/typecheck/should_compile/tc162.stderr
deleted file mode 100644 (file)
index e69de29..0000000