]> git.lizzy.rs Git - rust.git/blob - src/test/run-make/translation/Makefile
errors: don't fail on broken primary translations
[rust.git] / src / test / run-make / translation / Makefile
1 include ../../run-make-fulldeps/tools.mk
2
3 # This test uses `ln -s` rather than copying to save testing time, but its
4 # usage doesn't work on Windows.
5 # ignore-windows
6
7 SYSROOT:=$(shell $(RUSTC) --print sysroot)
8 FAKEROOT=$(TMPDIR)/fakeroot
9
10 all: normal custom sysroot
11
12 # Check that the test works normally, using the built-in fallback bundle.
13 normal: test.rs
14         $(RUSTC) $< 2>&1 | grep "struct literal body without path"
15
16 # Check that a primary bundle can be loaded and will be preferentially used
17 # where possible.
18 custom: test.rs working.ftl
19         $(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/working.ftl 2>&1 | grep "this is a test message"
20
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"
25
26 # Check that a primary bundle without the desired message will use the fallback
27 # bundle.
28 broken: test.rs broken.ftl
29         $(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/broken.ftl 2>&1 | grep "struct literal body without path"
30
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
33 # to it.
34 sysroot: test.rs working.ftl
35         mkdir $(FAKEROOT)
36         ln -s $(SYSROOT)/* $(FAKEROOT)
37         rm -f $(FAKEROOT)/lib
38         mkdir $(FAKEROOT)/lib
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"
49
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.
53 sysroot-missing: 
54         $(RUSTC) $< -Ztranslate-lang=tlh 2>&1 || grep "missing locale directory"
55
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
60         mkdir $(FAKEROOT)
61         ln -s $(SYSROOT)/* $(FAKEROOT)
62         rm -f $(FAKEROOT)/lib
63         mkdir $(FAKEROOT)/lib
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"