aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorNazir Bilal Yavuz <byavuz81@gmail.com>2023-06-12 13:47:19 +0300
committerDylan Baker <dylan@pnwbakers.com>2023-07-13 09:38:55 -0700
commitbd3d2cf91894b1f91128011b2cf56a5bd2c326ae (patch)
tree1955faa13e2a9b97630b0dc4d540e7428c228710 /test cases
parent61984bcfa3e4e758d18174d13aa0aaedbf406889 (diff)
downloadmeson-bd3d2cf91894b1f91128011b2cf56a5bd2c326ae.zip
meson-bd3d2cf91894b1f91128011b2cf56a5bd2c326ae.tar.gz
meson-bd3d2cf91894b1f91128011b2cf56a5bd2c326ae.tar.bz2
mtest: fix unencodable XML chars
Replace unencodable XML chars with their printable representation, so that, xmllint can parse test outputs without error. Closes #9894 Co-authored-by: Tristan Partin <tristan@partin.io>
Diffstat (limited to 'test cases')
-rw-r--r--test cases/unit/110 replace unencodable xml chars/meson.build4
-rw-r--r--test cases/unit/110 replace unencodable xml chars/script.py37
2 files changed, 41 insertions, 0 deletions
diff --git a/test cases/unit/110 replace unencodable xml chars/meson.build b/test cases/unit/110 replace unencodable xml chars/meson.build
new file mode 100644
index 0000000..2e6b1b7
--- /dev/null
+++ b/test cases/unit/110 replace unencodable xml chars/meson.build
@@ -0,0 +1,4 @@
+project('replace unencodable xml chars')
+
+test_script = find_program('script.py')
+test('main', test_script)
diff --git a/test cases/unit/110 replace unencodable xml chars/script.py b/test cases/unit/110 replace unencodable xml chars/script.py
new file mode 100644
index 0000000..2f2d4d6
--- /dev/null
+++ b/test cases/unit/110 replace unencodable xml chars/script.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+import sys
+
+# Print base string(\nHello Meson\n) to see valid chars are not replaced
+print('\n\x48\x65\x6c\x6c\x6f\x20\x4d\x65\x73\x6f\x6e\n')
+# Print invalid input from all known unencodable chars
+print(
+ '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f\x10\x11'
+ '\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f')
+
+# Cover for potential encoding issues
+try:
+ print(
+ '\x80\x81\x82\x83\x84\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f'
+ '\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e'
+ '\x9f\ufdd0\ufdd1\ufdd2\ufdd3\ufdd4\ufdd5\ufdd6\ufdd7\ufdd8'
+ '\ufdd9\ufdda\ufddb\ufddc\ufddd\ufdde\ufddf\ufde0\ufde1'
+ '\ufde2\ufde3\ufde4\ufde5\ufde6\ufde7\ufde8\ufde9\ufdea'
+ '\ufdeb\ufdec\ufded\ufdee\ufdef\ufffe\uffff')
+except:
+ pass
+
+# Cover for potential encoding issues
+try:
+ if sys.maxunicode >= 0x10000:
+ print(
+ '\U0001fffe\U0001ffff\U0002fffe\U0002ffff'
+ '\U0003fffe\U0003ffff\U0004fffe\U0004ffff'
+ '\U0005fffe\U0005ffff\U0006fffe\U0006ffff'
+ '\U0007fffe\U0007ffff\U0008fffe\U0008ffff'
+ '\U0009fffe\U0009ffff\U000afffe\U000affff'
+ '\U000bfffe\U000bffff\U000cfffe\U000cffff'
+ '\U000dfffe\U000dffff\U000efffe\U000effff'
+ '\U000ffffe\U000fffff\U0010fffe\U0010ffff')
+except:
+ pass