2023-03-31 03:48:35 +02:00
|
|
|
// normalize-stderr-test "could not open Fluent resource:.*" -> "could not open Fluent resource: os-specific message"
|
2022-05-23 18:24:55 +01:00
|
|
|
|
|
|
|
#![feature(rustc_private)]
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
2023-04-16 14:33:00 +02:00
|
|
|
extern crate rustc_fluent_macro;
|
|
|
|
use rustc_fluent_macro::fluent_messages;
|
2022-05-23 18:24:55 +01:00
|
|
|
|
|
|
|
/// Copy of the relevant `DiagnosticMessage` variant constructed by `fluent_messages` as it
|
|
|
|
/// expects `crate::DiagnosticMessage` to exist.
|
|
|
|
pub enum DiagnosticMessage {
|
|
|
|
FluentIdentifier(std::borrow::Cow<'static, str>, Option<std::borrow::Cow<'static, str>>),
|
|
|
|
}
|
|
|
|
|
2022-05-24 15:09:47 +01:00
|
|
|
/// Copy of the relevant `SubdiagnosticMessage` variant constructed by `fluent_messages` as it
|
|
|
|
/// expects `crate::SubdiagnosticMessage` to exist.
|
|
|
|
pub enum SubdiagnosticMessage {
|
|
|
|
FluentAttr(std::borrow::Cow<'static, str>),
|
|
|
|
}
|
|
|
|
|
2022-05-23 18:24:55 +01:00
|
|
|
mod missing_absolute {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent_messages! { "/definitely_does_not_exist.ftl" }
|
|
|
|
//~^ ERROR could not open Fluent resource
|
2022-05-23 18:24:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mod missing_relative {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent_messages! { "../definitely_does_not_exist.ftl" }
|
|
|
|
//~^ ERROR could not open Fluent resource
|
2022-05-23 18:24:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mod missing_message {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent_messages! { "./missing-message.ftl" }
|
|
|
|
//~^ ERROR could not parse Fluent resource
|
2022-05-23 18:24:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mod duplicate {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent_messages! { "./duplicate.ftl" }
|
|
|
|
//~^ ERROR overrides existing message: `no_crate_a_b_key`
|
2022-05-23 18:24:55 +01:00
|
|
|
}
|
|
|
|
|
2022-08-10 11:31:31 +02:00
|
|
|
mod slug_with_hyphens {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent_messages! { "./slug-with-hyphens.ftl" }
|
|
|
|
//~^ ERROR name `no_crate_this-slug-has-hyphens` contains a '-' character
|
2022-08-10 11:31:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
mod label_with_hyphens {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent_messages! { "./label-with-hyphens.ftl" }
|
|
|
|
//~^ ERROR attribute `label-has-hyphens` contains a '-' character
|
2022-08-10 11:31:31 +02:00
|
|
|
}
|
|
|
|
|
2022-05-23 18:24:55 +01:00
|
|
|
mod valid {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent_messages! { "./valid.ftl" }
|
2022-05-23 18:24:55 +01:00
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
mod test_generated {
|
|
|
|
use super::{fluent_generated::no_crate_key, DEFAULT_LOCALE_RESOURCE};
|
|
|
|
}
|
2022-08-17 13:05:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
mod missing_crate_name {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent_messages! { "./missing-crate-name.ftl" }
|
|
|
|
//~^ ERROR name `no-crate_foo` contains a '-' character
|
|
|
|
//~| ERROR name `with-hyphens` contains a '-' character
|
|
|
|
//~| ERROR name `with-hyphens` does not start with the crate name
|
2022-08-17 13:05:13 +02:00
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
mod test_generated {
|
|
|
|
use super::{
|
|
|
|
fluent_generated::{no_crate_foo, with_hyphens},
|
|
|
|
DEFAULT_LOCALE_RESOURCE,
|
|
|
|
};
|
|
|
|
}
|
2022-05-23 18:24:55 +01:00
|
|
|
}
|
2023-01-19 23:48:08 +00:00
|
|
|
|
|
|
|
mod missing_message_ref {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent_messages! { "./missing-message-ref.ftl" }
|
|
|
|
//~^ ERROR referenced message `message` does not exist
|
2023-01-19 23:48:08 +00:00
|
|
|
}
|
2023-03-29 16:00:48 +01:00
|
|
|
|
|
|
|
mod bad_escape {
|
|
|
|
use super::fluent_messages;
|
|
|
|
|
|
|
|
fluent_messages! { "./invalid-escape.ftl" }
|
|
|
|
//~^ ERROR invalid escape `\n`
|
|
|
|
//~| ERROR invalid escape `\"`
|
|
|
|
//~| ERROR invalid escape `\'`
|
|
|
|
}
|