]> git.huck.website - metaforge.git/commitdiff
added: scope tests
authorHuck Boles <huck@huck.website>
Sat, 20 May 2023 22:04:24 +0000 (17:04 -0500)
committerHuck Boles <huck@huck.website>
Sat, 20 May 2023 22:04:24 +0000 (17:04 -0500)
files/test_site/pattern/test/bad.meta [new file with mode: 0644]
files/test_site/pattern/test/good.meta [new file with mode: 0644]
files/test_site/pattern/test/scope.meta [new file with mode: 0644]
files/test_site/source/unit_tests/global/local_in_pattern.meta [new file with mode: 0644]
src/builder/tests.rs

diff --git a/files/test_site/pattern/test/bad.meta b/files/test_site/pattern/test/bad.meta
new file mode 100644 (file)
index 0000000..7b3a785
--- /dev/null
@@ -0,0 +1 @@
+BAD
diff --git a/files/test_site/pattern/test/good.meta b/files/test_site/pattern/test/good.meta
new file mode 100644 (file)
index 0000000..f49b816
--- /dev/null
@@ -0,0 +1 @@
+GOOD
diff --git a/files/test_site/pattern/test/scope.meta b/files/test_site/pattern/test/scope.meta
new file mode 100644 (file)
index 0000000..43881ee
--- /dev/null
@@ -0,0 +1,5 @@
+${ *var = 'good' }
+
+${var}
+
+&{SOURCE}
diff --git a/files/test_site/source/unit_tests/global/local_in_pattern.meta b/files/test_site/source/unit_tests/global/local_in_pattern.meta
new file mode 100644 (file)
index 0000000..5db16f6
--- /dev/null
@@ -0,0 +1,8 @@
+${ var = 'bad' }
+
+&{
+    body = DEFAULT
+    test = 'scope'
+}
+
+${var}
index 4ac2c09f30a453840e7ba243eafb5fb7711437c0..1d7d2ed37fe0ea784d87e36eb2104c7822b46a6a 100644 (file)
@@ -84,6 +84,14 @@ fn builder_tests() -> Result<()> {
         }
     }
 
+    if let Err(e) = test_filetype_header() {
+        errs.push(e.into());
+    }
+
+    if let Err(e) = test_global() {
+        errs.push(e.into());
+    }
+
     if err {
         for e in errs.iter() {
             eprintln!("{}", e);
@@ -94,7 +102,6 @@ fn builder_tests() -> Result<()> {
     Ok(())
 }
 
-#[test]
 fn test_filetype_header() -> Result<()> {
     let dir = PathBuf::from("files/test_site").canonicalize()?;
 
@@ -106,18 +113,21 @@ fn test_filetype_header() -> Result<()> {
     let path = opts.source.join("unit_tests/header/filetype.meta");
     let file = MetaFile::build(path, &opts)?;
 
-    assert_eq!(
-        file.dest()?,
-        opts.build.join("unit_tests/header/filetype.rss")
-    );
-
-    Ok(())
+    if file.dest()? == opts.build.join("unit_tests/header/filetype.rss") {
+        Ok(())
+    } else {
+        let err = eyre::eyre!("filetype - failed");
+        eprintln!("{:?}", err);
+        eprintln!(
+            "\nTEST:\n{}\nOUTPUT:\n{}",
+            opts.build.join("unit_tests/header/filetype.rss").display(),
+            file.dest()?.display()
+        );
+        Err(err)
+    }
 }
 
-#[test]
-#[ignore = "interferes with unit_tests"]
 fn test_global() -> Result<()> {
-    clean_build_dir()?;
     let dir = PathBuf::from("files/test_site/").canonicalize()?;
 
     let mut opts = Options::new();
@@ -132,12 +142,12 @@ fn test_global() -> Result<()> {
     dir_node.build_dir()?;
 
     assert_eq!(
-        std::fs::read_to_string(dir.join("build/unit_tests/global/pattern.html"))?,
+        fs::read_to_string(dir.join("build/unit_tests/global/pattern.html"))?,
         "<p>GOOD GOOD</p>\n"
     );
 
     assert_eq!(
-        std::fs::read_to_string(dir.join("build/unit_tests/global/variable.html"))?,
+        fs::read_to_string(dir.join("build/unit_tests/global/variable.html"))?,
         "<p>GOODGOOD</p>\n"
     );