2022-03-28 03:36:20 -05:00
|
|
|
include ../../run-make-fulldeps/tools.mk
|
|
|
|
|
|
|
|
# This test uses `ln -s` rather than copying to save testing time, but its
|
|
|
|
# usage doesn't work on Windows.
|
|
|
|
# ignore-windows
|
|
|
|
|
|
|
|
SYSROOT:=$(shell $(RUSTC) --print sysroot)
|
|
|
|
FAKEROOT=$(TMPDIR)/fakeroot
|
2022-10-17 05:36:54 -05:00
|
|
|
RUSTC_LOG:=rustc_error_messages
|
|
|
|
export RUSTC_TRANSLATION_NO_DEBUG_ASSERT:=1
|
2022-03-28 03:36:20 -05:00
|
|
|
|
2022-10-17 05:36:54 -05:00
|
|
|
all: normal custom missing broken sysroot sysroot-invalid sysroot-missing
|
2022-03-28 03:36:20 -05:00
|
|
|
|
2022-08-10 05:48:25 -05:00
|
|
|
# Check that the test works normally, using the built-in fallback bundle.
|
|
|
|
normal: test.rs
|
2023-03-05 08:30:50 -06:00
|
|
|
$(RUSTC) $< 2>&1 | $(CGREP) "struct literal body without path"
|
2022-03-28 03:36:20 -05:00
|
|
|
|
2022-08-10 05:48:25 -05:00
|
|
|
# Check that a primary bundle can be loaded and will be preferentially used
|
|
|
|
# where possible.
|
|
|
|
custom: test.rs working.ftl
|
2023-03-05 08:30:50 -06:00
|
|
|
$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/working.ftl 2>&1 | $(CGREP) "this is a test message"
|
2022-08-10 05:48:25 -05:00
|
|
|
|
|
|
|
# Check that a primary bundle with a broken message (e.g. a interpolated
|
|
|
|
# variable is missing) will use the fallback bundle.
|
|
|
|
missing: test.rs missing.ftl
|
2023-03-05 08:30:50 -06:00
|
|
|
$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/missing.ftl 2>&1 | $(CGREP) "struct literal body without path"
|
2022-08-10 05:48:25 -05:00
|
|
|
|
|
|
|
# Check that a primary bundle without the desired message will use the fallback
|
|
|
|
# bundle.
|
|
|
|
broken: test.rs broken.ftl
|
2023-03-05 08:30:50 -06:00
|
|
|
$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/broken.ftl 2>&1 | $(CGREP) "struct literal body without path"
|
2022-03-28 03:36:20 -05:00
|
|
|
|
2022-04-05 22:16:07 -05:00
|
|
|
# Check that a locale can be loaded from the sysroot given a language
|
|
|
|
# identifier by making a local copy of the sysroot and adding the custom locale
|
|
|
|
# to it.
|
2022-08-10 05:48:25 -05:00
|
|
|
sysroot: test.rs working.ftl
|
2022-10-17 05:36:54 -05:00
|
|
|
rm -rf $(FAKEROOT)
|
2022-03-28 03:36:20 -05:00
|
|
|
mkdir $(FAKEROOT)
|
|
|
|
ln -s $(SYSROOT)/* $(FAKEROOT)
|
|
|
|
rm -f $(FAKEROOT)/lib
|
|
|
|
mkdir $(FAKEROOT)/lib
|
|
|
|
ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
|
|
|
|
rm -f $(FAKEROOT)/lib/rustlib
|
|
|
|
mkdir $(FAKEROOT)/lib/rustlib
|
|
|
|
ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
|
|
|
|
rm -f $(FAKEROOT)/lib/rustlib/src
|
|
|
|
mkdir $(FAKEROOT)/lib/rustlib/src
|
|
|
|
ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
|
|
|
|
mkdir -p $(FAKEROOT)/share/locale/zh-CN/
|
2022-08-10 05:48:25 -05:00
|
|
|
ln -s $(CURDIR)/working.ftl $(FAKEROOT)/share/locale/zh-CN/basic-translation.ftl
|
2023-03-05 08:30:50 -06:00
|
|
|
$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | $(CGREP) "this is a test message"
|
2022-04-05 22:16:07 -05:00
|
|
|
|
|
|
|
# Check that the compiler errors out when the sysroot requested cannot be
|
|
|
|
# found. This test might start failing if there actually exists a Klingon
|
|
|
|
# translation of rustc's error messages.
|
2023-03-05 08:30:50 -06:00
|
|
|
sysroot-missing:
|
|
|
|
$(RUSTC) $< -Ztranslate-lang=tlh 2>&1 | $(CGREP) "missing locale directory"
|
2022-04-05 22:16:07 -05:00
|
|
|
|
2022-10-17 05:36:54 -05:00
|
|
|
# Check that the compiler errors out when the directory for the locale in the
|
|
|
|
# sysroot is actually a file.
|
2022-08-10 05:48:25 -05:00
|
|
|
sysroot-invalid: test.rs working.ftl
|
2022-10-17 05:36:54 -05:00
|
|
|
rm -rf $(FAKEROOT)
|
2022-04-05 22:16:07 -05:00
|
|
|
mkdir $(FAKEROOT)
|
|
|
|
ln -s $(SYSROOT)/* $(FAKEROOT)
|
|
|
|
rm -f $(FAKEROOT)/lib
|
|
|
|
mkdir $(FAKEROOT)/lib
|
|
|
|
ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
|
|
|
|
rm -f $(FAKEROOT)/lib/rustlib
|
|
|
|
mkdir $(FAKEROOT)/lib/rustlib
|
|
|
|
ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
|
|
|
|
rm -f $(FAKEROOT)/lib/rustlib/src
|
|
|
|
mkdir $(FAKEROOT)/lib/rustlib/src
|
|
|
|
ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
|
2022-10-17 05:36:54 -05:00
|
|
|
mkdir -p $(FAKEROOT)/share/locale
|
|
|
|
touch $(FAKEROOT)/share/locale/zh-CN
|
2023-03-05 08:30:50 -06:00
|
|
|
$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | $(CGREP) "`\$sysroot/share/locales/\$locale` is not a directory"
|