summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsharkdp <davidpeter@web.de>2018-06-01 00:33:39 +0200
committersharkdp <davidpeter@web.de>2018-06-01 00:33:39 +0200
commit86c17772053b10431531101686aec64d76a08122 (patch)
tree0536d0dd089208d60c6637343ef275111d3b91fe /tests
parent16874ab016c869eb2ee4523c1dead126ce6d183c (diff)
Skip snapshot test if Git is not available
closes #161
Diffstat (limited to 'tests')
-rw-r--r--tests/tester.rs2
-rw-r--r--tests/tests.rs12
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/tester.rs b/tests/tester.rs
index 9865cbc1..404e8342 100644
--- a/tests/tester.rs
+++ b/tests/tester.rs
@@ -11,7 +11,7 @@ pub struct BatTester {
impl BatTester {
pub fn new() -> Self {
modify_sample_file();
- // Lifted from fd :)
+
let root = env::current_exe()
.expect("tests executable")
.parent()
diff --git a/tests/tests.rs b/tests/tests.rs
index 0f14ae15..2bf07906 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1,5 +1,6 @@
mod tester;
+use std::process::{Command, Stdio};
use tester::BatTester;
static STYLES: &'static [&'static str] = &[
@@ -24,6 +25,17 @@ static STYLES: &'static [&'static str] = &[
#[test]
fn test_snapshots() {
+ let status = Command::new("git")
+ .arg("rev-parse")
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status();
+
+ if !status.map(|s| s.success()).unwrap_or(false) {
+ // Git not available or not a git repository. Skipping snapshot test.
+ return;
+ }
+
let bat_tester = BatTester::new();
for style in STYLES {