changeset 53163:5ad18f785a0e

annotate: add test for non-UTF8 with -Tjson This adds a test to test-annotate.t for annotating a non-UTF8 file with -Tjson. The current behavior is incorrect and outputs invalid JSON. I plan to fix the behavior in rhg annotate.
author Mitchell Kember <mkember@janestreet.com>
date Thu, 06 Mar 2025 14:18:49 -0500
parents fddb8e12c463
children 1f228f92426a
files tests/test-annotate.t
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-annotate.t	Mon Apr 14 13:36:02 2025 +0100
+++ b/tests/test-annotate.t	Thu Mar 06 14:18:49 2025 -0500
@@ -1060,6 +1060,19 @@
    }
   ]
 
+Test non-UTF8 (should use U+FFFD replacement character)
+TODO: fix Python which instead emits invalid JSON
+
+  $ "$PYTHON" -c 'open("latin1", "wb").write(b"\xc9")'
+  $ hg ci -qAm 'add latin1 file'
+  $ hg annotate -Tjson latin1
+  [
+   {
+    "lines": [{"line": "\xed\xb3\x89", "rev": 35}], (esc) (known-bad-output !)
+    "path": "latin1"
+   }
+  ]
+
 Test annotate with whitespace options
 
   $ cd ..