diff --git a/pomme-client/src/app/install.rs b/pomme-client/src/app/install.rs index 704710690..04aabb84c 100644 --- a/pomme-client/src/app/install.rs +++ b/pomme-client/src/app/install.rs @@ -70,16 +70,19 @@ impl Install { let state = Arc::clone(&self.state); let report = move |progress| *state.lock().unwrap() = State::Running(progress); let job: Pin + Send>> = match self.job { - Job::Update => Box::pin(async move { - match crate::update::run(&report).await { - Ok(Some(exe)) => State::Updated(exe), - Ok(None) => State::Done, - Err(reason) => { - tracing::warn!("Skipping the update: {reason}"); - State::Done + Job::Update => { + let channel = core.menu.update_channel(); + Box::pin(async move { + match crate::update::run(channel, &report).await { + Ok(Some(exe)) => State::Updated(exe), + Ok(None) => State::Done, + Err(reason) => { + tracing::warn!("Skipping the update: {reason}"); + State::Done + } } - } - }), + }) + } Job::Assets => { let dirs = core.data_dirs.clone(); let version = core.version.clone(); diff --git a/pomme-client/src/args.rs b/pomme-client/src/args.rs index 2b892d6b8..13d6a3e55 100644 --- a/pomme-client/src/args.rs +++ b/pomme-client/src/args.rs @@ -30,6 +30,11 @@ pub struct LaunchArgs { #[arg(long)] pub launch_token: Option, + /// Starts this build as it is, without updating it first: the way to the + /// Nightly Builds option when the newest build won't start. + #[arg(long)] + pub no_update: bool, + #[arg(long)] pub assets_dir: Option, diff --git a/pomme-client/src/ui/menu/mod.rs b/pomme-client/src/ui/menu/mod.rs index 774709181..5a7a0103d 100644 --- a/pomme-client/src/ui/menu/mod.rs +++ b/pomme-client/src/ui/menu/mod.rs @@ -16,6 +16,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::Instant; +use pomme_install::client::Channel; use serde::{Deserialize, Serialize}; use winit::keyboard::KeyCode; @@ -85,6 +86,8 @@ struct Settings { vignette: bool, #[serde(default = "default_true")] entity_shadows: bool, + #[serde(default)] + nightly_builds: bool, #[serde(default = "default_true")] show_autosave_indicator: bool, #[serde(default = "default_true")] @@ -336,6 +339,7 @@ impl Default for Settings { show_autosave_indicator: true, vignette: true, entity_shadows: true, + nightly_builds: false, vsync: true, max_framerate: 120, inactivity_fps_limit: InactivityFpsLimit::default(), @@ -633,6 +637,7 @@ enum Screen { OptionsPomme, OptionsPommePerformance, OptionsPommeShaders, + OptionsPommeUpdates, OptionsSkinCustomization, OptionsMusicSounds, OptionsControls, @@ -661,6 +666,7 @@ impl Screen { Self::OptionsPomme => Self::OptionsPomme, Self::OptionsPommePerformance => Self::OptionsPommePerformance, Self::OptionsPommeShaders => Self::OptionsPommeShaders, + Self::OptionsPommeUpdates => Self::OptionsPommeUpdates, Self::OptionsSkinCustomization => Self::OptionsSkinCustomization, Self::OptionsMusicSounds => Self::OptionsMusicSounds, Self::OptionsControls => Self::OptionsControls, @@ -857,6 +863,8 @@ pub struct MainMenu { pub show_autosave_indicator: bool, pub vignette: bool, pub entity_shadows: bool, + /// Whether updates follow master's nightly builds (Pomme-only). + nightly_builds: bool, pub vsync: bool, pub max_framerate: u32, pub inactivity_fps_limit: InactivityFpsLimit, @@ -1033,6 +1041,7 @@ impl MainMenu { show_autosave_indicator: settings.show_autosave_indicator, vignette: settings.vignette, entity_shadows: settings.entity_shadows, + nightly_builds: settings.nightly_builds, vsync: settings.vsync, max_framerate: settings.max_framerate, inactivity_fps_limit: settings.inactivity_fps_limit, @@ -1295,6 +1304,7 @@ impl MainMenu { show_autosave_indicator: self.show_autosave_indicator, vignette: self.vignette, entity_shadows: self.entity_shadows, + nightly_builds: self.nightly_builds, vsync: self.vsync, max_framerate: self.max_framerate, inactivity_fps_limit: self.inactivity_fps_limit, @@ -1406,6 +1416,15 @@ impl MainMenu { self.save_settings(key_bindings); } + /// The builds this client updates to at its next start. + pub fn update_channel(&self) -> Channel { + if self.nightly_builds { + Channel::Nightly + } else { + Channel::Stable + } + } + pub fn open_options(&mut self, key_bindings: &KeyBindings) { // Stale after a disconnect; the in-game path re-sets it every frame. self.server_render_distance = 0; @@ -1432,6 +1451,7 @@ impl MainMenu { | Screen::OptionsPomme | Screen::OptionsPommePerformance | Screen::OptionsPommeShaders + | Screen::OptionsPommeUpdates | Screen::OptionsSkinCustomization | Screen::OptionsMusicSounds | Screen::OptionsControls @@ -1738,6 +1758,13 @@ impl MainMenu { &text_width_fn, key_bindings, ), + Screen::OptionsPommeUpdates => self.build_options_pomme_updates( + screen_w, + screen_h, + input, + &text_width_fn, + key_bindings, + ), Screen::OptionsSkinCustomization => { self.build_options_skin(screen_w, screen_h, input, &text_width_fn, key_bindings) } diff --git a/pomme-client/src/ui/menu/options.rs b/pomme-client/src/ui/menu/options.rs index 016249356..31b0a60d8 100644 --- a/pomme-client/src/ui/menu/options.rs +++ b/pomme-client/src/ui/menu/options.rs @@ -193,6 +193,7 @@ const MENU_BACKGROUND_BLUR: &str = "Menu Background Blur:"; const CHUNK_DETAIL: &str = "Chunk Detail:"; const DISTANT_TERRAIN: &str = "Distant Terrain:"; const SHADER_PACK: &str = "Shader Pack:"; +const NIGHTLY_BUILDS: &str = "Nightly Builds:"; const CHUNK_FADE: &str = "Chunk Fade:"; const INACTIVITY_FPS_LIMIT: &str = "Reduce fps when:"; @@ -566,10 +567,15 @@ impl MainMenu { text_width_fn: common::TextWidthFn, key_bindings: &KeyBindings, ) -> MainMenuResult { - let rows = [OptRow::Pair("Performance...", "Shaders...")]; + let mut rows = vec![OptRow::Pair("Performance...", "Shaders...")]; + // Phones and tablets don't update themselves (`update::enabled`). + if cfg!(not(mobile)) { + rows.push(OptRow::PairLeft("Updates...")); + } let nav: &[(&str, Screen)] = &[ ("Performance...", Screen::OptionsPommePerformance), ("Shaders...", Screen::OptionsPommeShaders), + ("Updates...", Screen::OptionsPommeUpdates), ]; self.build_options_grid( sw, @@ -662,6 +668,39 @@ impl MainMenu { ) } + /// Pomme Settings' Updates category (Pomme-only). + pub(super) fn build_options_pomme_updates( + &mut self, + sw: f32, + sh: f32, + input: &MenuInput, + text_width_fn: common::TextWidthFn, + key_bindings: &KeyBindings, + ) -> MainMenuResult { + let nightly_label = format!("{NIGHTLY_BUILDS} {}", on_off(self.nightly_builds)); + let rows = [OptRow::PairLeft(&nightly_label)]; + let tooltips: &[(&str, &str)] = &[( + NIGHTLY_BUILDS, + "Updates to each night's build when the game starts, not only to releases. Nightly \ + builds are less tested.", + )]; + self.build_options_grid( + sw, + sh, + input, + "Updates", + Screen::OptionsPomme, + &rows, + &[], + &[], + &[], + true, + tooltips, + text_width_fn, + key_bindings, + ) + } + pub(super) fn build_options_controls( &mut self, sw: f32, @@ -1739,6 +1778,10 @@ impl MainMenu { self.cloud_mode = self.cloud_mode.cycle(); self.save_settings(key_bindings); } + if label.starts_with(NIGHTLY_BUILDS) { + self.nightly_builds = !self.nightly_builds; + self.save_settings(key_bindings); + } if label.starts_with(SHADER_PACK) { self.shader_pack = next_shader_pack(&self.shader_packs_dir, self.shader_pack.as_deref()); @@ -2808,16 +2851,26 @@ mod tests { } } - #[test] - fn entity_shadows_toggle_preserves_saved_key_bindings() { - let dir = - std::env::temp_dir().join(format!("pomme-entity-shadows-{}", uuid::Uuid::new_v4())); + /// A grid whose options save to a folder of its own, gone with the guard. + fn saving_grid(left: &'static str) -> (Grid, impl Drop) { + let dir = std::env::temp_dir().join(format!("pomme-options-{}", uuid::Uuid::new_v4())); std::fs::create_dir(&dir).unwrap(); - let _cleanup = scopeguard::guard((), |_| { + let mut grid = Grid::new(left, "Other"); + grid.menu.settings_dir = dir.clone(); + let cleanup = scopeguard::guard((), move |_| { let _ = std::fs::remove_dir_all(&dir); }); - let mut grid = Grid::new("Entity Shadows: ON", "Other"); - grid.menu.settings_dir = dir.clone(); + (grid, cleanup) + } + + fn saved_settings(grid: &Grid) -> Settings { + let saved = std::fs::read_to_string(grid.menu.settings_dir.join("options.json")).unwrap(); + serde_json::from_str(&saved).unwrap() + } + + #[test] + fn entity_shadows_toggle_preserves_saved_key_bindings() { + let (mut grid, _cleanup) = saving_grid("Entity Shadows: ON"); grid.menu.entity_shadows = true; grid.key_bindings .set(Action::Jump, vec![InputKey::Keyboard(KeyCode::KeyJ)]); @@ -2826,9 +2879,7 @@ mod tests { for enabled in [false, true] { assert!(grid.frame(&click(300.0)).clicked_button); assert_eq!(grid.menu.entity_shadows, enabled); - let saved: Settings = - serde_json::from_str(&std::fs::read_to_string(dir.join("options.json")).unwrap()) - .unwrap(); + let saved = saved_settings(&grid); assert_eq!(saved.entity_shadows, enabled); assert_eq!( serde_json::to_value(&saved.key_bindings).unwrap(), @@ -2837,6 +2888,16 @@ mod tests { } } + #[test] + fn the_nightly_builds_toggle_moves_the_update_channel_and_is_saved() { + let (mut grid, _cleanup) = saving_grid("Nightly Builds: OFF"); + assert_eq!(grid.menu.update_channel(), Channel::Stable); + + assert!(grid.frame(&click(300.0)).clicked_button); + assert_eq!(grid.menu.update_channel(), Channel::Nightly); + assert!(saved_settings(&grid).nightly_builds); + } + #[test] fn mouse_focus_persists_until_another_enabled_option_is_clicked() { let mut grid = Grid::new("First", "Second"); @@ -3004,6 +3065,7 @@ mod tests { menu.build_options_pomme(sw, sh, &input, tw, &key_bindings); menu.build_options_pomme_performance(sw, sh, &input, tw, &key_bindings); menu.build_options_pomme_shaders(sw, sh, &input, tw, &key_bindings); + menu.build_options_pomme_updates(sw, sh, &input, tw, &key_bindings); menu.build_options_controls(sw, sh, &input, tw, &key_bindings); menu.build_options_chat(sw, sh, &input, tw, &key_bindings); menu.build_options_accessibility(sw, sh, &input, tw, &key_bindings); diff --git a/pomme-client/src/update.rs b/pomme-client/src/update.rs index 13597159b..d7a9060d7 100644 --- a/pomme-client/src/update.rs +++ b/pomme-client/src/update.rs @@ -1,14 +1,16 @@ -//! Keeps a release build current: before the menu, a newer `client-v*` -//! release replaces this build's files where they are, and the client +//! Keeps a published build current: before the menu, a newer build on its +//! channel replaces this build's files where they are, and the client //! relaunches into it. use std::path::{Path, PathBuf}; +use std::sync::OnceLock; use std::time::Duration; +use pomme_install::client::Channel; use pomme_install::{Progress, client}; -/// The release this binary was built as (`release-client.yml` sets it); dev -/// and local builds have none and never update. +/// The build this binary was published as (`release-client.yml` sets it); +/// dev and local builds have none and never update. const RELEASE: Option<&str> = option_env!("POMME_RELEASE"); /// Where a new release unpacks before its files move into place. const STAGING: &str = ".pomme-update"; @@ -18,41 +20,49 @@ const REPLACED: &str = "old"; /// Offline, the check gives up this soon rather than hold the menu back. const CHECK_TIMEOUT: Duration = Duration::from_secs(5); -/// This build's `x.y.z` for display, or "dev" for one that isn't a release. +/// This build's version for display, or "dev" for one that wasn't published. pub fn version() -> &'static str { - RELEASE.and_then(client::release_version).unwrap_or("dev") + static VERSION: OnceLock = OnceLock::new(); + VERSION.get_or_init(|| { + RELEASE + .and_then(client::Build::parse) + .map_or_else(|| "dev".to_owned(), |build| build.to_string()) + }) } -/// Whether this launch checks for a newer release. Not when the old launcher -/// started it: that keeps its own copies under `launcher/clients`. +/// Whether this launch checks for a newer build: only a published one's. pub fn enabled(args: &crate::LaunchArgs) -> bool { + RELEASE.is_some() && cfg!(not(mobile)) && wanted(args) +} + +/// Whether `args` leave the update on. Not when the old launcher started the +/// client: that keeps its own copies under `launcher/clients`. +fn wanted(args: &crate::LaunchArgs) -> bool { #[cfg(feature = "test-harness")] if args.harness_script.is_some() { return false; } // A `--chunk-bench` run measures the binary it was started with. - RELEASE.is_some() - && cfg!(not(mobile)) - && args.launch_token.is_none() - && args.chunk_bench.is_none() + !args.no_update && args.launch_token.is_none() && args.chunk_bench.is_none() } -/// Installs a newer release over this one, returning the binary to relaunch, -/// or `None` when this build is current. +/// Installs `channel`'s newest build over this one if it is newer, returning +/// the binary to relaunch, or `None` when this build is current. pub async fn run( + channel: Channel, on_progress: &(dyn Fn(Progress) + Send + Sync), ) -> Result, String> { let Some(ours) = RELEASE else { return Ok(None); }; let http = crate::net::http::client(); - let release = tokio::time::timeout(CHECK_TIMEOUT, client::latest_release(http)) + let release = tokio::time::timeout(CHECK_TIMEOUT, client::latest_release(http, channel)) .await .map_err(|_| "timed out".to_owned())??; - if !client::is_newer(ours, &release.tag_name) { + if !client::is_newer(ours, release.id()) { return Ok(None); } - tracing::info!("Updating from {ours} to {}", release.tag_name); + tracing::info!("Updating from {ours} to {}", release.id()); if let Some(appimage) = appimage() { let file = client::download(http, &release, client::APPIMAGE, on_progress).await?; replace_appimage(&file, &appimage).await?; @@ -166,6 +176,15 @@ mod tests { use super::*; + #[test] + fn a_launch_can_turn_the_update_off() { + let wanted = |words| wanted(&crate::LaunchArgs::from_words(words).unwrap()); + assert!(wanted("")); + assert!(!wanted("--no-update")); + assert!(!wanted("--launch-token abc")); + assert!(!wanted("--chunk-bench 16")); + } + fn release_zip(files: &[(&str, &str)]) -> Vec { let mut zip = zip::ZipWriter::new(std::io::Cursor::new(Vec::new())); for (name, body) in files { diff --git a/pomme-install/src/client.rs b/pomme-install/src/client.rs index 7d51841a4..32e7cece2 100644 --- a/pomme-install/src/client.rs +++ b/pomme-install/src/client.rs @@ -1,6 +1,7 @@ -//! The Pomme client's own builds, published as `client-v*` GitHub releases: -//! finding the newest, and downloading this platform's zip checked against the -//! release's `sha256sums.txt`. +//! The Pomme client's own builds, published as GitHub releases: a `client-v*` +//! one per release and a rolling `nightly` one for master's latest build. +//! Finding the newest on a channel, and downloading this platform's zip +//! checked against the release's `sha256sums.txt`. use std::path::Path; @@ -12,15 +13,83 @@ use crate::{Progress, get}; /// Newest first; listed rather than `/releases/latest`, which held the /// launcher's releases before the client's. const RELEASES_URL: &str = "https://api.github.com/repos/PommeMC/Client/releases?per_page=30"; -const TAG_PREFIX: &str = "client-v"; +const RELEASE_PREFIX: &str = "client-v"; +const NIGHTLY_PREFIX: &str = "nightly-"; +/// The tag of the one release each nightly build replaces. +const NIGHTLY_TAG: &str = "nightly"; const CHECKSUMS_ASSET: &str = "sha256sums.txt"; +/// Which builds a client updates to. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Channel { + /// Releases only. + Stable, + /// Master's latest build too, whichever is newer. + Nightly, +} + +/// A published build, ordered oldest first: release `x.y.z` from +/// `client-vx.y.z+`, or the `n`th build of master after it from +/// `nightly-x.y.z.n+`. A nightly is newer than the release it +/// follows and older than the next one, which is cut from a later master. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct Build { + version: (u32, u32, u32), + /// 0 for a release. + nightly: u32, +} + +impl Build { + pub fn parse(id: &str) -> Option { + let (core, is_nightly) = match id.strip_prefix(RELEASE_PREFIX) { + Some(core) => (core, false), + None => (id.strip_prefix(NIGHTLY_PREFIX)?, true), + }; + let core = core.split_once('+').map_or(core, |(core, _)| core); + let mut parts = core.split('.').map(str::parse); + let version = ( + parts.next()?.ok()?, + parts.next()?.ok()?, + parts.next()?.ok()?, + ); + let nightly = if is_nightly { + parts.next()?.ok().filter(|n| *n > 0)? + } else { + 0 + }; + parts.next().is_none().then_some(Self { version, nightly }) + } +} + +impl std::fmt::Display for Build { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let (major, minor, patch) = self.version; + write!(f, "{major}.{minor}.{patch}")?; + if self.nightly > 0 { + write!(f, "-nightly.{}", self.nightly)?; + } + Ok(()) + } +} + #[derive(Deserialize)] pub struct Release { - pub tag_name: String, + tag_name: String, + name: Option, assets: Vec, } +impl Release { + /// What names the build: the tag, or under the rolling nightly tag the + /// release's name. + pub fn id(&self) -> &str { + match (self.tag_name.as_str(), &self.name) { + (NIGHTLY_TAG, Some(name)) => name, + (tag, _) => tag, + } + } +} + #[derive(Deserialize)] struct Asset { name: String, @@ -41,41 +110,32 @@ pub fn platform_zip() -> Result<&'static str, String> { } } -/// Whether release `theirs` is a later build than `ours`, by the `x.y.z` of -/// `client-vx.y.z+`; never for a tag that doesn't parse. +/// Whether `theirs` is a later build than `ours`; never for an id that +/// doesn't parse. pub fn is_newer(ours: &str, theirs: &str) -> bool { - match (release_core(ours), release_core(theirs)) { + match (Build::parse(ours), Build::parse(theirs)) { (Some(ours), Some(theirs)) => theirs > ours, _ => false, } } -/// The `x.y.z` of a `client-vx.y.z+` tag. -pub fn release_version(tag: &str) -> Option<&str> { - let core = tag.strip_prefix(TAG_PREFIX)?; - Some(core.split_once('+').map_or(core, |(core, _)| core)) -} - -fn release_core(tag: &str) -> Option<(u32, u32, u32)> { - let mut parts = release_version(tag)?.split('.').map(str::parse); - let version = ( - parts.next()?.ok()?, - parts.next()?.ok()?, - parts.next()?.ok()?, - ); - parts.next().is_none().then_some(version) -} - -pub async fn latest_release(http: &reqwest::Client) -> Result { +pub async fn latest_release(http: &reqwest::Client, channel: Channel) -> Result { let releases: Vec = get(http, RELEASES_URL) .await? .json() .await .map_err(|e| e.to_string())?; + newest(releases, channel).ok_or_else(|| "No client release found".to_owned()) +} + +/// The newest build among `releases` that `channel` takes. +fn newest(releases: Vec, channel: Channel) -> Option { releases .into_iter() - .find(|r| r.tag_name.starts_with(TAG_PREFIX)) - .ok_or_else(|| "No client release found".to_owned()) + .filter_map(|release| Some((Build::parse(release.id())?, release))) + .filter(|(build, _)| channel == Channel::Nightly || build.nightly == 0) + .max_by_key(|(build, _)| *build) + .map(|(_, release)| release) } /// File `name` of `release`, refused unless it matches the release's @@ -91,7 +151,7 @@ pub async fn download( .assets .iter() .find(|a| a.name == name) - .ok_or_else(|| format!("Release {} has no {name}", release.tag_name)) + .ok_or_else(|| format!("Release {} has no {name}", release.id())) }; let sums = get(http, &asset(CHECKSUMS_ASSET)?.browser_download_url) .await? @@ -179,10 +239,85 @@ mod tests { } #[test] - fn the_version_drops_the_minecraft_part() { - assert_eq!(release_version("client-v0.2.8+26.2"), Some("0.2.8")); - assert_eq!(release_version("client-v0.2.8"), Some("0.2.8")); - assert_eq!(release_version("launcher-v0.1.2"), None); + fn a_nightly_sits_between_the_release_it_follows_and_the_next() { + let (release, nightly) = ("client-v0.2.12+26.2", "nightly-0.2.12.345+26.2"); + assert!(is_newer(release, nightly)); + assert!(is_newer(nightly, "nightly-0.2.12.346+26.2")); + assert!(is_newer(nightly, "client-v0.2.13+26.2")); + assert!(!is_newer(nightly, release)); + assert!(!is_newer(nightly, nightly)); + // A nightly names the run that built it. + assert!(!is_newer(release, "nightly-0.2.12+26.2")); + assert!(!is_newer(release, "nightly-0.2.12.0+26.2")); + assert!(!is_newer(release, "nightly")); + } + + #[test] + fn a_build_shows_as_its_version() { + let shown = |id| Build::parse(id).map(|build| build.to_string()); + assert_eq!(shown("client-v0.2.8+26.2").as_deref(), Some("0.2.8")); + assert_eq!(shown("client-v0.2.8").as_deref(), Some("0.2.8")); + assert_eq!( + shown("nightly-0.2.8.345+26.2").as_deref(), + Some("0.2.8-nightly.345") + ); + assert_eq!(shown("launcher-v0.1.2"), None); + } + + /// The id of the newest build `channel` takes from GitHub's `listed`. + fn newest_id(listed: &str, channel: Channel) -> Option { + let releases: Vec = serde_json::from_str(listed).unwrap(); + newest(releases, channel).map(|release| release.id().to_owned()) + } + + #[test] + fn a_channel_takes_its_newest_build() { + // As GitHub lists them: the rolling nightly, recreated each night, + // then the releases newest first. + let listed = r#"[ + {"tag_name": "nightly", "name": "nightly-0.2.12.345+26.2", "assets": []}, + {"tag_name": "client-v0.2.12+26.2", "name": "client-v0.2.12+26.2", "assets": []}, + {"tag_name": "client-v0.2.11+26.2", "name": null, "assets": []}, + {"tag_name": "launcher-v0.1.2", "name": null, "assets": []} + ]"#; + assert_eq!( + newest_id(listed, Channel::Stable).as_deref(), + Some("client-v0.2.12+26.2") + ); + assert_eq!( + newest_id(listed, Channel::Nightly).as_deref(), + Some("nightly-0.2.12.345+26.2") + ); + } + + #[test] + fn the_newest_build_is_the_highest_however_they_are_listed() { + let listed = r#"[ + {"tag_name": "client-v0.2.11+26.2", "name": null, "assets": []}, + {"tag_name": "client-v0.2.12+26.2", "name": null, "assets": []} + ]"#; + assert_eq!( + newest_id(listed, Channel::Stable).as_deref(), + Some("client-v0.2.12+26.2") + ); + } + + #[test] + fn the_nightly_channel_takes_a_release_newer_than_the_nightly() { + let listed = r#"[ + {"tag_name": "client-v0.2.13+26.2", "name": null, "assets": []}, + {"tag_name": "nightly", "name": "nightly-0.2.12.345+26.2", "assets": []} + ]"#; + assert_eq!( + newest_id(listed, Channel::Nightly).as_deref(), + Some("client-v0.2.13+26.2") + ); + } + + #[test] + fn no_release_is_no_build() { + let listed = r#"[{"tag_name": "launcher-v0.1.2", "name": null, "assets": []}]"#; + assert_eq!(newest_id(listed, Channel::Nightly), None); } #[test] diff --git a/tests/ingame/ui/pomme_settings.toml b/tests/ingame/ui/pomme_settings.toml index 1443ae68d..39dcc03bd 100644 --- a/tests/ingame/ui/pomme_settings.toml +++ b/tests/ingame/ui/pomme_settings.toml @@ -1,6 +1,6 @@ # Pomme's own settings (Pomme-only): a button under the Options grid opens # them, one screen per category. Performance holds Chunk Detail and Distant -# Terrain, Shaders holds Shader Pack. +# Terrain, Shaders holds Shader Pack, Updates holds Nightly Builds. pomme_only = true @@ -119,6 +119,67 @@ mouse_up = "left" [[step]] wait_ms = 300 +[[step]] +cursor_to_button = "Updates..." + +[[step]] +mouse_down = "left" + +[[step]] +mouse_up = "left" + +[[step]] +wait_ms = 300 + +[[step]] +cursor_to_button = "Nightly Builds: OFF" + +[[step]] +wait_ms = 300 + +[[step]] +screenshot = "updates" + +[[step]] +mouse_down = "left" + +[[step]] +mouse_up = "left" + +[[step]] +cursor = [213, 200] + +[[step]] +wait_ms = 300 + +[[step]] +screenshot = "nightly_on" + +# Back off, since the options save. +[[step]] +cursor_to_button = "Nightly Builds: ON" + +[[step]] +mouse_down = "left" + +[[step]] +mouse_up = "left" + +[[step]] +wait_ms = 300 + +[[step]] +cursor_to_button = "Done" + +[[step]] +mouse_down = "left" + +[[step]] +mouse_up = "left" + +[[step]] +wait_ms = 300 + # Back out of Pomme Settings, then Options. [[step]] cursor_to_button = "Done"