Skip to content

Commit

Permalink
Update translation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nilstrieb committed Oct 23, 2022
1 parent c65ebae commit 6987322
Show file tree
Hide file tree
Showing 8 changed files with 356 additions and 342 deletions.
5 changes: 3 additions & 2 deletions src/test/ui-fulldeps/fluent-messages/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ mod duplicate {
use super::fluent_messages;

fluent_messages! {
//~^ ERROR the name `a_b_key` is defined multiple times
a => "./duplicate-a.ftl",
a_b => "./duplicate-a-b.ftl",
//~^ ERROR overrides existing message: `a_b_key`
Expand Down Expand Up @@ -80,7 +81,7 @@ mod valid {
valid => "./valid.ftl",
}

use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid::key};
use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid_key};
}

mod missing_crate_name {
Expand All @@ -93,5 +94,5 @@ mod missing_crate_name {
//~| ERROR name `with-hyphens` does not start with the crate name
}

use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate::{foo, with_hyphens}};
use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate_foo, with_hyphens};
}
29 changes: 21 additions & 8 deletions src/test/ui-fulldeps/fluent-messages/test.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,56 +30,69 @@ error: expected a message field for "missing_message"
|

error: overrides existing message: `a_b_key`
--> $DIR/test.rs:53:16
--> $DIR/test.rs:54:16
|
LL | a_b => "./duplicate-a-b.ftl",
| ^^^^^^^^^^^^^^^^^^^^^
|
help: previously defined in this resource
--> $DIR/test.rs:52:14
--> $DIR/test.rs:53:14
|
LL | a => "./duplicate-a.ftl",
| ^^^^^^^^^^^^^^^^^^^

error[E0428]: the name `a_b_key` is defined multiple times
--> $DIR/test.rs:51:5
|
LL | fluent_messages! {
| ^^^^^^^^^^^^^^^^
| |
| `a_b_key` redefined here
| previous definition of the value `a_b_key` here
|
= note: os-specific message
= note: os-specific message

error: name `slug_with_hyphens_this-slug-has-hyphens` contains a '-' character
--> $DIR/test.rs:62:30
--> $DIR/test.rs:63:30
|
LL | slug_with_hyphens => "./slug-with-hyphens.ftl",
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: replace any '-'s with '_'s

error: attribute `label-has-hyphens` contains a '-' character
--> $DIR/test.rs:71:31
--> $DIR/test.rs:72:31
|
LL | label_with_hyphens => "./label-with-hyphens.ftl",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: replace any '-'s with '_'s

error: name `with-hyphens` contains a '-' character
--> $DIR/test.rs:90:23
--> $DIR/test.rs:91:23
|
LL | test_crate => "./missing-crate-name.ftl",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: replace any '-'s with '_'s

error: name `with-hyphens` does not start with the crate name
--> $DIR/test.rs:90:23
--> $DIR/test.rs:91:23
|
LL | test_crate => "./missing-crate-name.ftl",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: prepend `test_crate_` to the slug name: `test_crate_with_hyphens`

error: name `test-crate_foo` contains a '-' character
--> $DIR/test.rs:90:23
--> $DIR/test.rs:91:23
|
LL | test_crate => "./missing-crate-name.ftl",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: replace any '-'s with '_'s

error: aborting due to 9 previous errors
error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0428`.
10 changes: 5 additions & 5 deletions src/test/ui-fulldeps/internal-lints/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::Span;

#[derive(Diagnostic)]
#[diag(compiletest::example)]
#[diag(compiletest_example)]
struct DeriveDiagnostic {
#[primary_span]
span: Span,
}

#[derive(Subdiagnostic)]
#[note(compiletest::example)]
#[note(compiletest_example)]
struct Note {
#[primary_span]
span: Span,
Expand All @@ -45,7 +45,7 @@ pub struct TranslatableInIntoDiagnostic;

impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
handler.struct_err(fluent::compiletest::example)
handler.struct_err(fluent::compiletest_example)
}
}

Expand All @@ -68,12 +68,12 @@ impl AddToDiagnostic for TranslatableInAddToDiagnostic {
where
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
{
diag.note(fluent::compiletest::note);
diag.note(fluent::note);
}
}

pub fn make_diagnostics<'a>(handler: &'a Handler) {
let _diag = handler.struct_err(fluent::compiletest::example);
let _diag = handler.struct_err(fluent::compiletest_example);
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls

let _diag = handler.struct_err("untranslatable diagnostic");
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/internal-lints/diagnostics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LL | diag.note("untranslatable diagnostic");
error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
--> $DIR/diagnostics.rs:76:25
|
LL | let _diag = handler.struct_err(fluent::compiletest::example);
LL | let _diag = handler.struct_err(fluent::compiletest_example);
| ^^^^^^^^^^
|
note: the lint level is defined here
Expand Down
Loading

0 comments on commit 6987322

Please sign in to comment.