diff --git a/scripts/test_all b/scripts/test_all new file mode 100755 index 0000000..b87f434 --- /dev/null +++ b/scripts/test_all @@ -0,0 +1,84 @@ +#! /bin/sh +# Runs Fes on all projects in test/ + +scriptversion="1" + +# +# +# Copyright (C) 2025-2026 fSD +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +me=$0 +version="$me/fSD v$scriptversion + +Copyright (C) 2025-2026 fSD. +This is free software; you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law." + +usage="Usage: $me [OPTION]... +Runs Fes on all projects in test/ + +Options: + --help print this help and exit + --version output version information" + +say() { + if [ -z "$q" ]; then + echo "$me: $*" + fi +} + +lsay() { + if [ -z "$q" ]; then + echo " => $*" + fi +} + +check_dep() { + printf 'checking for %s... ' "$1" + if command -v "$1" > /dev/null; then + echo "yes" + else + echo "no" + exit 1 + fi +} + +while [ $# -gt 0 ]; do + case $1 in + --help) echo "$usage"; exit 0 ;; + --version) echo "$version"; exit 0 ;; + -*) echo "$me: Unknown option '$1'." >&2; exit 1 ;; + esac +done + +if [ ! -d "modules" ]; then + echo "$me: error: must be run in project root." >&2 + exit 1 +fi + +if [ ! -f "fes" ]; then + echo "$me: error: run 'make'." >&2 + exit 1 +fi + +for dir in test/*; do + ./fes run "$dir" >/dev/null 2>&1 & + pid=$! + + printf "test '%s'" "$dir" + + printf "\nPress [Enter] to move to start the next..." + read -r unused + + if kill -0 $pid 2>/dev/null; then + kill $pid + fi +done + +echo "done" +kill $$ diff --git a/test/archive_test/Fes.toml b/test/archive_test/Fes.toml new file mode 100644 index 0000000..82c5002 --- /dev/null +++ b/test/archive_test/Fes.toml @@ -0,0 +1,5 @@ +[app] + +name = "archive" +version = "0.0.1" +authors = ["vx-clutch"] \ No newline at end of file diff --git a/test/archive_test/README.md b/test/archive_test/README.md new file mode 100644 index 0000000..0b7aab4 --- /dev/null +++ b/test/archive_test/README.md @@ -0,0 +1,4 @@ +# archive + +This example demonstrates the archive feature of Fes it is useful for file +sharing purposes. diff --git a/test/archive_test/archive/facts/seals/seals.txt b/test/archive_test/archive/facts/seals/seals.txt new file mode 100644 index 0000000..4637e63 --- /dev/null +++ b/test/archive_test/archive/facts/seals/seals.txt @@ -0,0 +1,22 @@ +Pinnipeds [2] are the seals and their relatives, a group of semi-aquatic marine +mammals. The Pinnipedia is in the Order Carnivora. There are three seal +families: Odobenidae (walruses), Otariidae (eared seals, including sea lions +and fur seals), and Phocidae (true seals).[3] + +Seals are sleek-bodied and barrel-shaped. Their bodies are well adapted to the +aquatic habitat where they spend most of their lives. Pinnipeds have flippers +for hands, big bulky bodies, doggish faces, and big eyes. Unlike cetaceans, +pinnipeds have their noses on their faces, and each nostril of the nose closes +when the pinniped goes underwater. Like cetaceans, pinnipeds have a thick layer +of blubber (fat) just under their skin: this blubber keeps them warm in cold +waters and keeps them fed during times when food is not easily found. When they +cannot find food, they live off the fat in the blubber. + +Pinnipeds are carnivorous. This means they eat only meat (such as fish or +squid) and not plants. However, almost all pinnipeds can be eaten by polar +bears, sharks and killer whales. + +Seals are often trained in zoos or aquariums to put on shows. However, in +Sweden, it is illegal to train a seal to balance a ball on its nose.[4] + +From [Pinniped Wikipedia](https://simple.wikipedia.org/wiki/Pinniped) diff --git a/test/archive_test/archive/seal.png b/test/archive_test/archive/seal.png new file mode 100644 index 0000000..74634c2 Binary files /dev/null and b/test/archive_test/archive/seal.png differ diff --git a/test/archive_test/www/index.lua b/test/archive_test/www/index.lua new file mode 100644 index 0000000..6a96cd7 --- /dev/null +++ b/test/archive_test/www/index.lua @@ -0,0 +1,10 @@ +local fes = require("fes") +local site = fes.fes() + +site.copyright = fes.util.copyright("https://fsd.vxserver.dev", "fSD") + +site:h1("Hello, World!") + +site:a("/archive", fes.std.h2("To the file room!")) + +return site diff --git a/test/basic_hello_world/Fes.toml b/test/basic_hello_world/Fes.toml new file mode 100644 index 0000000..31606c1 --- /dev/null +++ b/test/basic_hello_world/Fes.toml @@ -0,0 +1,5 @@ +[app] + +name = "hello" +version = "0.0.1" +authors = ["vx-clutch"] \ No newline at end of file diff --git a/test/basic_hello_world/README.md b/test/basic_hello_world/README.md new file mode 100644 index 0000000..fd8567d --- /dev/null +++ b/test/basic_hello_world/README.md @@ -0,0 +1,4 @@ +# hello + +This is a very simple hello world program, the only difference between this and +default is this README. diff --git a/test/basic_hello_world/www/index.lua b/test/basic_hello_world/www/index.lua new file mode 100644 index 0000000..12a2a55 --- /dev/null +++ b/test/basic_hello_world/www/index.lua @@ -0,0 +1,8 @@ +local fes = require("fes") +local site = fes.fes() + +site.copyright = fes.util.copyright("https://fsd.vxserver.dev", "fSD") + +site:h1("Hello, World!") + +return site diff --git a/test/complex_sample_project/Fes.toml b/test/complex_sample_project/Fes.toml new file mode 100644 index 0000000..38a5e3d --- /dev/null +++ b/test/complex_sample_project/Fes.toml @@ -0,0 +1,5 @@ +[app] + +name = "best" +version = "0.0.1" +authors = ["vx-clutch"] \ No newline at end of file diff --git a/test/complex_sample_project/README.md b/test/complex_sample_project/README.md new file mode 100644 index 0000000..93a79a3 --- /dev/null +++ b/test/complex_sample_project/README.md @@ -0,0 +1,23 @@ +# best + +This is an example of best practices for the Fes framework. + +## Parts + +With best practice we can break our sites into a few parts. + +## Index + +The main page of the site loads in the header and the footer, as well as shows +some core information + +## Include + +Within include the header and footer are defined. + +* **Header:** Site navigation and name display +* **Footer:** Extra and external information. + +## Static + +This is where we store our favicon. diff --git a/test/complex_sample_project/include/footer.lua b/test/complex_sample_project/include/footer.lua new file mode 100644 index 0000000..cfd0ed9 --- /dev/null +++ b/test/complex_sample_project/include/footer.lua @@ -0,0 +1,13 @@ +local footer = {} + +footer.render = function(std) + return table.concat({ + std.h2("Other resources"), + std.tl({ + std.external("https://git.vxserver.dev/fSD/fes", "Fes source"), + std.external("https://docs.vxserver.dev/static/fes.html", "Documentation"), + }), +}) +end + +return footer diff --git a/test/complex_sample_project/include/header.lua b/test/complex_sample_project/include/header.lua new file mode 100644 index 0000000..4a60a1e --- /dev/null +++ b/test/complex_sample_project/include/header.lua @@ -0,0 +1,7 @@ +local header = {} + +header.render = function(std) + return std.center(std.ha("/", std.h1("Best Practices"))) +end + +return header diff --git a/test/complex_sample_project/static/favicon.ico b/test/complex_sample_project/static/favicon.ico new file mode 100644 index 0000000..9db4ded Binary files /dev/null and b/test/complex_sample_project/static/favicon.ico differ diff --git a/test/complex_sample_project/www/index.lua b/test/complex_sample_project/www/index.lua new file mode 100644 index 0000000..96af136 --- /dev/null +++ b/test/complex_sample_project/www/index.lua @@ -0,0 +1,20 @@ +local fes = require("fes") +local std = fes.std +local u = fes.util + +local site = fes.fes() + +site.copyright = fes.util.copyright("https://fsd.vxserver.dev", "fSD") +site.title = "Best practices" +site.favicon = "/static/favicon.ico" + +site:banner(fes.app.header.render(std)) + +site:note(u.cc { + std.h2("Hello, World!"), + std.p("This is an example of the best practices/canonical Fes site.") +}) + +site:note(fes.app.footer.render(std)) + +return site diff --git a/test/default_project/Fes.toml b/test/default_project/Fes.toml new file mode 100644 index 0000000..44e865c --- /dev/null +++ b/test/default_project/Fes.toml @@ -0,0 +1,5 @@ +[app] + +name = "default" +version = "0.0.1" +authors = ["vx-clutch"] \ No newline at end of file diff --git a/test/default_project/README.md b/test/default_project/README.md new file mode 100644 index 0000000..7e8b977 --- /dev/null +++ b/test/default_project/README.md @@ -0,0 +1,33 @@ +# default + +``` +fes new default +``` + +> **Know what you are doing?** Delete this file. Have fun! + +## Project Structure + +Inside your Fes project, you'll see the following directories and files: + +``` +. +├── Fes.toml +├── README.md +└── www + └── index.lua +``` + +Fes looks for `.lua` files in the `www/` directory. Each file is exposed as a route based on its file name. + +## Commands + +All commands are run from the root of the project, from a terminal: + +| Command | Action | +| :------------------------ | :----------------------------------------------- | +| `fes run .` | Runs the project at `.` | + +## What to learn more? + +Check out [Fes's docs](https://docs.vxserver.dev/static/fes.html). \ No newline at end of file diff --git a/test/default_project/www/index.lua b/test/default_project/www/index.lua new file mode 100644 index 0000000..12a2a55 --- /dev/null +++ b/test/default_project/www/index.lua @@ -0,0 +1,8 @@ +local fes = require("fes") +local site = fes.fes() + +site.copyright = fes.util.copyright("https://fsd.vxserver.dev", "fSD") + +site:h1("Hello, World!") + +return site diff --git a/test/expected_error/Fes.toml b/test/expected_error/Fes.toml new file mode 100644 index 0000000..9cd794b --- /dev/null +++ b/test/expected_error/Fes.toml @@ -0,0 +1,5 @@ +[app] + +name = "error" +version = "0.0.1" +authors = ["vx-clutch"] \ No newline at end of file diff --git a/test/expected_error/README.md b/test/expected_error/README.md new file mode 100644 index 0000000..c11361a --- /dev/null +++ b/test/expected_error/README.md @@ -0,0 +1,6 @@ +# error + +This shows what a Lua error looks like to the user. Lua errors are the most +common and the most critical so that is why they are shown to the user. Other, +lesser errors, are only shown to the developer because of their different +nature. diff --git a/test/expected_error/www/index.lua b/test/expected_error/www/index.lua new file mode 100644 index 0000000..77aaecf --- /dev/null +++ b/test/expected_error/www/index.lua @@ -0,0 +1,10 @@ +local fes = require("fes") +local site = fes.fes() + +site.copyright = fes.util.copyright("https://fsd.vxserver.dev", "fSD") + +This is what an error looks like + +site:h1("Hello, World!") + +return site diff --git a/test/markdown_render/Fes.toml b/test/markdown_render/Fes.toml new file mode 100644 index 0000000..f800d4d --- /dev/null +++ b/test/markdown_render/Fes.toml @@ -0,0 +1,5 @@ +[app] + +name = "markdown" +version = "0.0.1" +authors = ["vx-clutch"] \ No newline at end of file diff --git a/test/markdown_render/README.md b/test/markdown_render/README.md new file mode 100644 index 0000000..98d5834 --- /dev/null +++ b/test/markdown_render/README.md @@ -0,0 +1,3 @@ +# markdown + +This example demonstrate Fes's ability to handle markdown routes. diff --git a/test/markdown_render/www/index.md b/test/markdown_render/www/index.md new file mode 100644 index 0000000..846dbbd --- /dev/null +++ b/test/markdown_render/www/index.md @@ -0,0 +1,3 @@ +# Markdown! + +**Fes** also supports markdown routes! diff --git a/test/minimal_return/Fes.toml b/test/minimal_return/Fes.toml new file mode 100644 index 0000000..b3008f5 --- /dev/null +++ b/test/minimal_return/Fes.toml @@ -0,0 +1,5 @@ +[app] + +name = "simple" +version = "0.0.1" +authors = ["vx-clutch"] \ No newline at end of file diff --git a/test/minimal_return/README.md b/test/minimal_return/README.md new file mode 100644 index 0000000..70e9d20 --- /dev/null +++ b/test/minimal_return/README.md @@ -0,0 +1,5 @@ +# simple + +This simple example shows the extensibility of the Fes framework. It shows the +you do not necessarily need to use the site object (although it is recommended) +you can define your own site, similar to how Lisps do things. diff --git a/test/minimal_return/www/index.lua b/test/minimal_return/www/index.lua new file mode 100644 index 0000000..5e0506d --- /dev/null +++ b/test/minimal_return/www/index.lua @@ -0,0 +1 @@ +return "Hello, World!"