Get the test to failing,,, correctly
This commit is contained in:
parent
6ac9308a03
commit
c8e63d76a4
7 changed files with 68 additions and 34 deletions
|
@ -7,17 +7,21 @@ edition = "2021"
|
|||
doctest = false
|
||||
|
||||
[features]
|
||||
test-support = ["rand", "serde_json", "tempdir"]
|
||||
test-support = ["rand", "serde_json", "tempdir", "git2"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.38"
|
||||
futures = "0.3"
|
||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||
lazy_static = "1.4.0"
|
||||
rand = { version = "0.8", optional = true }
|
||||
tempdir = { version = "0.3.7", optional = true }
|
||||
serde_json = { version = "1.0", features = ["preserve_order"], optional = true }
|
||||
git2 = { version = "0.15", default-features = false, optional = true }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
rand = { version = "0.8" }
|
||||
tempdir = { version = "0.3.7" }
|
||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||
git2 = { version = "0.15", default-features = false }
|
||||
|
|
|
@ -2,13 +2,20 @@
|
|||
pub mod test;
|
||||
|
||||
use futures::Future;
|
||||
use lazy_static::lazy_static;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
ffi::OsStr,
|
||||
ops::AddAssign,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
pub static ref DOT_GIT: &'static OsStr = OsStr::new(".git");
|
||||
pub static ref GITIGNORE: &'static OsStr = OsStr::new(".gitignore");
|
||||
}
|
||||
|
||||
pub fn truncate(s: &str, max_chars: usize) -> &str {
|
||||
match s.char_indices().nth(max_chars) {
|
||||
None => s,
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
mod assertions;
|
||||
mod marked_text;
|
||||
|
||||
use git2;
|
||||
use std::path::{Path, PathBuf};
|
||||
use tempdir::TempDir;
|
||||
|
||||
pub use assertions::*;
|
||||
pub use marked_text::*;
|
||||
|
||||
use crate::DOT_GIT;
|
||||
|
||||
pub fn temp_tree(tree: serde_json::Value) -> TempDir {
|
||||
let dir = TempDir::new("").unwrap();
|
||||
write_tree(dir.path(), tree);
|
||||
|
@ -24,6 +27,11 @@ fn write_tree(path: &Path, tree: serde_json::Value) {
|
|||
match contents {
|
||||
Value::Object(_) => {
|
||||
fs::create_dir(&path).unwrap();
|
||||
|
||||
if path.file_name() == Some(&DOT_GIT) {
|
||||
git2::Repository::init(&path.parent().unwrap()).unwrap();
|
||||
}
|
||||
|
||||
write_tree(&path, contents);
|
||||
}
|
||||
Value::Null => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue