fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
3.2 KiB78 linesraw
1include ../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
7SYSROOT:=$(shell $(RUSTC) --print sysroot)
8FAKEROOT=$(TMPDIR)/fakeroot
9RUSTC_LOG:=rustc_error_messages
10export RUSTC_TRANSLATION_NO_DEBUG_ASSERT:=1
11
12all: normal custom missing broken sysroot sysroot-invalid sysroot-missing
13
14# Check that the test works normally, using the built-in fallback bundle.
15normal: test.rs
16	$(RUSTC) $< 2>&1 | $(CGREP) "struct literal body without path"
17
18# Check that a primary bundle can be loaded and will be preferentially used
19# where possible.
20custom: test.rs working.ftl
21	$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/working.ftl 2>&1 | $(CGREP) "this is a test message"
22
23# Check that a primary bundle with a broken message (e.g. a interpolated
24# variable is missing) will use the fallback bundle.
25missing: test.rs missing.ftl
26	$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/missing.ftl 2>&1 | $(CGREP) "struct literal body without path"
27
28# Check that a primary bundle without the desired message will use the fallback
29# bundle.
30broken: test.rs broken.ftl
31	$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/broken.ftl 2>&1 | $(CGREP) "struct literal body without path"
32
33# Check that a locale can be loaded from the sysroot given a language
34# identifier by making a local copy of the sysroot and adding the custom locale
35# to it.
36sysroot: test.rs working.ftl
37	rm -rf $(FAKEROOT)
38	mkdir $(FAKEROOT)
39	ln -s $(SYSROOT)/* $(FAKEROOT)
40	rm -f $(FAKEROOT)/lib
41	mkdir $(FAKEROOT)/lib
42	ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
43	rm -f $(FAKEROOT)/lib/rustlib
44	mkdir $(FAKEROOT)/lib/rustlib
45	ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
46	rm -f $(FAKEROOT)/lib/rustlib/src
47	mkdir $(FAKEROOT)/lib/rustlib/src
48	ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
49	# When download-rustc is enabled, `$(SYSROOT)` will have a share directory. Delete the link to it.
50	rm -f $(FAKEROOT)/share
51	mkdir -p $(FAKEROOT)/share/locale/zh-CN/
52	ln -s $(CURDIR)/working.ftl $(FAKEROOT)/share/locale/zh-CN/basic-translation.ftl
53	$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | $(CGREP) "this is a test message"
54
55# Check that the compiler errors out when the sysroot requested cannot be
56# found. This test might start failing if there actually exists a Klingon
57# translation of rustc's error messages.
58sysroot-missing:
59	$(RUSTC) $< -Ztranslate-lang=tlh 2>&1 | $(CGREP) "missing locale directory"
60
61# Check that the compiler errors out when the directory for the locale in the
62# sysroot is actually a file.
63sysroot-invalid: test.rs working.ftl
64	rm -rf $(FAKEROOT)
65	mkdir $(FAKEROOT)
66	ln -s $(SYSROOT)/* $(FAKEROOT)
67	rm -f $(FAKEROOT)/lib
68	mkdir $(FAKEROOT)/lib
69	ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
70	rm -f $(FAKEROOT)/lib/rustlib
71	mkdir $(FAKEROOT)/lib/rustlib
72	ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
73	rm -f $(FAKEROOT)/lib/rustlib/src
74	mkdir $(FAKEROOT)/lib/rustlib/src
75	ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
76	mkdir -p $(FAKEROOT)/share/locale
77	touch $(FAKEROOT)/share/locale/zh-CN
78	$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | $(CGREP) "`\$sysroot/share/locales/\$locale` is not a directory"