summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Knaack <davidkna@users.noreply.github.com>2020-03-15 18:12:25 +0100
committerGitHub <noreply@github.com>2020-03-15 12:12:25 -0500
commit56d475578ea508631275772127f49a6949fea6b0 (patch)
tree980e2bc8d4057a5ab32aad3bfe739e54135eff67
parentfef8cc8bbdbaaae4dd0f80d4c2643c33e2309c54 (diff)
fix: possible fix for Intermittent Test Failures in GH Actions (#987)
* fix: possible fix for Intermittent Test Failures in GH Actions * undo some of the chnages to directory.rs * typo * add docs
-rw-r--r--CONTRIBUTING.md8
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml4
-rw-r--r--src/context.rs4
-rw-r--r--src/modules/crystal.rs9
-rw-r--r--src/modules/elixir.rs4
-rw-r--r--src/modules/elm.rs10
-rw-r--r--src/modules/golang.rs16
-rw-r--r--src/modules/haskell.rs8
-rw-r--r--src/modules/nodejs.rs8
-rw-r--r--src/modules/php.rs6
-rw-r--r--src/modules/ruby.rs6
-rw-r--r--tests/testsuite/aws.rs4
-rw-r--r--tests/testsuite/common.rs7
-rw-r--r--tests/testsuite/directory.rs16
-rw-r--r--tests/testsuite/dotnet.rs27
-rw-r--r--tests/testsuite/git_branch.rs5
-rw-r--r--tests/testsuite/git_commit.rs17
-rw-r--r--tests/testsuite/git_status.rs95
-rw-r--r--tests/testsuite/hg_branch.rs18
-rw-r--r--tests/testsuite/python.rs16
-rw-r--r--tests/testsuite/terraform.rs9
22 files changed, 169 insertions, 129 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4fa8af11d..69b74320e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -80,6 +80,14 @@ Integration tests should test full modules or the entire prompt. All integration
For tests that depend on having preexisting state, whatever needed state will have to be added to the project's GitHub Actions workflow file([`.github/workflows/workflow.yml`](.github/workflows/workflow.yml)).
+### Test Programming Guidelines
+
+Any tests that depend on File I/O should use [`sync_all()`](https://doc.rust-lang.org/std/fs/struct.File.html#method.sync_all) when creating files or after writing to files.
+
+Any tests that use `tempfile::tempdir` should take care to call `dir.close()` after usage to ensure the lifecycle of the directory can be reasoned about.
+
+Any tests that use `create_fixture_repo()` should remove the returned directory after usage with `remove_dir_all::remove_dir_all()`.
+
## Running the Documentation Website Locally
If you are contributing to the design of Starship's website, the following section will help you get started.
diff --git a/Cargo.lock b/Cargo.lock
index 3dde5f51a..efeb5d471 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -912,6 +912,7 @@ dependencies = [
"pretty_env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
"starship_module_config_derive 0.1.1",
"sysinfo 0.11.7 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index 5f49645ea..c08e2880c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -64,6 +64,10 @@ native-tls = { version = "0.2", optional = true }
[dev-dependencies]
tempfile = "3.1.0"
+# More realiable than std::fs version on Windows
+# For removing temporary directories manually when needed
+# This is what tempfile uses to delete temporary directories
+remove_dir_all = "0.5.2"
[profile.release]
codegen-units = 1
diff --git a/src/context.rs b/src/context.rs
index b8cea1912..11cc911d9 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -350,6 +350,7 @@ mod tests {
.is_match(),
false
);
+ empty.close()?;
let rust = testdir(&["README.md", "Cargo.toml", "src/main.rs"])?;
let rust_dc = DirContents::from_path(&PathBuf::from(rust.path()))?;
@@ -363,6 +364,7 @@ mod tests {
.is_match(),
false
);
+ rust.close()?;
let java = testdir(&["README.md", "src/com/test/Main.java", "pom.xml"])?;
let java_dc = DirContents::from_path(&PathBuf::from(java.path()))?;
@@ -376,6 +378,7 @@ mod tests {
.is_match(),
false
);
+ java.close()?;
let node = testdir(&["README.md", "node_modules/lodash/main.js", "package.json"])?;
let node_dc = DirContents::from_path(&PathBuf::from(node.path()))?;
@@ -389,6 +392,7 @@ mod tests {
.is_match(),
true
);
+ node.close()?;
Ok(())
}
diff --git a/src/modules/crystal.rs b/src/modules/crystal.rs
index a215369cb..2243514ce 100644
--- a/src/modules/crystal.rs
+++ b/src/modules/crystal.rs
@@ -59,7 +59,8 @@ mod tests {
let actual = render_module("crystal", dir.path());
let expected = None;
assert_eq!(expected, actual);
- Ok(())
+
+ dir.close()
}
#[test]
@@ -70,7 +71,8 @@ mod tests {
let actual = render_module("crystal", dir.path());
let expected = Some(format!("via {} ", Color::Red.bold().paint("🔮 v0.32.1")));
assert_eq!(expected, actual);
- Ok(())
+
+ dir.close()
}
#[test]
@@ -81,6 +83,7 @@ mod tests {
let actual = render_module("crystal", dir.path());
let expected = Some(format!("via {} ", Color::Red.bold().paint("🔮 v0.32.1")));
assert_eq!(expected, actual);
- Ok(())
+
+ dir.close()
}
}
diff --git a/src/modules/elixir.rs b/src/modules/elixir.rs
index d68d11d6c..3ef1c984b 100644
--- a/src/modules/elixir.rs
+++ b/src/modules/elixir.rs
@@ -88,7 +88,7 @@ Elixir 1.10 (compiled with Erlang/OTP 22)
assert_eq!(output, expected);
- Ok(())
+ dir.close()
}
#[test]
@@ -104,6 +104,6 @@ Elixir 1.10 (compiled with Erlang/OTP 22)
assert_eq!(output, expected);
- Ok(())
+ dir.close()
}
}
diff --git a/src/modules/elm.rs b/src/modules/elm.rs
index 2acc87ac5..8cfadfaa8 100644
--- a/src/modules/elm.rs
+++ b/src/modules/elm.rs
@@ -49,7 +49,7 @@ mod tests {
let actual = render_module("elm", dir.path());
let expected = None;
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -59,7 +59,7 @@ mod tests {
let actual = render_module("elm", dir.path());
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🌳 v0.19.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -69,7 +69,7 @@ mod tests {
let actual = render_module("elm", dir.path());
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🌳 v0.19.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -80,7 +80,7 @@ mod tests {
let actual = render_module("elm", dir.path());
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🌳 v0.19.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -90,6 +90,6 @@ mod tests {
let actual = render_module("elm", dir.path());
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🌳 v0.19.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
}
diff --git a/src/modules/golang.rs b/src/modules/golang.rs
index 2f3cb27dd..4bfc17c67 100644
--- a/src/modules/golang.rs
+++ b/src/modules/golang.rs
@@ -72,7 +72,7 @@ mod tests {
let expected = None;
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -84,7 +84,7 @@ mod tests {
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -96,7 +96,7 @@ mod tests {
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -108,7 +108,7 @@ mod tests {
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -121,7 +121,7 @@ mod tests {
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -133,7 +133,7 @@ mod tests {
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -145,7 +145,7 @@ mod tests {
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
fn folder_with_gopkg_lock() -> io::Result<()> {
@@ -155,7 +155,7 @@ mod tests {
let actual = render_module("golang", dir.path());
let expected = Some(format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
diff --git a/src/modules/haskell.rs b/src/modules/haskell.rs
index 7324cc9cc..7b28d56ad 100644
--- a/src/modules/haskell.rs
+++ b/src/modules/haskell.rs
@@ -51,7 +51,7 @@ mod tests {
let actual = render_module("haskell", dir.path());
let expected = None;
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -61,7 +61,7 @@ mod tests {
let actual = render_module("haskell", dir.path());
let expected = Some(format!("via {} ", Color::Red.bold().paint("λ v8.6.5")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
fn folder_with_cabal_file() -> io::Result<()> {
@@ -70,7 +70,7 @@ mod tests {
let actual = render_module("haskell", dir.path());
let expected = Some(format!("via {} ", Color::Red.bold().paint("λ v8.6.5")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -80,6 +80,6 @@ mod tests {
let actual = render_module("haskell", dir.path());
let expected = Some(format!("via {} ", Color::Red.bold().paint("λ v8.6.5")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
}
diff --git a/src/modules/nodejs.rs b/src/modules/nodejs.rs
index 7fec383fa..d78ea5236 100644
--- a/src/modules/nodejs.rs
+++ b/src/modules/nodejs.rs
@@ -49,7 +49,7 @@ mod tests {
let actual = render_module("nodejs", dir.path());
let expected = None;
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -60,7 +60,7 @@ mod tests {
let actual = render_module("nodejs", dir.path());
let expected = Some(format!("via {} ", Color::Green.bold().paint("⬢ v12.0.0")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -71,7 +71,7 @@ mod tests {
let actual = render_module("nodejs", dir.path());
let expected = Some(format!("via {} ", Color::Green.bold().paint("⬢ v12.0.0")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -83,6 +83,6 @@ mod tests {
let actual = render_module("nodejs", dir.path());
let expected = Some(format!("via {} ", Color::Green.bold().paint("⬢ v12.0.0")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
}
diff --git a/src/modules/php.rs b/src/modules/php.rs
index 61e464e48..878cdb2ae 100644
--- a/src/modules/php.rs
+++ b/src/modules/php.rs
@@ -74,7 +74,7 @@ mod tests {
let expected = None;
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -89,7 +89,7 @@ mod tests {
Color::Fixed(147).bold().paint("🐘 v7.3.8")
));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -104,6 +104,6 @@ mod tests {
Color::Fixed(147).bold().paint("🐘 v7.3.8")
));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
}
diff --git a/src/modules/ruby.rs b/src/modules/ruby.rs
index de3670983..f50e80256 100644
--- a/src/modules/ruby.rs
+++ b/src/modules/ruby.rs
@@ -63,7 +63,7 @@ mod tests {
let expected = None;
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -75,7 +75,7 @@ mod tests {
let expected = Some(format!("via {} ", Color::Red.bold().paint("💎 v2.5.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -87,7 +87,7 @@ mod tests {
let expected = Some(format!("via {} ", Color::Red.bold().paint("💎 v2.5.1")));
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
diff --git a/tests/testsuite/aws.rs b/tests/testsuite/aws.rs
index d4d57335c..01f518f81 100644
--- a/tests/testsuite/aws.rs
+++ b/tests/testsuite/aws.rs
@@ -104,7 +104,7 @@ region = us-east-2
let expected = format!("on {} ", Color::Yellow.bold().paint("☁️ us-east-1"));
let actual = String::from_utf8(output.stdout).unwrap();
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
@@ -136,7 +136,7 @@ region = us-east-2
);
let actual = String::from_utf8(output.stdout).unwrap();
assert_eq!(expected, actual);
- Ok(())
+ dir.close()
}
#[test]
diff --git a/tests/testsuite/common.rs b/tests/testsuite/common.rs
index c7b6c6803..379edd238 100644
--- a/tests/testsuite/common.rs
+++ b/tests/testsuite/common.rs
@@ -1,4 +1,5 @@
use once_cell::sync::Lazy;
+use remove_dir_all::remove_dir_all;
use std::io::prelude::*;
use std::io::{Error, ErrorKind};
use std::path::{Path, PathBuf};
@@ -43,9 +44,10 @@ pub fn render_module(module_name: &str) -> process::Command {
}
/// Create a repo from the fixture to be used in git module tests
+/// Please delete the returned directory manually after usage with `remove_dir_all::remove_dir_all`
pub fn create_fixture_repo() -> io::Result<PathBuf> {
- let fixture_repo_path = tempfile::tempdir()?.path().join("fixture");
- let repo_path = tempfile::tempdir()?.path().join("rocket");
+ let fixture_repo_path = tempfile::tempdir()?.into_path();
+ let repo_path = tempfile::tempdir()?.into_path();
let fixture_path = env::current_dir()?.join("tests/fixtures/rocket.bundle");
let fixture_repo_dir = path_str(&fixture_repo_path)?;
@@ -57,6 +59,7 @@ pub fn create_fixture_repo() -> io::Result<PathBuf> {
.output()?;
git2::Repository::clone(&fixture_repo_dir, &repo_dir).ok();
+ remove_dir_all(fixture_repo_path)?;
Command::new("git")
.args(&["config", "--local", "user.email", "starship@example.com"])
diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs
index 2ead974e5..e30e3d531 100644
--- a/tests/testsuite/directory.rs
+++ b/tests/testsuite/directory.rs
@@ -268,7 +268,7 @@ fn git_repo_root() -> io::Result<()> {
let expected = format!("in {} ", Color::Cyan.bold().paint("rocket-controls"));
assert_eq!(expected, actual);
- Ok(())
+ tmp_dir.close()
}
#[test]
@@ -288,7 +288,7 @@ fn directory_in_git_repo() -> io::Result<()> {
let expected = format!("in {} ", Color::Cyan.bold().paint("rocket-controls/src"));
assert_eq!(expected, actual);
- Ok(())
+ tmp_dir.close()
}
#[test]
@@ -308,7 +308,7 @@ fn truncated_directory_in_git_repo() -> io::Result<()> {
let expected = format!("in {} ", Color::Cyan.bold().paint("src/meters/fuel-gauge"));
assert_eq!(expected, actual);
- Ok(())
+ tmp_dir.close()
}
#[test]
@@ -339,7 +339,7 @@ fn directory_in_git_repo_truncate_to_repo_false() -> io::Result<()> {
.paint("above-repo/rocket-controls/src/meters/fuel-gauge")
);
assert_eq!(expected, actual);
- Ok(())
+ tmp_dir.close()
}
#[test]
@@ -371,7 +371,7 @@ fn fish_path_directory_in_git_repo_truncate_to_repo_false() -> io::Result<()> {
.paint("~/.t/above-repo/rocket-controls/src/meters/fuel-gauge")
);
assert_eq!(expected, actual);
- Ok(())
+ tmp_dir.close()
}
#[test]
@@ -403,7 +403,7 @@ fn fish_path_directory_in_git_repo_truncate_to_repo_true() -> io::Result<()> {
.paint("~/.t/a/rocket-controls/src/meters/fuel-gauge")
);
assert_eq!(expected, actual);
- Ok(())
+ tmp_dir.close()
}
#[test]
@@ -434,7 +434,7 @@ fn directory_in_git_repo_truncate_to_repo_true() -> io::Result<()> {
.paint("rocket-controls/src/meters/fuel-gauge")
);
assert_eq!(expected, actual);
- Ok(())
+ tmp_dir.close()
}
#[test]
@@ -465,5 +465,5 @@ fn git_repo_in_home_directory_truncate_to_repo_true() -> io::Result<()> {
Color::Cyan.bold().paint("~/src/meters/fuel-gauge")
);
assert_eq!(expected, actual);
- Ok(())
+ tmp_dir.close()
}
diff --git a/tests/testsuite/dotnet.rs b/tests/testsuite/dotnet.rs
index fa53d2572..fe6991ade 100644
--- a/tests/testsuite/dotnet.rs
+++ b/tests/testsuite/dotnet.rs
@@ -8,7 +8,8 @@ use tempfile::{self, TempDir};
#[ignore]
fn shows_nothing_in_directory_with_zero_relevant_files() -> io::Result<()> {
let workspace = create_workspace(false)?;
- expect_output(&workspace, ".", None)
+ expect_output(&workspace, ".", None)?;
+ workspace.close()
}
#[test]
@@ -16,7 +17,8 @@ fn shows_nothing_in_directory_with_zero_relevant_files() -> io::Result<()> {
fn shows_latest_in_directory_with_solution() -> io::Result<()> {
let workspace = create_workspace(false)?;
touch_path(&workspace, "solution.sln", None)?;
- expect_output(&workspace, ".", Some("•NET v2.2.402"))
+ expect_output(&workspace, ".", Some("•NET v2.2.402"))?;
+ workspace.close()
}
#[test]
@@ -24,7 +26,8 @@ fn shows_latest_in_directory_with_solution() -> io::Result<()> {
fn shows_latest_in_directory_with_csproj() -> io::Result<()> {
let workspace = create_workspace(false)?;
touch_path(&workspace, "project.csproj", None)?;
- expect_output(&workspace, ".", Some("•NET v2.2.402"))
+ expect_output(&workspace, ".", Some("•NET v2.2.402"))?;
+ workspace.close()
}
#[test]
@@ -32,7 +35,8 @@ fn shows_latest_in_directory_with_csproj() -> io::Result<()> {
fn shows_latest_in_directory_with_fsproj() -> io::Result<()> {
let workspace = create_workspace(false)?;
touch_path(&workspace, "project.fsproj", None)?;
- expect_output(&workspace, ".", Some("•NET v2.2.402"))
+ expect_output(&workspace, ".", Some("•NET v2.2.402"))?;
+ workspace.close()
}
#[test]
@@ -40,7 +44,8 @@ fn shows_latest_in_directory_with_fsproj() -> io::Result<()> {
fn shows_latest_in_directory_with_xproj() -> io::Result<()> {
let workspace = create_workspace(false)?;
touch_path(&workspace, "project.xproj", None)?;
- expect_output(&workspace, ".", Some("•NET v2.2.402"))
+ expect_output(&workspace, ".", Some("•NET v2.2.402"))?;
+ workspace.close()
}
#[test]
@@ -48,7 +53,8 @@ fn shows_latest_in_directory_with_xproj() -> io::Result<()> {
fn shows_latest_in_directory_with_project_json() -> io::Result<()> {
let workspace = create_workspace(false)?;
touch_path(&workspace, "project.json", None)?;
- expect_output(&workspace, ".", Some("•NET v2.2.402"))
+ expect_output(&workspace, ".", Some("•NET v2.2.402"))?;
+ workspace.close()
}
#[test]
@@ -57,7 +63,8 @@ fn shows_pinned_in_directory_with_global_json() -> io::Result<()> {
let workspace = create_workspace(false)?;
let global_json = make_pinned_sdk_json("1.2.3");
touch_path(&workspace, "global.json", Some(&global_json))?;
- expect_output(&workspace, ".", Some("•NET v1.2.3"))
+ expect_output(&workspace, ".", Some("•NET v1.2.3"))?;
+ workspace.close()
}
#[test]
@@ -67,7 +74,8 @@ fn shows_pinned_in_project_below_root_with_global_json() -> io::Result<()> {
let global_json = make_pinned_sdk_json("1.2.3");
touch_path(&workspace, "global.json", Some(&global_json))?;
touch_path(&workspace, "project/project.csproj", None)?;
- expect_output(&workspace, "project", Some("•NET v1.2.3"))
+ expect_output(&workspace, "project", Some("•NET v1.2.3"))?;
+ workspace.close()
}
#[test]
@@ -77,7 +85,8 @@ fn shows_pinned_in_deeply_nested_project_within_repository() -> io::Result<()> {
let global_json = make_pinned_sdk_json("1.2.3");
touch_path(&workspace, "global.json", Some(&global_json))?;
touch_path(&workspace, "deep/path/to/project/project.csproj", None)?;
- expect_output(&workspace, "deep/path/to/project", Some("•NET v1.2.3"))
+ expect_output(&workspace, "deep/path/to/project", Some("•NET v1.2.3"))?;
+ workspace.close()
}
fn create_workspace(is_repo: bool) -> io::Result<TempDir> {
diff --git a/tests/testsuite/git_branch.rs b/tests/testsuite/git_branch.rs
index 76cd08ba2..7fa5aaaef 100644
--- a/tests/testsuite/git_branch.rs
+++ b/tests/testsuite/git_branch.rs
@@ -1,4 +1,5 @@
use ansi_term::Color;
+use remove_dir_all::remove_dir_all;
use std::io;
use std::process::Command;
@@ -124,7 +125,7 @@ fn test_truncate_length_with_config(
.unwrap(),
)
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
@@ -135,5 +136,5 @@ fn test_truncate_length_with_config(
.paint(format!("\u{e0a0} {}{}", expected_name, truncation_symbol)),
);
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
diff --git a/tests/testsuite/git_commit.rs b/tests/testsuite/git_commit.rs
index fdae075ab..d7ae8e771 100644
--- a/tests/testsuite/git_commit.rs
+++ b/tests/testsuite/git_commit.rs
@@ -1,4 +1,5 @@
use ansi_term::Color;
+use remove_dir_all::remove_dir_all;
use std::process::Command;
use std::{io, str};
@@ -22,7 +23,7 @@ fn test_render_commit_hash() -> io::Result<()> {
only_detached = false
})
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
@@ -32,7 +33,7 @@ fn test_render_commit_hash() -> io::Result<()> {
.to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -54,7 +55,7 @@ fn test_render_commit_hash_len_override() -> io::Result<()> {
commit_hash_length = 14
})
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
@@ -64,7 +65,7 @@ fn test_render_commit_hash_len_override() -> io::Result<()> {
.to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -73,13 +74,13 @@ fn test_render_commit_hash_only_detached_on_branch() -> io::Result<()> {
let output = common::render_module("git_commit")
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
assert_eq!("", actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -101,7 +102,7 @@ fn test_render_commit_hash_only_detached_on_detached() -> io::Result<()> {
let output = common::render_module("git_commit")
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
@@ -112,5 +113,5 @@ fn test_render_commit_hash_only_detached_on_detached() -> io::Result<()> {
.to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
diff --git a/tests/testsuite/git_status.rs b/tests/testsuite/git_status.rs
index d1ecf085c..58bba46e9 100644
--- a/tests/testsuite/git_status.rs
+++ b/tests/testsuite/git_status.rs
@@ -1,4 +1,5 @@
use ansi_term::{ANSIStrings, Color};
+use remove_dir_all::remove_dir_all;
use std::fs::{self, File};
use std::io;
use std::path::PathBuf;
@@ -27,14 +28,14 @@ fn shows_behind() -> io::Result<()> {
let output = common::render_module("git_status")
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = Color::Red.bold().paint(format!("[{}] ", "⇣")).to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -50,14 +51,14 @@ fn shows_behind_with_count() -> io::Result<()> {
show_sync_count = true
})
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = Color::Red.bold().paint(format!("[{}] ", "⇣1")).to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -70,14 +71,14 @@ fn shows_ahead() -> io::Result<()> {
let output = common::render_module("git_status")
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = Color::Red.bold().paint(format!("[{}] ", "⇡")).to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -94,14 +95,14 @@ fn shows_ahead_with_count() -> io::Result<()> {
show_sync_count = true
})
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = Color::Red.bold().paint(format!("[{}] ", "⇡1")).to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -113,14 +114,14 @@ fn shows_diverged() -> io::Result<()> {
let output = common::render_module("git_status")
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = Color::Red.bold().paint(format!("[{}] ", "⇕")).to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -136,7 +137,7 @@ fn shows_diverged_with_count() -> io::Result<()> {
show_sync_count = true
})
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = Color::Red
@@ -146,7 +147,7 @@ fn shows_diverged_with_count() -> io::Result<()> {
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -158,14 +159,14 @@ fn shows_conflicted() -> io::Result<()> {
let output = common::render_module("git_status")
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = Color::Red.bold().paint(format!("[{}] ", "=")).to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -181,14 +182,14 @@ fn shows_conflicted_with_count() -> io::Result<()> {
conflicted_count.enabled = true
})
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = Color::Red.bold().paint(format!("[{}] ", "=1")).to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -200,14 +201,14 @@ fn shows_untracked_file() -> io::Result<()> {
let output = common::render_module("git_status")
.arg("--path")
- .arg(repo_dir)
+ .arg(&repo_dir)
.output()?;
let actual = String::from_utf8(output.stdout).unwrap();
let expected = Color::Red.bold().paint(format!("[{}] ", "?")).to_string();
assert_eq!(expected, actual);
- Ok(())
+ remove_dir_all(repo_dir)
}
#[test]
@@ -223,14 +224,14 @@ fn shows_untracked_file_with_count() -> io::Result<()> {
untracked_count.enabled = true