pub fn attribution() -> &'static str {
use std::sync::OnceLock;
static TEXT: OnceLock<String> = OnceLock::new();
TEXT.get_or_init(|| {
format!(
"Bundles uv {}, licensed under the Apache License, Version 2.0 (Apache-2.0).",
bombadil_uv_bin::BUNDLED_VERSION
)
})
}
pub fn license() -> &'static str {
bombadil_uv_bin::UV_LICENSE
}
pub fn font_attribution() -> &'static str {
"Uses Atkinson Hyperlegible Next and IBM Plex Mono, both licensed under \
the SIL Open Font License, Version 1.1 (OFL-1.1)."
}
pub fn atkinson_license() -> &'static str {
include_str!("../fonts/OFL-AtkinsonHyperlegibleNext.txt")
}
pub fn plex_license() -> &'static str {
include_str!("../fonts/OFL-IBMPlexMono.txt")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_attribution_names_uv_and_its_licence() {
let text = attribution();
assert!(text.contains("uv"), "got {text}");
assert!(
text.contains("Apache-2.0") || text.contains("Apache License"),
"got {text}"
);
}
#[test]
fn the_attribution_names_the_bundled_version() {
let text = attribution();
assert!(
text.contains(bombadil_uv_bin::BUNDLED_VERSION),
"must name the bundled version; got {text}"
);
}
#[test]
fn the_attribution_does_not_send_the_user_to_a_file_that_is_not_shipped() {
let text = attribution();
assert!(
!text.contains("UV-LICENSE"),
"the notice must not reference an undistributed file; got {text}"
);
}
#[test]
fn the_full_licence_text_is_reachable_from_the_ui() {
let text = license();
assert!(text.contains("Apache License"), "got {text}");
assert!(
text.contains("TERMS AND CONDITIONS"),
"the full text must ship, not just a title line"
);
}
#[test]
fn the_font_attribution_names_both_fonts_and_ofl() {
let text = font_attribution();
assert!(text.contains("Atkinson Hyperlegible Next"), "got {text}");
assert!(text.contains("IBM Plex Mono"), "got {text}");
assert!(
text.contains("OFL-1.1") || text.contains("Open Font License"),
"got {text}"
);
}
#[test]
fn both_font_licence_texts_are_reachable_from_the_ui() {
let atkinson = atkinson_license();
assert!(atkinson.contains("SIL OPEN FONT LICENSE"), "got {atkinson}");
assert!(atkinson.contains("Version 1.1"), "got {atkinson}");
let plex = plex_license();
assert!(plex.contains("SIL OPEN FONT LICENSE"), "got {plex}");
assert!(plex.contains("Version 1.1"), "got {plex}");
}
#[test]
fn the_font_licences_are_not_the_same_text_twice() {
assert_ne!(atkinson_license(), plex_license());
}
}