diff --git a/lib/frontend/test/config.t b/lib/frontend/test/config.t index a1bf37b..75107d1 100644 --- a/lib/frontend/test/config.t +++ b/lib/frontend/test/config.t @@ -4,6 +4,7 @@ warning: option [forest.trees] not set, using default [trees] warning: option [forest.assets] not set, using default [] warning: option [forest.home] not set, using default index + error[config_error]: directory trees does not exist $ parse_forester_config configs/uninterpreted-fields.toml warning[config_error]: unknown options forest.unknown diff --git a/test/assets.t b/test/assets.t new file mode 100644 index 0000000..8fc0864 --- /dev/null +++ b/test/assets.t @@ -0,0 +1,67 @@ + $ forester init + note: Created directory trees + note: Created directory assets + note: Created file forest.toml + note: Created file .gitignore + note: Created file assets/.gitkeep + note: Created file trees/index.tree + note: Initialized forest, try editing `trees/index.tree` and running `forester build`. Afterwards, you can open `output/index.html` in your browser to view your forest. + + $ cat > trees/index.tree << EOF + > \title{Hello world} + > EOF + + $ cat > assets/hello.txt << EOF + > Hello + > EOF + + $ cat > trees/index.tree << EOF + > \{\route-asset{assets/hello.txt}} + > EOF + + $ forester build + Success! + + $ cat output/index/index.html + + + + + + + + + + + + +
+ +
+
+
+
+
+ +
+

https://www.my-great-forest.net/index/ [index]

+ +
+
+
/bafkrmig7e23kb5i6k7hr2lpxnfynqvnq7yb2ipf6ajbwkgysm6b6r5napm.txtindex.html
+
+
+
+
+ + + + $ [[ ! -f output/bafkrmig7e23kb5i6k7hr2lpxnfynqvnq7yb2ipf6ajbwkgysm6b6r5napm.txt ]] || printf "File exists" + File exists diff --git a/test/bad-foreign-blob.t b/test/bad-foreign-blob.t new file mode 100644 index 0000000..6e50c3e --- /dev/null +++ b/test/bad-foreign-blob.t @@ -0,0 +1,28 @@ + $ forester init + note: Created directory trees + note: Created directory assets + note: Created file forest.toml + note: Created file .gitignore + note: Created file assets/.gitkeep + note: Created file trees/index.tree + note: Initialized forest, try editing `trees/index.tree` and running `forester build`. Afterwards, you can open `output/index.html` in your browser to view your forest. + + $ cat > bad << EOF + > bad + > EOF + + $ cat > forest.toml << EOF + > [forest] + > trees = ["trees"] + > assets = [] + > home = "index" + > + > [[forest.foreign]] + > route_locally = true + > inlcude_in_manifest = true + > path = "bad" + > EOF + + $ forester build + error: Failed to parse foreign blob: expected JSON text (JSON value) + [1] diff --git a/test/expand-errors.t b/test/expand-errors.t new file mode 100644 index 0000000..e69de29 diff --git a/test/legacy-xml.t b/test/legacy-xml.t new file mode 100644 index 0000000..f1d2eed --- /dev/null +++ b/test/legacy-xml.t @@ -0,0 +1,63 @@ + $ forester init + note: Created directory trees + note: Created directory assets + note: Created file forest.toml + note: Created file .gitignore + note: Created file assets/.gitkeep + note: Created file trees/index.tree + note: Initialized forest, try editing `trees/index.tree` and running `forester build`. Afterwards, you can open `output/index.html` in your browser to view your forest. + $ cat > trees/index.tree << EOF + > \title{Hello world} + > EOF + $ forester build --emit-legacy-xml + Success! + $ cat output/index/index.xml + + + + + + https://www.my-great-forest.net/index/ + index + /index/ + Hello world + + + + + + + References + + + + + + + Context + + + + + + + Backlinks + + + + + + + Related + + + + + + + Contributions + + + + + diff --git a/test/objects.t b/test/objects.t new file mode 100644 index 0000000..9210c0f --- /dev/null +++ b/test/objects.t @@ -0,0 +1,86 @@ + $ forester init + note: Created directory trees + note: Created directory assets + note: Created file forest.toml + note: Created file .gitignore + note: Created file assets/.gitkeep + note: Created file trees/index.tree + note: Initialized forest, try editing `trees/index.tree` and running `forester build`. Afterwards, you can open `output/index.html` in your browser to view your forest. + + $ cat > trees/index.tree << EOF + > \def\my-object{ + > \object[self]{ + > [method1]{ + > \p{Hello method1} + > } + > } + > } + > \my-object#method1 + > EOF + + $ forester build + Success! + + $ cat output/index/index.html + + + + + + + + + + + + +
+ +
+
+
+
+

https://www.my-great-forest.net/index/ [index]

