Skip to content

Commit

Permalink
[test] Use system locale for mri-utf8.test
Browse files Browse the repository at this point in the history
Summary:
llvm-ar's mri-utf8.test test relies on the en_US.UTF-8 locale to be
installed for its last RUN line to work. If not installed, the unicode
string gets encoded (interpreted) as ascii which fails since the most
significant byte is non zero. This commit changes the test to only rely
on the system being able to encode the pound sign in its default
encoding (e.g. UTF-16 for Microsoft Windows) by always opening the file
via input/output redirection. This avoids forcing a given locale to be
present and supported. A Byte Order Mark is also added to help
recognizing the encoding of the file and its endianness. Finally the
XFAIL on system-darwin is removed since the test actually passes fine on
Mac OS X and XFAIL was only added because it failed before.

Reviewers: gbreynoo, MaskRay, rupprecht, JamesNagurne, jfb

Subscribers: dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68472
  • Loading branch information
Thomas Preud'homme committed Nov 4, 2019
1 parent bf6744d commit 0bab053
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
21 changes: 21 additions & 0 deletions llvm/test/tools/llvm-ar/mri-nonascii.test
@@ -0,0 +1,21 @@
# Test non-ascii archive members

RUN: rm -rf %t && mkdir -p %t/extracted

# Note: lit's Python will read this UTF-8 encoded mri-nonascii.txt file,
# decode it to unicode. The filename in the redirection below will then
# be encoded in the system's filename encoding (e.g. UTF-16 for
# Microsoft Windows).
RUN: echo "contents" > %t/£.txt

RUN: echo "CREATE %t/mri.ar" > %t/script.mri
RUN: echo "ADDMOD %t/£.txt" >> %t/script.mri
RUN: echo "SAVE" >> %t/script.mri

RUN: llvm-ar -M < %t/script.mri
RUN: cd %t/extracted && llvm-ar x %t/mri.ar

# Same as above.
RUN: FileCheck --strict-whitespace %s <£.txt
CHECK:{{^}}
CHECK-SAME:{{^}}contents{{$}}
23 changes: 0 additions & 23 deletions llvm/test/tools/llvm-ar/mri-utf8.test

This file was deleted.

0 comments on commit 0bab053

Please sign in to comment.