1 include ../../run-make-fulldeps/tools.mk
3 # This test uses `ln -s` rather than copying to save testing time, but its
4 # usage doesn't work on Windows.
7 SYSROOT:=$(shell $(RUSTC) --print sysroot)
8 FAKEROOT=$(TMPDIR)/fakeroot
10 all: normal custom sysroot
12 # Check that the test works normally, using the built-in fallback bundle.
14 $(RUSTC) $< 2>&1 | grep "struct literal body without path"
16 # Check that a primary bundle can be loaded and will be preferentially used
18 custom: test.rs working.ftl
19 $(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/working.ftl 2>&1 | grep "this is a test message"
21 # Check that a primary bundle with a broken message (e.g. a interpolated
22 # variable is missing) will use the fallback bundle.
23 missing: test.rs missing.ftl
24 $(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/missing.ftl 2>&1 | grep "struct literal body without path"
26 # Check that a primary bundle without the desired message will use the fallback
28 broken: test.rs broken.ftl
29 $(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/broken.ftl 2>&1 | grep "struct literal body without path"
31 # Check that a locale can be loaded from the sysroot given a language
32 # identifier by making a local copy of the sysroot and adding the custom locale
34 sysroot: test.rs working.ftl
36 ln -s $(SYSROOT)/* $(FAKEROOT)
39 ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
40 rm -f $(FAKEROOT)/lib/rustlib
41 mkdir $(FAKEROOT)/lib/rustlib
42 ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
43 rm -f $(FAKEROOT)/lib/rustlib/src
44 mkdir $(FAKEROOT)/lib/rustlib/src
45 ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
46 mkdir -p $(FAKEROOT)/share/locale/zh-CN/
47 ln -s $(CURDIR)/working.ftl $(FAKEROOT)/share/locale/zh-CN/basic-translation.ftl
48 $(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | grep "this is a test message"
50 # Check that the compiler errors out when the sysroot requested cannot be
51 # found. This test might start failing if there actually exists a Klingon
52 # translation of rustc's error messages.
54 $(RUSTC) $< -Ztranslate-lang=tlh 2>&1 || grep "missing locale directory"
56 # Check that the compiler errors out when the sysroot requested cannot be
57 # found. This test might start failing if there actually exists a Klingon
58 # translation of rustc's error messages.
59 sysroot-invalid: test.rs working.ftl
61 ln -s $(SYSROOT)/* $(FAKEROOT)
64 ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
65 rm -f $(FAKEROOT)/lib/rustlib
66 mkdir $(FAKEROOT)/lib/rustlib
67 ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
68 rm -f $(FAKEROOT)/lib/rustlib/src
69 mkdir $(FAKEROOT)/lib/rustlib/src
70 ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
71 touch $(FAKEROOT)/share/locale/zh-CN/
72 $(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 || grep "`\$sysroot/share/locales/\$locale` is not a directory"