+

Hello method1

+
+
+
+
+ + + +Unfortunately, the error message here is pretty bad, since the error only +occurs when the top-level `extract_content` is called, to which the total range +is associated. Thus the error has as the location the entire file. I think +improving this will require rearchitecting the evaluator. + + $ cat > trees/index.tree << EOF + > \def\my-object{ + > \object[self]{ + > [method1]{ + > \p{Hello method1} + > } + > } + > } + > \patch{\my-object}[self]{ + > [method1]{} + > } + > EOF + + $ forester build + error[type_error]: mismatched type + ┌─ $TESTCASE_ROOT/trees/index.tree:1:1 + 1 │ ╭ \def\my-object{ + 2 │ │ \object[self]{ + 3 │ │ [method1]{ + 4 │ │ \p{Hello method1} + · │ + 7 │ │ } + 8 │ │ \patch{\my-object}[self]{ + 9 │ │ [method1]{} + 10 │ │ } + │ ╰───^ This is an object. Did you forget to bind this object to an identifier? + 11 │ + = expected some content + [1] diff --git a/test/ok.t b/test/ok.t new file mode 100644 index 0000000..d8a9477 --- /dev/null +++ b/test/ok.t @@ -0,0 +1,42 @@ + $ forester init + note: Created directory trees + note: Created directory assets + note: Created file forest.toml + note: Created file .gitignore + note: Created file assets/.gitkeep + note: Created file trees/index.tree + note: Initialized forest, try editing `trees/index.tree` and running `forester build`. Afterwards, you can open `output/index.html` in your browser to view your forest. + + $ cat > trees/index.tree << EOF + > \def\hello[name]{Hello, \name!} + > \hello{world} + > EOF + + $ forester build + Success! + $ cat output/index/index.html + + + + + + + + + + + + +
+ +
+
+
+
+

https://www.my-great-forest.net/index/ [index]

Hello, world!
+
+
+
+ + diff --git a/test/queries.t b/test/queries.t new file mode 100644 index 0000000..a92cce7 --- /dev/null +++ b/test/queries.t @@ -0,0 +1,106 @@ + $ forester init + note: Created directory trees + note: Created directory assets + note: Created file forest.toml + note: Created file .gitignore + note: Created file assets/.gitkeep + note: Created file trees/index.tree + note: Initialized forest, try editing `trees/index.tree` and running `forester build`. Afterwards, you can open `output/index.html` in your browser to view your forest. + + $ cat > trees/jonmsterling.tree < \taxon{Person} + > \title{Jon Sterling} + > EOF + + $ cat > trees/rel.tree << EOF + > \def\rel/accepted-or-refereed{jonmsterling.query.bibliography.accepted-or-refereed} + > + > \execute\datalog{ + > \rel/accepted-or-refereed ?X -: {\rel/has-tag ?X '{refereed}} + > } + > + > \execute\datalog{ + > \rel/accepted-or-refereed ?X -: {\rel/has-tag ?X '{accepted}} + > } + > EOF + + $ cat > trees/paper.tree << EOF + > \author{jonmsterling} + > \tag{refereed} + > \taxon{Reference} + > \title{Some novel result} + > EOF + + $ cat > trees/index.tree << EOF + > \import{rel} + > \query\datalog{ + > ?X -: + > {\rel/has-author ?X @{jonmsterling}} + > {\rel/is-reference ?X} + > {\rel/accepted-or-refereed ?X} + > } + > EOF + + + $ forester build + Success! + $ cat output/index/index.html + + + + + + + + + + + + +
+ +
+
+
+
+
+ +
+

https://www.my-great-forest.net/index/ [index]

+ +
+
+
+
+ +
+

Reference Some novel result [paper]

+ +
+
+
+
+
+
+
+
+ + diff --git a/test/transclusions.t b/test/transclusions.t new file mode 100644 index 0000000..e69de29 diff --git a/test/unlinked-attribution.t b/test/unlinked-attribution.t new file mode 100644 index 0000000..7b7bbe2 --- /dev/null +++ b/test/unlinked-attribution.t @@ -0,0 +1,19 @@ + $ forester init + note: Created directory trees + note: Created directory assets + note: Created file forest.toml + note: Created file .gitignore + note: Created file assets/.gitkeep + note: Created file trees/index.tree + note: Initialized forest, try editing `trees/index.tree` and running `forester build`. Afterwards, you can open `output/index.html` in your browser to view your forest. + + $ cat > trees/index.tree << EOF + > \author{Kento} + > EOF + + $ forester build + error: Unlinked attribution + ┌─ $TESTCASE_ROOT/trees/index.tree:1:8 + 1 │ \author{Kento} + │ ^^^^^^^ Expected valid URI in attribution. Use `\author/literal` instead if you intend an unlinked attribution. + Success!