From 7baefc958dc26f83430680d05aa3285baf87f1b0 Mon Sep 17 00:00:00 2001 From: numzero Date: Fri, 3 Apr 2026 17:01:12 +0300 Subject: [PATCH 1/2] init.sh: add tests (for manual running only for now) --- test/cargo.sh | 5 +++++ test/cmake.sh | 8 ++++++++ test/test-nogit.sh | 17 +++++++++++++++++ test/test-tar.sh | 16 ++++++++++++++++ test/test.sh | 18 ++++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100755 test/cargo.sh create mode 100755 test/cmake.sh create mode 100755 test/test-nogit.sh create mode 100755 test/test-tar.sh create mode 100755 test/test.sh diff --git a/test/cargo.sh b/test/cargo.sh new file mode 100755 index 0000000..4c0e2cc --- /dev/null +++ b/test/cargo.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -E + +exec cargo check diff --git a/test/cmake.sh b/test/cmake.sh new file mode 100755 index 0000000..6d2b548 --- /dev/null +++ b/test/cmake.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -x +set -E + +mkdir build +cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Debug +ninja -C build diff --git a/test/test-nogit.sh b/test/test-nogit.sh new file mode 100755 index 0000000..1aa4a74 --- /dev/null +++ b/test/test-nogit.sh @@ -0,0 +1,17 @@ +#!/bin/zsh + +set -e +trap 'echo Test failed!' ERR +name=' "Example"' +dir=${0%/*} +root=$dir/.. +tmp=$(mktemp -d) +trap 'rm -rf $tmp' EXIT +rsync -a --exclude=/.git --exclude-from=$root/.gitignore $root/. $tmp/ +cd $tmp +echo "Initializing in $tmp" +./init.sh $name +echo "Starting the shell in $tmp" +echo "Review the files, then exit the shell" +${SHELL:-/bin/sh} -i +echo "Review successful, cleaning up" diff --git a/test/test-tar.sh b/test/test-tar.sh new file mode 100755 index 0000000..8c60732 --- /dev/null +++ b/test/test-tar.sh @@ -0,0 +1,16 @@ +#!/bin/zsh + +set -e +trap 'echo Test failed!' ERR +name=' "Example"' +root=$(realpath ${0%/*}/..) +tmp=$(mktemp -d) +trap 'rm -rf $tmp' EXIT +cd $tmp +git -C $root archive HEAD | tar -x +echo "Initializing in $tmp" +./init.sh $name +echo "Starting the shell in $tmp" +echo "Review the files, then exit the shell" +${SHELL:-/bin/sh} -i +echo "Review successful, cleaning up" diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..f80950f --- /dev/null +++ b/test/test.sh @@ -0,0 +1,18 @@ +#!/bin/zsh + +set -e +trap 'echo Test failed!' ERR +name=' "Example"' +dir=${0%/*} +root=$dir/.. +tmp=$(mktemp -d) +trap 'rm -rf $tmp' EXIT +rsync -a --exclude-from=$root/.gitignore $root/. $tmp/ +cd $tmp +git clean -fxdq +echo "Initializing in $tmp" +./init.sh $name +echo "Starting the shell in $tmp" +echo "Review the files, then exit the shell" +${SHELL:-/bin/sh} -i +echo "Review successful, cleaning up" -- 2.47.3 From af79b01fff61e5ebd425402df20ebd0ef66f6c49 Mon Sep 17 00:00:00 2001 From: numzero Date: Sat, 18 Apr 2026 16:23:47 +0300 Subject: [PATCH 2/2] make sure skeleton tests are separate for (future) project tests --- init.sh | 1 + skel-test/README.md | 3 +++ {test => skel-test}/cargo.sh | 0 {test => skel-test}/cmake.sh | 0 {test => skel-test}/test-nogit.sh | 0 {test => skel-test}/test-tar.sh | 0 {test => skel-test}/test.sh | 0 7 files changed, 4 insertions(+) create mode 100644 skel-test/README.md rename {test => skel-test}/cargo.sh (100%) rename {test => skel-test}/cmake.sh (100%) rename {test => skel-test}/test-nogit.sh (100%) rename {test => skel-test}/test-tar.sh (100%) rename {test => skel-test}/test.sh (100%) diff --git a/init.sh b/init.sh index 98a011b..7e098e7 100755 --- a/init.sh +++ b/init.sh @@ -52,6 +52,7 @@ git remote remove origin # remove this script from the project (but keep on disk for now) git rm --cached init.sh +git rm -r skel-test # escape HTML special characters (&, <, and >), but also sed special characters (& again, \, and /) htmlname=$(echo -n "$name" | sed 's/&/\&/g; s//\>/g; s:[\\/&]:\\&:g') diff --git a/skel-test/README.md b/skel-test/README.md new file mode 100644 index 0000000..c0d80e5 --- /dev/null +++ b/skel-test/README.md @@ -0,0 +1,3 @@ +# Self-tests + +This directory contains self-tests for the skeleton itself. It should be removed when starting a new project. diff --git a/test/cargo.sh b/skel-test/cargo.sh similarity index 100% rename from test/cargo.sh rename to skel-test/cargo.sh diff --git a/test/cmake.sh b/skel-test/cmake.sh similarity index 100% rename from test/cmake.sh rename to skel-test/cmake.sh diff --git a/test/test-nogit.sh b/skel-test/test-nogit.sh similarity index 100% rename from test/test-nogit.sh rename to skel-test/test-nogit.sh diff --git a/test/test-tar.sh b/skel-test/test-tar.sh similarity index 100% rename from test/test-tar.sh rename to skel-test/test-tar.sh diff --git a/test/test.sh b/skel-test/test.sh similarity index 100% rename from test/test.sh rename to skel-test/test.sh -- 2.47.3