mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
errors: fix translation's run-make test
`run-make/translation` had some targets that weren't listed in `all` and thus weren't being tested - the behaviour that should have been being tested was basically correct fortunately. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
d1fcf61117
commit
a8e37507f4
@ -4,6 +4,7 @@ use crate::{DiagnosticArg, DiagnosticMessage, FluentBundle};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_error_messages::FluentArgs;
|
||||
use std::borrow::Cow;
|
||||
use std::env;
|
||||
use std::error::Report;
|
||||
|
||||
/// Convert diagnostic arguments (a rustc internal type that exists to implement
|
||||
@ -94,8 +95,16 @@ pub trait Translate {
|
||||
// The primary bundle was present and translation succeeded
|
||||
Some(Ok(t)) => t,
|
||||
|
||||
// Always yeet out for errors on debug
|
||||
Some(Err(primary)) if cfg!(debug_assertions) => do yeet primary,
|
||||
// Always yeet out for errors on debug (unless
|
||||
// `RUSTC_TRANSLATION_NO_DEBUG_ASSERT` is set in the environment - this allows
|
||||
// local runs of the test suites, of builds with debug assertions, to test the
|
||||
// behaviour in a normal build).
|
||||
Some(Err(primary))
|
||||
if cfg!(debug_assertions)
|
||||
&& env::var("RUSTC_TRANSLATION_NO_DEBUG_ASSERT").is_err() =>
|
||||
{
|
||||
do yeet primary
|
||||
}
|
||||
|
||||
// If `translate_with_bundle` returns `Err` with the primary bundle, this is likely
|
||||
// just that the primary bundle doesn't contain the message being translated or
|
||||
|
@ -6,8 +6,10 @@ include ../../run-make-fulldeps/tools.mk
|
||||
|
||||
SYSROOT:=$(shell $(RUSTC) --print sysroot)
|
||||
FAKEROOT=$(TMPDIR)/fakeroot
|
||||
RUSTC_LOG:=rustc_error_messages
|
||||
export RUSTC_TRANSLATION_NO_DEBUG_ASSERT:=1
|
||||
|
||||
all: normal custom sysroot
|
||||
all: normal custom missing broken sysroot sysroot-invalid sysroot-missing
|
||||
|
||||
# Check that the test works normally, using the built-in fallback bundle.
|
||||
normal: test.rs
|
||||
@ -32,6 +34,7 @@ broken: test.rs broken.ftl
|
||||
# identifier by making a local copy of the sysroot and adding the custom locale
|
||||
# to it.
|
||||
sysroot: test.rs working.ftl
|
||||
rm -rf $(FAKEROOT)
|
||||
mkdir $(FAKEROOT)
|
||||
ln -s $(SYSROOT)/* $(FAKEROOT)
|
||||
rm -f $(FAKEROOT)/lib
|
||||
@ -51,12 +54,12 @@ sysroot: test.rs working.ftl
|
||||
# found. This test might start failing if there actually exists a Klingon
|
||||
# translation of rustc's error messages.
|
||||
sysroot-missing:
|
||||
$(RUSTC) $< -Ztranslate-lang=tlh 2>&1 || grep "missing locale directory"
|
||||
$(RUSTC) $< -Ztranslate-lang=tlh 2>&1 | grep "missing locale directory"
|
||||
|
||||
# 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.
|
||||
# Check that the compiler errors out when the directory for the locale in the
|
||||
# sysroot is actually a file.
|
||||
sysroot-invalid: test.rs working.ftl
|
||||
rm -rf $(FAKEROOT)
|
||||
mkdir $(FAKEROOT)
|
||||
ln -s $(SYSROOT)/* $(FAKEROOT)
|
||||
rm -f $(FAKEROOT)/lib
|
||||
@ -68,5 +71,6 @@ sysroot-invalid: test.rs working.ftl
|
||||
rm -f $(FAKEROOT)/lib/rustlib/src
|
||||
mkdir $(FAKEROOT)/lib/rustlib/src
|
||||
ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
|
||||
touch $(FAKEROOT)/share/locale/zh-CN/
|
||||
$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 || grep "`\$sysroot/share/locales/\$locale` is not a directory"
|
||||
mkdir -p $(FAKEROOT)/share/locale
|
||||
touch $(FAKEROOT)/share/locale/zh-CN
|
||||
$(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | grep "`\$sysroot/share/locales/\$locale` is not a directory"
|
||||
|
Loading…
Reference in New Issue
Block a user