]> git.huck.website - metaforge.git/commitdiff
benchmarks and tests
authorHuck Boles <huck@huck.website>
Sun, 14 May 2023 22:18:26 +0000 (17:18 -0500)
committerHuck Boles <huck@huck.website>
Sun, 14 May 2023 22:18:26 +0000 (17:18 -0500)
14 files changed:
.gitignore
Cargo.toml
benches/build_metafile.rs [moved from benches/build_site.rs with 74% similarity]
files/site/build/dir1/dir.html [deleted file]
files/site/build/dir1/sub_dir1/deep1/deep.html [deleted file]
files/site/build/dir1/sub_dir1/deep2/deep.html [deleted file]
files/site/build/dir1/sub_dir1/sub_dir.html [deleted file]
files/site/build/dir1/sub_dir2/sub_dir.html [deleted file]
files/site/build/dir1/sub_dir3/sub_dir.html [deleted file]
files/site/build/dir2/dir.html [deleted file]
files/site/build/root.html [deleted file]
files/site/source/root.meta
src/builder.rs
tests/build_dir.rs [new file with mode: 0644]

index 9c45757bddd730af7e9ae9612c5bcb007b7c7c8b..f3f425c34e2bc78245fa8465d3ee28ecc187e1cd 100644 (file)
@@ -1,2 +1,2 @@
 /target
-/test/build/
+files/site/build
index a8716f3f7b21c7658b62f23e60ec2354bc1b34d7..81a5157bc595892d2a0904deae0c1eead29b9be7 100644 (file)
@@ -15,5 +15,9 @@ pretty_assertions = "1"
 criterion = "0.4"
 
 [[bench]]
-name = "build_site"
+name = "build_metafile"
+harness = false
+
+[[bench]]
+name = "map_dir"
 harness = false
similarity index 74%
rename from benches/build_site.rs
rename to benches/build_metafile.rs
index 96304d25f843562e596fc8857cb76957b906e41c..52dba9776bfb35f269f8beae776f61df1fc4900b 100644 (file)
@@ -16,13 +16,16 @@ pub fn build_file_benchmark(c: &mut Criterion) {
 
     c.bench_function("build benchmark file", |b| {
         b.iter(|| {
-            let string = std::fs::read_to_string(black_box(&source)).unwrap();
-            let file = metaforge::parse_file(string, black_box(&opts)).unwrap();
-            let mut path = opts
-                .build
-                .join(source.strip_prefix(black_box(&opts.source)).unwrap());
+            let string = std::fs::read_to_string(black_box(&source)).expect("read file");
+            let file = metaforge::parse_file(string, black_box(&opts)).expect("parse file");
+            let mut path = opts.build.join(
+                source
+                    .strip_prefix(black_box(&opts.source))
+                    .expect("strip path"),
+            );
             path.set_extension("html");
-            std::fs::write(path, metaforge::build_metafile(&file).unwrap()).unwrap();
+            std::fs::write(path, metaforge::build_metafile(&file).expect("build file"))
+                .expect("write file");
         })
     });
 }
