From 7baefc958dc26f83430680d05aa3285baf87f1b0 Mon Sep 17 00:00:00 2001 From: numzero Date: Fri, 3 Apr 2026 17:01:12 +0300 Subject: [PATCH] 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"