Skip to content

Commit 3399809

Browse files
committed
Greatly improve the error messages when run-make/translation fails
Before: ``` LD_LIBRARY_PATH="/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/test/run-make/translation/translation:/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/stage2/lib:/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/stage0-bootstrap-tools/aarch64-unknown-linux-gnu/release/deps:/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/stage0/lib" '/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/stage2/bin/rustc' --out-dir /home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/test/run-make/translation/translation -L /home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/test/run-make/translation/translation test.rs --sysroot /home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/test/run-make/translation/translation/fakeroot -Ztranslate-lang=zh-CN 2>&1 | grep "this is a test message" ------------------------------------------ --- stderr ------------------------------- make: *** [Makefile:51: sysroot] Error 1 ------------------------------------------ failures: [run-make] tests/run-make/translation ``` After: ``` LD_LIBRARY_PATH="/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/test/run-make/translation/translation:/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/stage2/lib:/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/stage0-bootstrap-tools/aarch64-unknown-linux-gnu/release/deps:/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/stage0/lib" '/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/stage2/bin/rustc' --out-dir /home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/test/run-make/translation/translation -L /home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/test/run-make/translation/translation test.rs --sysroot /home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/test/run-make/translation/translation/fakeroot -Ztranslate-lang=zh-CN 2>&1 | grep "this is a test message" [[[ begin stdout ]]] error: failed to load fluent bundle: failed to add resource: Attempt to override an existing message: "parse_struct_literal_body_without_path". [[[ end stdout ]]] Error: cannot match: this is a test message ------------------------------------------ --- stderr ------------------------------- make: *** [Makefile:51: sysroot] Error 1 ------------------------------------------ failures: [run-make] tests/run-make/translation ```
1 parent 35636f9 commit 3399809

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/run-make/translation/Makefile

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ all: normal custom missing broken sysroot sysroot-invalid sysroot-missing
1313

1414
# Check that the test works normally, using the built-in fallback bundle.
1515
normal: test.rs
16-
$(RUSTC) $< 2>&1 | grep "struct literal body without path"
16+
$(RUSTC) $< 2>&1 | $(CGREP) "struct literal body without path"
1717

1818
# Check that a primary bundle can be loaded and will be preferentially used
1919
# where possible.
2020
custom: test.rs working.ftl
21-
$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/working.ftl 2>&1 | grep "this is a test message"
21+
$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/working.ftl 2>&1 | $(CGREP) "this is a test message"
2222

2323
# Check that a primary bundle with a broken message (e.g. a interpolated
2424
# variable is missing) will use the fallback bundle.
2525
missing: test.rs missing.ftl
26-
$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/missing.ftl 2>&1 | grep "struct literal body without path"
26+
$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/missing.ftl 2>&1 | $(CGREP) "struct literal body without path"
2727

2828
# Check that a primary bundle without the desired message will use the fallback
2929
# bundle.
3030
broken: test.rs broken.ftl
31-
$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/broken.ftl 2>&1 | grep "struct literal body without path"
31+
$(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/broken.ftl 2>&1 | $(CGREP) "struct literal body without path"
3232

3333
# Check that a locale can be loaded from the sysroot given a language
3434
# identifier by making a local copy of the sysroot and adding the custom locale
@@ -48,13 +48,13 @@ sysroot: test.rs working.ftl
4848
ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
4949
mkdir -p $(FAKEROOT)/share/locale/zh-CN/
5050
ln -s $(CURDIR)/working.ftl $(FAKEROOT)/share/locale/zh-CN/basic-translation.ftl
51-
$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | grep "this is a test message"
51+
$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | $(CGREP) "this is a test message"
5252

5353
# Check that the compiler errors out when the sysroot requested cannot be
5454
# found. This test might start failing if there actually exists a Klingon
5555
# translation of rustc's error messages.
56-
sysroot-missing:
57-
$(RUSTC) $< -Ztranslate-lang=tlh 2>&1 | grep "missing locale directory"
56+
sysroot-missing:
57+
$(RUSTC) $< -Ztranslate-lang=tlh 2>&1 | $(CGREP) "missing locale directory"
5858

5959
# Check that the compiler errors out when the directory for the locale in the
6060
# sysroot is actually a file.
@@ -73,4 +73,4 @@ sysroot-invalid: test.rs working.ftl
7373
ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
7474
mkdir -p $(FAKEROOT)/share/locale
7575
touch $(FAKEROOT)/share/locale/zh-CN
76-
$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | grep "`\$sysroot/share/locales/\$locale` is not a directory"
76+
$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | $(CGREP) "`\$sysroot/share/locales/\$locale` is not a directory"

0 commit comments

Comments
 (0)