diff --git a/Cargo.lock b/Cargo.lock index 1e3c8954..f5d04fc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -466,6 +466,11 @@ name = "numtoa" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "once_cell" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "openssl-probe" version = "0.1.2" @@ -756,8 +761,8 @@ dependencies = [ "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "gethostname 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "path-slash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1031,6 +1036,7 @@ dependencies = [ "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" +"checksum once_cell 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a04cb71e910d0034815600180f62a95bf6e67942d7ab52a166a68c7d7e9cd0" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)" = "05636e06b4f8762d4b81d24a351f3966f38bd25ccbcfd235606c91fdb82cc60f" "checksum path-slash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a0858af4d9136275541f4eac7be1af70add84cf356d901799b065ac1b8ff6e2f" diff --git a/Cargo.toml b/Cargo.toml index 8af9c898..93272f10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,10 +37,10 @@ log = "0.4.8" # battery is optional (on by default) because the crate doesn't currently build for Termux # see: https://github.com/svartalf/rust-battery/issues/33 battery = { version = "0.7.4", optional = true } -lazy_static = "1.4.0" path-slash = "0.1.1" unicode-segmentation = "1.3.0" gethostname = "0.2.0" +once_cell = "1.1.0" [dev-dependencies] tempfile = "3.1.0" diff --git a/src/context.rs b/src/context.rs index 6ccda849..836a18db 100644 --- a/src/context.rs +++ b/src/context.rs @@ -2,11 +2,12 @@ use crate::config::Config; use crate::module::Module; use clap::ArgMatches; -use git2::Repository; +use git2::{Repository, RepositoryState}; +use once_cell::sync::OnceCell; use std::env; use std::ffi::OsStr; use std::fs; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; /// Context contains data or common methods that may be used by multiple modules. /// The data contained within Context will be relevant to this particular rendering @@ -24,13 +25,8 @@ pub struct Context<'a> { /// The map of arguments that were passed when starship was called. pub arguments: ArgMatches<'a>, - /// If `current_dir` is a git repository or is contained within one, - /// this is the path to the root of that repo. - pub repo_root: Option, - - /// If `current_dir` is a git repository or is contained within one, - /// this is the current branch name of that repo. - pub branch_name: Option, + /// Private field to store Git information for modules who need it + repo: OnceCell, } impl<'a> Context<'a> { @@ -67,21 +63,12 @@ impl<'a> Context<'a> { .map(|entry| entry.path()) .collect::>(); - let repository = Repository::discover(¤t_dir).ok(); - let repo_root = repository - .as_ref() - .and_then(|repo| repo.workdir().map(std::path::Path::to_path_buf)); - let branch_name = repository - .as_ref() - .and_then(|repo| get_current_branch(repo)); - Context { config, arguments, current_dir, dir_files, - repo_root, - branch_name, + repo: OnceCell::new(), } } @@ -95,20 +82,20 @@ impl<'a> Context<'a> { } /// Create a new module - /// - /// Will return `None` if the module is disabled by configuration, by setting - /// the `disabled` key to `true` in the configuration for that module. - pub fn new_module(&self, name: &str) -> Option { + pub fn new_module(&self, name: &str) -> Module { + let config = self.config.get_module_config(name); + + Module::new(name, config) + } + + /// Check the `disabled` configuration of the module + pub fn is_module_enabled(&self, name: &str) -> bool { let config = self.config.get_module_config(name); // If the segment has "disabled" set to "true", don't show it let disabled = config.and_then(|table| table.get_as_bool("disabled")); - if disabled == Some(true) { - return None; - } - - Some(Module::new(name, config)) + disabled != Some(true) } // returns a new ScanDir struct with reference to current dir_files of context @@ -121,6 +108,43 @@ impl<'a> Context<'a> { extensions: &[], } } + + /// Will lazily get repo root and branch when a module requests it. + pub fn get_repo(&self) -> Result<&Repo, std::io::Error> { + let repo = self + .repo + .get_or_try_init(|| -> Result { + let repository = Repository::discover(&self.current_dir).ok(); + let branch = repository + .as_ref() + .and_then(|repo| get_current_branch(repo)); + let root = repository + .as_ref() + .and_then(|repo| repo.workdir().map(Path::to_path_buf)); + let state = repository.as_ref().map(|repo| repo.state()); + + Ok(Repo { + branch, + root, + state, + }) + })?; + + Ok(repo) + } +} + +pub struct Repo { + /// If `current_dir` is a git repository or is contained within one, + /// this is the current branch name of that repo. + pub branch: Option, + + /// If `current_dir` is a git repository or is contained within one, + /// this is the path to the root of that repo. + pub root: Option, + + /// State + pub state: Option, } // A struct of Criteria which will be used to verify current PathBuf is diff --git a/src/modules/battery.rs b/src/modules/battery.rs index 47c9eee7..81edfbf0 100644 --- a/src/modules/battery.rs +++ b/src/modules/battery.rs @@ -29,7 +29,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { } // TODO: Set style based on percentage when threshold is modifiable - let mut module = context.new_module("battery")?; + let mut module = context.new_module("battery"); let module_style = module .config_value_style("style") .unwrap_or_else(|| Color::Red.bold()); diff --git a/src/modules/character.rs b/src/modules/character.rs index 704fe5c9..9385e53c 100644 --- a/src/modules/character.rs +++ b/src/modules/character.rs @@ -20,7 +20,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { const ASSUMED_MODE: ShellEditMode = ShellEditMode::Insert; // TODO: extend config to more modes - let mut module = context.new_module("character")?; + let mut module = context.new_module("character"); module.get_prefix().set_value(""); let style_success = module diff --git a/src/modules/cmd_duration.rs b/src/modules/cmd_duration.rs index ac710228..35a7e685 100644 --- a/src/modules/cmd_duration.rs +++ b/src/modules/cmd_duration.rs @@ -7,7 +7,7 @@ use super::{Context, Module}; /// Will only print if last command took more than a certain amount of time to /// execute. Default is two seconds, but can be set by config option `min_time`. pub fn module<'a>(context: &'a Context) -> Option> { - let mut module = context.new_module("cmd_duration")?; + let mut module = context.new_module("cmd_duration"); let arguments = &context.arguments; let elapsed = arguments diff --git a/src/modules/directory.rs b/src/modules/directory.rs index 95270126..096b0764 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -18,7 +18,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { const DIR_TRUNCATION_LENGTH: i64 = 3; const FISH_STYLE_PWD_DIR_LENGTH: i64 = 0; - let mut module = context.new_module("directory")?; + let mut module = context.new_module("directory"); let module_color = module .config_value_style("style") .unwrap_or_else(|| Color::Cyan.bold()); @@ -36,7 +36,9 @@ pub fn module<'a>(context: &'a Context) -> Option> { let current_dir = &context.current_dir; log::debug!("Current directory: {:?}", current_dir); - let dir_string = match &context.repo_root { + let repo = &context.get_repo().ok()?; + + let dir_string = match &repo.root { Some(repo_root) if truncate_to_repo => { let repo_folder_name = repo_root.file_name().unwrap().to_str().unwrap(); diff --git a/src/modules/git_branch.rs b/src/modules/git_branch.rs index d6b64c4e..6d07e890 100644 --- a/src/modules/git_branch.rs +++ b/src/modules/git_branch.rs @@ -9,7 +9,7 @@ use super::{Context, Module}; pub fn module<'a>(context: &'a Context) -> Option> { const GIT_BRANCH_CHAR: &str = "๎‚  "; - let mut module = context.new_module("git_branch")?; + let mut module = context.new_module("git_branch"); let segment_color = module .config_value_style("style") @@ -38,7 +38,8 @@ pub fn module<'a>(context: &'a Context) -> Option> { } else { unsafe_truncation_length as usize }; - let branch_name = context.branch_name.as_ref()?; + let repo = context.get_repo().ok()?; + let branch_name = repo.branch.as_ref()?; let truncated_graphemes = get_graphemes(&branch_name, len); // The truncation symbol should only be added if we truncated let truncated_and_symbol = if len < graphemes_len(&branch_name) { diff --git a/src/modules/git_state.rs b/src/modules/git_state.rs index 8d242b0c..c26a6007 100644 --- a/src/modules/git_state.rs +++ b/src/modules/git_state.rs @@ -1,6 +1,6 @@ use ansi_term::Color; -use git2::{Repository, RepositoryState}; -use std::path::Path; +use git2::RepositoryState; +use std::path::{Path, PathBuf}; use super::{Context, Module}; @@ -9,11 +9,12 @@ use super::{Context, Module}; /// During a git operation it will show: REBASING, BISECTING, MERGING, etc. /// If the progress information is available (e.g. rebasing 3/10), it will show that too. pub fn module<'a>(context: &'a Context) -> Option> { - let mut module = context.new_module("git_state")?; + let mut module = context.new_module("git_state"); - let repo_root = context.repo_root.as_ref()?; - let mut repository = Repository::open(repo_root).ok()?; - let state_description = get_state_description(&mut repository); + let repo = context.get_repo().ok()?; + let repo_root = repo.root.as_ref()?; + let repo_state = repo.state?; + let state_description = get_state_description(repo_state, repo_root); if let StateDescription::Clean = state_description { return None; @@ -79,8 +80,11 @@ static AM_OR_REBASE_LABEL: StateLabel = StateLabel { message_default: "AM/REBASE", }; -fn get_state_description(repository: &mut Repository) -> StateDescription { - match repository.state() { +/// Returns the state of the current repository +/// +/// During a git operation it will show: REBASING, BISECTING, MERGING, etc. +fn get_state_description(state: RepositoryState, root: &PathBuf) -> StateDescription { + match state { RepositoryState::Clean => StateDescription::Clean, RepositoryState::Merge => StateDescription::Label(&MERGE_LABEL), RepositoryState::Revert => StateDescription::Label(&REVERT_LABEL), @@ -90,13 +94,13 @@ fn get_state_description(repository: &mut Repository) -> StateDescription { RepositoryState::Bisect => StateDescription::Label(&BISECT_LABEL), RepositoryState::ApplyMailbox => StateDescription::Label(&AM_LABEL), RepositoryState::ApplyMailboxOrRebase => StateDescription::Label(&AM_OR_REBASE_LABEL), - RepositoryState::Rebase => describe_rebase(repository), - RepositoryState::RebaseInteractive => describe_rebase(repository), - RepositoryState::RebaseMerge => describe_rebase(repository), + RepositoryState::Rebase => describe_rebase(root), + RepositoryState::RebaseInteractive => describe_rebase(root), + RepositoryState::RebaseMerge => describe_rebase(root), } } -fn describe_rebase(repository: &mut Repository) -> StateDescription { +fn describe_rebase(root: &PathBuf) -> StateDescription { /* * Sadly, libgit2 seems to have some issues with reading the state of * interactive rebases. So, instead, we'll poke a few of the .git files @@ -107,18 +111,7 @@ fn describe_rebase(repository: &mut Repository) -> StateDescription { let just_label = StateDescription::Label(&REBASE_LABEL); - let dot_git = repository - .workdir() - .and_then(|d| Some(d.join(Path::new(".git")))); - - let dot_git = match dot_git { - None => { - // We didn't find the .git directory. - // Something very odd is going on. We'll just back away slowly. - return just_label; - } - Some(path) => path, - }; + let dot_git = root.join(".git"); let has_path = |relative_path: &str| { let path = dot_git.join(Path::new(relative_path)); diff --git a/src/modules/git_status.rs b/src/modules/git_status.rs index aa82fb73..badf0fac 100644 --- a/src/modules/git_status.rs +++ b/src/modules/git_status.rs @@ -30,11 +30,12 @@ pub fn module<'a>(context: &'a Context) -> Option> { const GIT_STATUS_RENAMED: &str = "ยป"; const GIT_STATUS_DELETED: &str = "โœ˜"; - let branch_name = context.branch_name.as_ref()?; - let repo_root = context.repo_root.as_ref()?; + let repo = context.get_repo().ok()?; + let branch_name = repo.branch.as_ref()?; + let repo_root = repo.root.as_ref()?; let repository = Repository::open(repo_root).ok()?; - let mut module = context.new_module("git_status")?; + let mut module = context.new_module("git_status"); let show_sync_count = module.config_value_bool("show_sync_count").unwrap_or(false); let module_style = module .config_value_style("style") @@ -133,10 +134,10 @@ pub fn module<'a>(context: &'a Context) -> Option> { } if module.is_empty() { - None - } else { - Some(module) + return None; } + + Some(module) } /// Gets the bitflags associated with the repo's git status diff --git a/src/modules/golang.rs b/src/modules/golang.rs index bf632bf7..4676f9e6 100644 --- a/src/modules/golang.rs +++ b/src/modules/golang.rs @@ -29,7 +29,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { Some(go_version) => { const GO_CHAR: &str = "๐Ÿน "; - let mut module = context.new_module("golang")?; + let mut module = context.new_module("golang"); let module_style = module .config_value_style("style") .unwrap_or_else(|| Color::Cyan.bold()); diff --git a/src/modules/hostname.rs b/src/modules/hostname.rs index 9b0690d8..d71f733f 100644 --- a/src/modules/hostname.rs +++ b/src/modules/hostname.rs @@ -10,7 +10,7 @@ use std::ffi::OsString; /// - hostname.disabled is absent or false /// - hostname.ssh_only is false OR the user is currently connected as an SSH session (`$SSH_CONNECTION`) pub fn module<'a>(context: &'a Context) -> Option> { - let mut module = context.new_module("hostname")?; + let mut module = context.new_module("hostname"); let module_style = module .config_value_style("style") .unwrap_or_else(|| Color::Green.bold().dimmed()); diff --git a/src/modules/jobs.rs b/src/modules/jobs.rs index bb8a2d7d..8a667049 100644 --- a/src/modules/jobs.rs +++ b/src/modules/jobs.rs @@ -4,7 +4,7 @@ use super::{Context, Module}; /// Creates a segment to show if there are any active jobs running pub fn module<'a>(context: &'a Context) -> Option> { - let mut module = context.new_module("jobs")?; + let mut module = context.new_module("jobs"); let threshold = module.config_value_i64("threshold").unwrap_or(1); diff --git a/src/modules/line_break.rs b/src/modules/line_break.rs index 5cbe3a1a..259e6087 100644 --- a/src/modules/line_break.rs +++ b/src/modules/line_break.rs @@ -4,7 +4,7 @@ use super::{Context, Module}; pub fn module<'a>(context: &'a Context) -> Option> { const LINE_ENDING: &str = "\n"; - let mut module = context.new_module("line_break")?; + let mut module = context.new_module("line_break"); module.get_prefix().set_value(""); module.get_suffix().set_value(""); diff --git a/src/modules/nix_shell.rs b/src/modules/nix_shell.rs index 5fc98dfc..36228993 100644 --- a/src/modules/nix_shell.rs +++ b/src/modules/nix_shell.rs @@ -22,7 +22,7 @@ use super::{Context, Module}; /// - pure // use_name == false in a pure nix-shell /// - impure // use_name == false in an impure nix-shell pub fn module<'a>(context: &'a Context) -> Option> { - let mut module = context.new_module("nix_shell")?; + let mut module = context.new_module("nix_shell"); env::var("IN_NIX_SHELL") .ok() diff --git a/src/modules/nodejs.rs b/src/modules/nodejs.rs index 8f8219c7..180e143f 100644 --- a/src/modules/nodejs.rs +++ b/src/modules/nodejs.rs @@ -25,7 +25,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { Some(node_version) => { const NODE_CHAR: &str = "โฌข "; - let mut module = context.new_module("nodejs")?; + let mut module = context.new_module("nodejs"); let module_style = module .config_value_style("style") .unwrap_or_else(|| Color::Green.bold()); diff --git a/src/modules/package.rs b/src/modules/package.rs index ceb34bc6..0debe162 100644 --- a/src/modules/package.rs +++ b/src/modules/package.rs @@ -13,7 +13,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { Some(package_version) => { const PACKAGE_CHAR: &str = "๐Ÿ“ฆ "; - let mut module = context.new_module("package")?; + let mut module = context.new_module("package"); let module_style = module .config_value_style("style") .unwrap_or_else(|| Color::Red.bold()); diff --git a/src/modules/python.rs b/src/modules/python.rs index 61d8189d..487d033d 100644 --- a/src/modules/python.rs +++ b/src/modules/python.rs @@ -30,7 +30,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { return None; } - let mut module = context.new_module("python")?; + let mut module = context.new_module("python"); let pyenv_version_name = module .config_value_bool("pyenv_version_name") .unwrap_or(false); diff --git a/src/modules/ruby.rs b/src/modules/ruby.rs index a39bda75..7e689234 100644 --- a/src/modules/ruby.rs +++ b/src/modules/ruby.rs @@ -23,7 +23,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { Some(ruby_version) => { const RUBY_CHAR: &str = "๐Ÿ’Ž "; - let mut module = context.new_module("ruby")?; + let mut module = context.new_module("ruby"); let module_style = module .config_value_style("style") .unwrap_or_else(|| Color::Red.bold()); diff --git a/src/modules/rust.rs b/src/modules/rust.rs index 401f6e4c..26ee377c 100644 --- a/src/modules/rust.rs +++ b/src/modules/rust.rs @@ -23,7 +23,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { Some(rust_version) => { const RUST_CHAR: &str = "๐Ÿฆ€ "; - let mut module = context.new_module("rust")?; + let mut module = context.new_module("rust"); let module_style = module .config_value_style("style") .unwrap_or_else(|| Color::Red.bold()); diff --git a/src/modules/username.rs b/src/modules/username.rs index 07ecc5b1..c2789698 100644 --- a/src/modules/username.rs +++ b/src/modules/username.rs @@ -18,7 +18,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { const ROOT_UID: Option = Some(0); let user_uid = get_uid(); if user != logname || ssh_connection.is_some() || user_uid == ROOT_UID { - let mut module = context.new_module("username")?; + let mut module = context.new_module("username"); let module_style = get_mod_style(user_uid, &module); module.set_style(module_style); module.new_segment("username", &user?); diff --git a/src/print.rs b/src/print.rs index 1ea1648f..2b730e25 100644 --- a/src/print.rs +++ b/src/print.rs @@ -81,6 +81,7 @@ pub fn prompt(args: ArgMatches) { let modules = &prompt_order .par_iter() + .filter(|module| context.is_module_enabled(module)) .map(|module| modules::handle(module, &context)) // Compute modules .flatten() .collect::>(); // Remove segments set to `None` diff --git a/tests/testsuite/cmd_duration.rs b/tests/testsuite/cmd_duration.rs index a8279032..287944cb 100644 --- a/tests/testsuite/cmd_duration.rs +++ b/tests/testsuite/cmd_duration.rs @@ -58,20 +58,3 @@ fn config_5s_duration_10s() -> io::Result<()> { assert_eq!(expected, actual); Ok(()) } - -#[test] -fn config_disabled() -> io::Result<()> { - let output = common::render_module("cmd_duration") - .use_config(toml::toml! { - [cmd_duration] - disabled = true - min_time = 5 - }) - .arg("--cmd-duration=10") - .output()?; - let actual = String::from_utf8(output.stdout).unwrap(); - - let expected = ""; - assert_eq!(expected, actual); - Ok(()) -} diff --git a/tests/testsuite/common.rs b/tests/testsuite/common.rs index babe43a1..e06f5af4 100644 --- a/tests/testsuite/common.rs +++ b/tests/testsuite/common.rs @@ -1,15 +1,12 @@ -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::io::prelude::*; use std::io::{Error, ErrorKind}; use std::path::{Path, PathBuf}; use std::process::Command; use std::{env, fs, io, process}; -lazy_static! { - static ref MANIFEST_DIR: &'static Path = Path::new(env!("CARGO_MANIFEST_DIR")); - pub static ref FIXTURES_DIR: PathBuf = MANIFEST_DIR.join("tests/fixtures"); - static ref EMPTY_CONFIG: PathBuf = MANIFEST_DIR.join("empty_config.toml"); -} +static MANIFEST_DIR: Lazy<&'static Path> = Lazy::new(|| Path::new(env!("CARGO_MANIFEST_DIR"))); +static EMPTY_CONFIG: Lazy = Lazy::new(|| MANIFEST_DIR.join("empty_config.toml")); /// Render the full starship prompt pub fn render_prompt() -> process::Command { diff --git a/tests/testsuite/configuration.rs b/tests/testsuite/configuration.rs index a9daefb6..6d058be9 100644 --- a/tests/testsuite/configuration.rs +++ b/tests/testsuite/configuration.rs @@ -19,20 +19,6 @@ fn char_symbol_configuration() -> io::Result<()> { Ok(()) } -#[test] -fn disabled_module() -> io::Result<()> { - let output = common::render_module("package") - .use_config(toml::toml! { - [package] - disabled = true - }) - .output()?; - let actual = String::from_utf8(output.stdout).unwrap(); - assert_eq!("", actual); - - Ok(()) -} - #[test] fn add_newline_configuration() -> io::Result<()> { // Start prompt with newline diff --git a/tests/testsuite/git_branch.rs b/tests/testsuite/git_branch.rs index ab1cc3c9..095615f8 100644 --- a/tests/testsuite/git_branch.rs +++ b/tests/testsuite/git_branch.rs @@ -1,6 +1,5 @@ use ansi_term::Color; use git2::Repository; -use std::env; use std::io; use std::process::Command; diff --git a/tests/testsuite/git_status.rs b/tests/testsuite/git_status.rs index e2be95c2..3a2626b1 100644 --- a/tests/testsuite/git_status.rs +++ b/tests/testsuite/git_status.rs @@ -1,6 +1,5 @@ use ansi_term::Color; use git2::Repository; -use std::env; use std::fs::{self, File}; use std::io; use std::process::Command; diff --git a/tests/testsuite/golang.rs b/tests/testsuite/golang.rs index b5d37bc1..a2c50e72 100644 --- a/tests/testsuite/golang.rs +++ b/tests/testsuite/golang.rs @@ -2,7 +2,7 @@ use ansi_term::Color; use std::fs::{self, File}; use std::io; -use crate::common::{self, TestCommand}; +use crate::common; #[test] fn folder_without_go_files() -> io::Result<()> { @@ -138,24 +138,3 @@ fn folder_with_gopkg_lock() -> io::Result<()> { assert_eq!(expected, actual); Ok(()) } - -#[test] -#[ignore] -fn config_disabled() -> io::Result<()> { - let dir = common::new_tempdir()?; - File::create(dir.path().join("main.go"))?; - - let output = common::render_module("golang") - .use_config(toml::toml! { - [golang] - disabled = true - }) - .arg("--path") - .arg(dir.path()) - .output()?; - let actual = String::from_utf8(output.stdout).unwrap(); - - let expected = ""; - assert_eq!(expected, actual); - Ok(()) -} diff --git a/tests/testsuite/jobs.rs b/tests/testsuite/jobs.rs index b69e3803..cfdd1e9d 100644 --- a/tests/testsuite/jobs.rs +++ b/tests/testsuite/jobs.rs @@ -64,19 +64,3 @@ fn config_2_job_3() -> io::Result<()> { assert_eq!(expected, actual); Ok(()) } - -#[test] -fn config_disabled() -> io::Result<()> { - let output = common::render_module("jobs") - .use_config(toml::toml! { - [jobs] - disabled = true - }) - .arg("--jobs=1") - .output()?; - let actual = String::from_utf8(output.stdout).unwrap(); - - let expected = ""; - assert_eq!(expected, actual); - Ok(()) -} diff --git a/tests/testsuite/nodejs.rs b/tests/testsuite/nodejs.rs index bea6248a..33b0df2a 100644 --- a/tests/testsuite/nodejs.rs +++ b/tests/testsuite/nodejs.rs @@ -2,7 +2,7 @@ use ansi_term::Color; use std::fs::{self, File}; use std::io; -use crate::common::{self, TestCommand}; +use crate::common; #[test] fn folder_without_node_files() -> io::Result<()> { @@ -70,24 +70,3 @@ fn folder_with_node_modules() -> io::Result<()> { assert_eq!(expected, actual); Ok(()) } - -#[test] -#[ignore] -fn config_disabled() -> io::Result<()> { - let dir = common::new_tempdir()?; - File::create(dir.path().join("package.json"))?; - - let output = common::render_module("nodejs") - .use_config(toml::toml! { - [nodejs] - disabled = true - }) - .arg("--path") - .arg(dir.path()) - .output()?; - let actual = String::from_utf8(output.stdout).unwrap(); - - let expected = ""; - assert_eq!(expected, actual); - Ok(()) -}