From 0a253246f73eb72f14fb218867b6ace3014e0286 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Fri, 23 Aug 2024 18:09:20 +0000 Subject: [PATCH] Add test for fluent diagnostics --- .../ui-fulldeps/fluent-messages/many-lines.ftl | 11 +++++++++++ tests/ui-fulldeps/fluent-messages/test.rs | 5 +++++ tests/ui-fulldeps/fluent-messages/test.stderr | 17 ++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/ui-fulldeps/fluent-messages/many-lines.ftl diff --git a/tests/ui-fulldeps/fluent-messages/many-lines.ftl b/tests/ui-fulldeps/fluent-messages/many-lines.ftl new file mode 100644 index 00000000000..43660ebeacd --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/many-lines.ftl @@ -0,0 +1,11 @@ +no_crate_foo = foo + +# This file tests error reporting for +# fluent files with many lines. +# The error message should point to the correct line number +# and include no more context than necessary. + +no_crate_bar = + +no_crate_baz = + baz diff --git a/tests/ui-fulldeps/fluent-messages/test.rs b/tests/ui-fulldeps/fluent-messages/test.rs index 7bf1252ccf6..3361ebcef01 100644 --- a/tests/ui-fulldeps/fluent-messages/test.rs +++ b/tests/ui-fulldeps/fluent-messages/test.rs @@ -80,3 +80,8 @@ mod bad_escape { //~| ERROR invalid escape `\"` //~| ERROR invalid escape `\'` } + +mod many_lines { + rustc_fluent_macro::fluent_messages! { "./many-lines.ftl" } + //~^ ERROR could not parse Fluent resource +} diff --git a/tests/ui-fulldeps/fluent-messages/test.stderr b/tests/ui-fulldeps/fluent-messages/test.stderr index 09d4a384732..139790462f0 100644 --- a/tests/ui-fulldeps/fluent-messages/test.stderr +++ b/tests/ui-fulldeps/fluent-messages/test.stderr @@ -103,5 +103,20 @@ LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" } | = note: Fluent does not interpret these escape sequences () -error: aborting due to 13 previous errors +error: could not parse Fluent resource + --> $DIR/test.rs:85:44 + | +LL | rustc_fluent_macro::fluent_messages! { "./many-lines.ftl" } + | ^^^^^^^^^^^^^^^^^^ + | + = help: see additional errors emitted + +error: expected a message field for "no_crate_bar" + --> ./many-lines.ftl:15:1 + | +15 | no_crate_bar = + | ^^^^^^^^^^^^^^ + | + +error: aborting due to 14 previous errors