From da86b4f8476221a513bde489f9fc119bb005f1be Mon Sep 17 00:00:00 2001 From: Kevin Song Date: Wed, 21 Aug 2019 09:37:43 -0700 Subject: [PATCH] fix: Failing Tests if home is a git directory (#214) --- CONTRIBUTING.md | 2 ++ tests/testsuite/directory.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37652202..f59950fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,6 +70,8 @@ Unit tests are written using the built-in Rust testing library in the same file Unit tests should be fully isolated, only testing a given function's expected output given a specific input, and should be reproducible on any machine. Unit tests should not expect the computer running them to be in any particular state. This includes having any applications pre-installed, having any environment variables set, etc. +The previous point should be emphasized: even seemingly innocuous ideas like "if we can see the directory, we can read it" or "nobody will have their home directory be a git repo" have bitten us in the past. Having even a single test fail can completely break installation on some platforms, so be careful with tests! + ### Acceptance Testing Acceptance tests are located in the [`tests/`](tests) directory and are also written using the built-in Rust testing library. diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs index beaa3328..702a6b51 100644 --- a/tests/testsuite/directory.rs +++ b/tests/testsuite/directory.rs @@ -12,6 +12,10 @@ use crate::common::{self, TestCommand}; fn home_directory() -> io::Result<()> { let output = common::render_module("directory") .arg("--path=~") + .use_config(toml::toml! { // Necessary if homedir is a git repo + [directory] + truncate_to_repo = false + }) .output()?; let actual = String::from_utf8(output.stdout).unwrap();