Skip to content

Commit 7028980

Browse files
committed
Utility: test corrade_add_resource() with Unicode filenames.
Causes CMake with Ninja+MSVC to go into an infinite loop, MinGW fails during build. Wow.
1 parent b47ea83 commit 7028980

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Corrade/Utility/Test/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,18 @@ corrade_add_test(UtilityUnicodeTest UnicodeTest.cpp LIBRARIES CorradeUtilityTest
163163
corrade_add_resource(ResourceTestData ResourceTestFiles/resources.conf)
164164
corrade_add_resource(ResourceTestEmptyFileData ResourceTestFiles/resources-empty-file.conf)
165165
corrade_add_resource(ResourceTestNothingData ResourceTestFiles/resources-nothing.conf)
166+
167+
# CMake < 3.1 can't handle UTF-8 in file(STRINGS)
168+
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
169+
corrade_add_resource(ResourceTestUtf8Data ResourceTestFiles/hýždě.conf)
170+
endif()
171+
166172
corrade_add_test(UtilityResourceTest
167173
ResourceTest.cpp
168174
${ResourceTestData}
169175
${ResourceTestEmptyFileData}
170176
${ResourceTestNothingData}
177+
${ResourceTestUtf8Data}
171178
LIBRARIES CorradeUtilityTestLib
172179
FILES
173180
ResourceTestFiles/compiled.cpp
@@ -195,6 +202,11 @@ corrade_add_test(UtilityResourceTest
195202
ResourceTestFiles/resources-overriden-nonexistent-file.conf)
196203
target_include_directories(UtilityResourceTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
197204

205+
# CMake < 3.1 can't handle UTF-8 in file(STRINGS), disable relevant test case
206+
if(CMAKE_VERSION VERSION_LESS 3.1)
207+
target_compile_definitions(UtilityResourceTest PRIVATE "RESOURCETETST_NO_UNICODE")
208+
endif()
209+
198210
# Static lib resource test
199211
add_library(ResourceTestDataLib STATIC ${ResourceTestData})
200212
target_link_libraries(ResourceTestDataLib CorradeUtility)

src/Corrade/Utility/Test/ResourceTest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct ResourceTest: TestSuite::Tester {
5656
void getEmptyFile();
5757
void getNonexistent();
5858
void getNothing();
59+
void getUtf8Filename();
5960

6061
void overrideGroup();
6162
void overrideGroupFallback();
@@ -83,6 +84,7 @@ ResourceTest::ResourceTest() {
8384
&ResourceTest::getEmptyFile,
8485
&ResourceTest::getNonexistent,
8586
&ResourceTest::getNothing,
87+
&ResourceTest::getUtf8Filename,
8688

8789
&ResourceTest::overrideGroup,
8890
&ResourceTest::overrideGroupFallback,
@@ -239,6 +241,17 @@ void ResourceTest::getNothing() {
239241
CORRADE_VERIFY(r.get("nonexistentFile").empty());
240242
}
241243

244+
void ResourceTest::getUtf8Filename() {
245+
#ifdef RESOURCETETST_NO_UNICODE
246+
CORRADE_SKIP("CMake < 3.1 used, can't test compilation of resources with UTF-8 filenames.");
247+
#else
248+
Resource r("unicode");
249+
CORRADE_COMPARE_AS(r.get("hýždě.bin"),
250+
Directory::join(RESOURCE_TEST_DIR, "hýždě.bin"),
251+
TestSuite::Compare::StringToFile);
252+
#endif
253+
}
254+
242255
void ResourceTest::overrideGroup() {
243256
std::ostringstream out;
244257
Debug redirectDebug{&out};

0 commit comments

Comments
 (0)