From 2acd98248b801b3b2a9517cde7480af29b738547 Mon Sep 17 00:00:00 2001 From: Andrew Houts <16907671+ahouts@users.noreply.github.com> Date: Fri, 2 Jul 2021 11:00:46 -0700 Subject: [PATCH] style: enforce ALL_MODULES ordering in test (#2837) * style: enforce ALL_MODULES ordering in test * use unstable sort * use copied instead of dereferencing in iterator --- src/module.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/module.rs b/src/module.rs index 67b0f5d0..7beb1305 100644 --- a/src/module.rs +++ b/src/module.rs @@ -6,7 +6,6 @@ use std::fmt; use std::time::Duration; // List of all modules -// Keep these ordered alphabetically. // Default ordering is handled in configs/starship_root.rs pub const ALL_MODULES: &[&str] = &[ "aws", @@ -16,6 +15,7 @@ pub const ALL_MODULES: &[&str] = &[ "cmake", "cmd_duration", "conda", + "crystal", "dart", "deno", "directory", @@ -23,8 +23,8 @@ pub const ALL_MODULES: &[&str] = &[ "dotnet", "elixir", "elm", - "erlang", "env_var", + "erlang", "gcloud", "git_branch", "git_commit", @@ -35,7 +35,6 @@ pub const ALL_MODULES: &[&str] = &[ "hg_branch", "hostname", "java", - "scala", "jobs", "julia", "kotlin", @@ -50,24 +49,24 @@ pub const ALL_MODULES: &[&str] = &[ "openstack", "package", "perl", + "php", "purescript", "python", - "rlang", "red", + "rlang", "ruby", - "crystal", "rust", - "php", - "swift", - "terraform", + "scala", "shell", "shlvl", "singularity", "status", + "swift", + "terraform", "time", "username", - "vcsh", "vagrant", + "vcsh", "vlang", "zig", ]; @@ -177,6 +176,13 @@ fn ansi_strings_modified(ansi_strings: Vec, shell: Shell) -> Vec = ALL_MODULES.iter().copied().collect(); + sorted_modules.sort_unstable(); + assert_eq!(sorted_modules.as_slice(), ALL_MODULES); + } + #[test] fn test_module_is_empty_with_no_segments() { let name = "unit_test";