diff --git a/files/site/build/dir1/dir.html b/files/site/build/dir1/dir.html
deleted file mode 100644 (file)
index e0b7905..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<html>
-
-<header>HEADER</header>
-<body>
-<h1 id="list">LIST</h1>
-This is to test using arrays as lists.
-<ul>
-<li>
-A
-</li>
-<li>
-Single
-</li>
-<li>
-Word
-</li>
-<li>
-Per
-</li>
-<li>
-Item
-</li>
-</ul>
-
-</body>
-<footer>FOOTER</footer>
-
-</html>
diff --git a/files/site/build/dir1/sub_dir1/deep1/deep.html b/files/site/build/dir1/sub_dir1/deep1/deep.html
deleted file mode 100644 (file)
index a60088b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-<h1 id="simple-substitution">SIMPLE SUBSTITUTION</h1>
-<p>variable: GOOD</p>
-
-
diff --git a/files/site/build/dir1/sub_dir1/deep2/deep.html b/files/site/build/dir1/sub_dir1/deep2/deep.html
deleted file mode 100644 (file)
index 27c9159..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
-GOOD
-</body>
-</html>
diff --git a/files/site/build/dir1/sub_dir1/sub_dir.html b/files/site/build/dir1/sub_dir1/sub_dir.html
deleted file mode 100644 (file)
index a510f98..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<html>
-
-<header>HEADER</header>
-<body>
-<h1 id="links">LINKS</h1>
-<p>This should create a group of bold links <a href="
-a.com
-"><b> A Website </b></a><a href="
-b.net
-"><b> B Place </b></a><a href="
-c.org
-"><b> C Dest </b></a></p>
-
-</body>
-<footer>FOOTER</footer>
-
-</html>
diff --git a/files/site/build/dir1/sub_dir2/sub_dir.html b/files/site/build/dir1/sub_dir2/sub_dir.html
deleted file mode 100644 (file)
index 6907021..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<html>
-
-
-<body>
-<h1 id="blank">BLANK</h1>
-<p>This should have no header or footer</p>
-
-</body>
-
-
-</html>
diff --git a/files/site/build/dir1/sub_dir3/sub_dir.html b/files/site/build/dir1/sub_dir3/sub_dir.html
deleted file mode 100644 (file)
index 52ea22b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<html>
-
-<header>HEADER</header>
-<body>
-<h1 id="header-list">HEADER LIST</h1>
-<p>This should have a list in the header</p>
-
-</body>
-<footer>FOOTER</footer>
-
-</html>
diff --git a/files/site/build/dir2/dir.html b/files/site/build/dir2/dir.html
deleted file mode 100644 (file)
index e3465ee..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-
-<h1 id="markdown">MARKDOWN</h1>
-<h2 id="header">Header</h2>
-<p>This is a test for how various markdown elements translate</p>
-<h3 id="small-header">Small Header</h3>
-<ul>
-<li>Lists</li>
-<li>With</li>
-<li>Items</li>
-</ul>
-<h4 id="tiny-header">tiny header</h4>
-<p><em>Fancy</em> <strong>Text</strong> <strong>With</strong>
-<em>Adornments</em></p>
-<p>
-Inline HTML
-</p>
-<p><a href="https://example.org">a link</a></p>
-
-
diff --git a/files/site/build/root.html b/files/site/build/root.html
deleted file mode 100644 (file)
index 139ffbf..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<html>
-
-<header>HEADER</header>
-<body>
-<h1 id="root">ROOT</h1>
-<p>This is to test that the default base works without any
-defintions.</p>
-
-</body>
-<footer>FOOTER</footer>
-
-</html>
index 957a2d37231380e852061c1b64a7a9767e758ef4..3af0ab775f11662039217ed53753b46a88d4c9f8 100644 (file)
@@ -1,2 +1,2 @@
-# ROOT
-This is to test that the default base works without any defintions.
+&{ base = 'text' }
+TEST
index ff8e7027de60eaddaf2e507f8c842fd8082c9556..ad0d00f79a915d4466a72e8ba6ddceb982fa81d5 100644 (file)
@@ -248,15 +248,11 @@ mod tests {
     }
 
     #[test]
-    fn test_build_metafile() -> Result<()> {
+    fn test_metafile_to_string() -> Result<()> {
         let opts = build_options()?;
         let path = opts.source.join("dir1/sub_dir1/deep2/deep.meta");
-        let expanded = "<html>\n<body>\nGOOD\n</body>\n</html>\n";
-        build_metafile(&MetaFile::build(path, &opts)?)?;
-        assert_eq!(
-            std::fs::read_to_string(opts.build.join("dir1/sub_dir1/deep2/deep.html"))?,
-            expanded
-        );
+        let expanded = "<html><body>GOOD</body></html>";
+        assert_eq!(build_metafile(&MetaFile::build(path, &opts)?)?, expanded);
         Ok(())
     }
 
diff --git a/tests/build_dir.rs b/tests/build_dir.rs
new file mode 100644 (file)
index 0000000..f18d0f6
--- /dev/null
@@ -0,0 +1,4 @@
+use color_eyre::Result;
+
+#[test]
+fn build_dir() -> Result<()> {}