"typenum",
]
+[[package]]
+name = "ctor"
+version = "0.1.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
+dependencies = [
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "diff"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
+
[[package]]
name = "digest"
version = "0.10.6"
"pandoc",
"pest",
"pest_derive",
+ "pretty_assertions",
"walkdir",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
+[[package]]
+name = "output_vt100"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66"
+dependencies = [
+ "winapi",
+]
+
[[package]]
name = "owo-colors"
version = "1.3.0"
"pest_meta",
"proc-macro2",
"quote",
- "syn",
+ "syn 2.0.15",
]
[[package]]
"sha2",
]
+[[package]]
+name = "pretty_assertions"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755"
+dependencies = [
+ "ctor",
+ "diff",
+ "output_vt100",
+ "yansi",
+]
+
[[package]]
name = "proc-macro2"
version = "1.0.56"
"digest",
]
+[[package]]
+name = "syn"
+version = "1.0.109"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
[[package]]
name = "syn"
version = "2.0.15"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 2.0.15",
]
[[package]]
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "yansi"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
-#![allow(dead_code, unused)]
use crate::{metafile_to_string, parse_file, source, RootDirs, Source, Substitution};
use color_eyre::Result;
+use pretty_assertions::assert_eq;
use std::path::PathBuf;
-static SOURCE: &str = include_str!("./test_files/test_source.meta");
-static PATTERN: &str = include_str!("./test_files/test_pattern.meta");
-static PRE_EXPAND: &str = include_str!("./test_files/test_expand.meta");
+static SOURCE: &str = include_str!("./test_files/test_site/source/test_source.meta");
+static PATTERN: &str = include_str!("./test_files/test_site/pattern/test/pattern.meta");
+static PRE_EXPAND: &str = include_str!("./test_files/test_site/source/expand.meta");
static POST_EXPAND: &str = include_str!("./test_files/test_expanded");
+// builds a tmp_dir then runs multiple tests on it, then deletes the tmpdir
+// so we don't have to rebuild entire tmpdir every test
+fn test_on_tmp_dir(tests: Vec<fn(dirs: &RootDirs) -> Result<()>>) -> Result<()> {
+ let tmp_dir = std::env::temp_dir();
+
+ let dirs = RootDirs {
+ source: tmp_dir.join("source"),
+ build: tmp_dir.join("site"),
+ pattern: tmp_dir.join("pattern"),
+ };
+
+ for test in tests.iter() {
+ std::fs::remove_dir_all(&dirs.build)?;
+ std::fs::create_dir(&dirs.build)?;
+ test(&dirs)?;
+ }
+
+ std::fs::remove_dir_all(tmp_dir)?;
+ Ok(())
+}
+
#[test]
fn test_metafile_gets() -> Result<()> {
let source = parse_file(SOURCE)?;
Ok(())
}
-#[ignore = "todo: build tmp directory"]
#[test]
-fn test_metafile_to_str() -> Result<()> {
+fn builder_tests() -> Result<()> {
+ // vector of tests to perform on tmp_dir
+ let mut tests: Vec<fn(dirs: &RootDirs) -> Result<()>> = Vec::default();
+ tests.push(test_metafile_to_str);
+ test_on_tmp_dir(tests)?;
+ Ok(())
+}
+
+fn test_metafile_to_str(dirs: &RootDirs) -> Result<()> {
let metafile = parse_file(PRE_EXPAND)?;
- let dirs = RootDirs {
- source: PathBuf::new(),
- build: PathBuf::new(),
- pattern: PathBuf::new(),
- };
- let file = metafile_to_string(&metafile, &dirs, None)?;
+ let file = metafile_to_string(&metafile, dirs, None)?;
assert_eq!(file, POST_EXPAND);