aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-04-02 10:33:40 -0300
committerEuAndreh <eu@euandre.org>2023-04-02 16:36:23 -0300
commit22a7b4f0c8e018077984d58476a0c419b5e11942 (patch)
tree0343f0defd1bcea762dcce10b29c8c909661b577
parentaux/dev.mk: make in parallel over for loop (diff)
downloadremembering-main.tar.gz
remembering-main.tar.xz
aux/checks/repo.sh: WIP Fix testsHEADmain
Notes
See CI logs with: git notes --ref=refs/notes/ci-logs show 22a7b4f0c8e018077984d58476a0c419b5e11942 git notes --ref=refs/notes/ci-data show 22a7b4f0c8e018077984d58476a0c419b5e11942 Exit status: 2 Duration: 7
-rw-r--r--Makefile2
-rw-r--r--aux/checks/repo.env5
-rwxr-xr-xaux/checks/repo.sh150
-rwxr-xr-xaux/checks/shellcheck.sh6
-rw-r--r--aux/dev.mk10
-rw-r--r--aux/lib.sh5
-rwxr-xr-xrepo.sh33
-rwxr-xr-xsrc/remembering.in2
8 files changed, 126 insertions, 87 deletions
diff --git a/Makefile b/Makefile
index 8d155d6..9b60452 100644
--- a/Makefile
+++ b/Makefile
@@ -45,7 +45,7 @@ test-files = \
tests/signals.sh \
$(test-files): src/remembering ALWAYS
- sh $@
+ @echo sh $@
check: $(test-files)
diff --git a/aux/checks/repo.env b/aux/checks/repo.env
new file mode 100644
index 0000000..79b46d9
--- /dev/null
+++ b/aux/checks/repo.env
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+export EXECUTABLES=1
+export SYMLINKS=2
+export FILES=9
diff --git a/aux/checks/repo.sh b/aux/checks/repo.sh
index 0c00e92..323f68e 100755
--- a/aux/checks/repo.sh
+++ b/aux/checks/repo.sh
@@ -1,9 +1,6 @@
#!/bin/sh
set -eu
-if true; then
- exit
-fi
if [ -n "${RECURSIVE_CHECK:-}" ]; then
exit
@@ -11,30 +8,14 @@ fi
export RECURSIVE_CHECK=true
. aux/lib.sh
+. aux/checks/repo.env
+set -eu
-REPODIR="$PWD"
-
-INSTALLCHECK=false
-while getopts 'x:l:f:' flag; do
- case "$flag" in
- x)
- EXECUTABLES="$OPTARG"
- INSTALLCHECK=true
- ;;
- l)
- SYMLINKS="$OPTARG"
- INSTALLCHECK=true
- ;;
- f)
- FILES="$OPTARG"
- INSTALLCHECK=true
- ;;
- *)
- exit 2
- ;;
- esac
-done
-shift $((OPTIND - 1))
+usage() {
+ cat <<-'EOF'
+ FIXME
+ EOF
+}
assert_no_diffs() {
if [ -n "$(git status -s)" ]; then
@@ -45,37 +26,31 @@ assert_no_diffs() {
}
assert_installed_files() {
- if [ -n "${EXECUTABLES:-}" ]; then
- ACTUAL="$(find "$1" -type f -perm -u=x | wc -l)"
- if [ "$EXECUTABLES" != "$ACTUAL" ]; then
- printf 'Expected %s executables, found %s:\n' \
- "$EXECUTABLES" "$ACTUAL" >&2
- echo "find $1 -type f -perm -u=x:" >&2
- find "$1" -type f -perm -u=x >&2
- exit 1
- fi
+ ACTUAL="$(find "$1" -type f -perm -u=x | wc -l)"
+ if [ "$EXECUTABLES" != "$ACTUAL" ]; then
+ printf 'Expected %s executables, found %s:\n' \
+ "$EXECUTABLES" "$ACTUAL" >&2
+ echo "find $1 -type f -perm -u=x:" >&2
+ find "$1" -type f -perm -u=x >&2
+ exit 1
fi
- if [ -n "${SYMLINKS:-}" ]; then
- ACTUAL="$(find "$1" -type l | wc -l)"
- if [ "$SYMLINKS" != "$ACTUAL" ]; then
- printf 'Expected %s symlinks, found %s:\n' \
- "$SYMLINKS" "$ACTUAL" >&2
- echo "find $1 -type l:" >&2
- find "$1" -type l >&2
- exit 1
- fi
+ ACTUAL="$(find "$1" -type l | wc -l)"
+ if [ "$SYMLINKS" != "$ACTUAL" ]; then
+ printf 'Expected %s symlinks, found %s:\n' \
+ "$SYMLINKS" "$ACTUAL" >&2
+ echo "find $1 -type l:" >&2
+ find "$1" -type l >&2
+ exit 1
fi
- if [ -n "${FILES:-}" ]; then
- ACTUAL="$(find "$1" -type f | wc -l)"
- if [ "$FILES" != "$ACTUAL" ]; then
- printf 'Expected %s files, found %s:\n' \
- "$FILES" "$ACTUAL" >&2
- echo "find $1 -type f:" >&2
- find "$1" -type f >&2
- exit 1
- fi
+ ACTUAL="$(find "$1" -type f | wc -l)"
+ if [ "$FILES" != "$ACTUAL" ]; then
+ printf 'Expected %s files, found %s:\n' \
+ "$FILES" "$ACTUAL" >&2
+ echo "find $1 -type f:" >&2
+ find "$1" -type f >&2
+ exit 1
fi
}
@@ -89,14 +64,10 @@ assert_uninstalled_files() {
}
assert_install() {
- if [ "$INSTALLCHECK" != 'true' ]; then
- return
- fi
-
make clean
echo 'Asserting "canonical" install path' >&2
- INSTALL1="$(mkdtemp)"
+ INSTALL1="$(tmpname)"
make PREFIX="$INSTALL1"
make check PREFIX="$INSTALL1"
make install PREFIX="$INSTALL1"
@@ -107,7 +78,7 @@ assert_install() {
make clean
echo 'Asserting "straigh-forward" install path' >&2
- INSTALL2="$(mkdtemp)"
+ INSTALL2="$(tmpname)"
make install PREFIX="$INSTALL2"
assert_installed_files "$INSTALL2"
make uninstall PREFIX="$INSTALL2"
@@ -116,7 +87,7 @@ assert_install() {
make clean
echo 'Asserting "idempotent" install path' >&2
- INSTALL3="$(mkdtemp)"
+ INSTALL3="$(tmpname)"
make install PREFIX="$INSTALL3"
make install PREFIX="$INSTALL3"
assert_installed_files "$INSTALL3"
@@ -127,21 +98,26 @@ assert_install() {
make clean
echo 'Asserting "destdir" install path' >&2
- DESTDIR="$(mkdtemp)"
- INSTALL4="$(mkdtemp)"
+ DESTDIR="$(tmpname)"
+ INSTALL4="$(tmpname)"
make install DESTDIR="$DESTDIR" PREFIX="$INSTALL4"
assert_installed_files "$DESTDIR/$INSTALL4"
make uninstall DESTDIR="$DESTDIR" PREFIX="$INSTALL4"
assert_uninstalled_files "$DESTDIR/$INSTALL4"
}
-assert_clean_clone() {
- CLONEDIR="$(mkdtemp)"
+check_clean_clone() {
+ um
+ unreachable
+ return 12
+ oijwsx
+ CLONEDIR="$(tmpname)/$NAME"
+ mkdir -p -- "$CLONEDIR"
cd "$CLONEDIR"
- git clone "$REPODIR" .
+ git clone "$OLDPWD" .
- make clean public dev-check
+ make dev
assert_no_diffs
make clean
assert_no_diffs
@@ -154,35 +130,59 @@ assert_clean_clone() {
fi
rm -rf aux/
- make clean check || {
+ make check || {
echo 'Cannot run "make check" without "aux/".' >&2
echo "Clone directory: $CLONEDIR" >&2
- exit 1
+ exit 1 #FIXME
}
assert_install
+ oijwsx
cd - > /dev/null
}
-assert_clean_checkout() {
- CHECKOUTDIR="$(mkdtemp)"
+check_clean_checkout() {
+ set -x
+ echo dois
+ dois
+ CHECKOUTDIR="$(tmpname)/$NAME"
+ mkdir -p -- "$CHECKOUTDIR"
git --work-tree="$CHECKOUTDIR" checkout HEAD -- .
cd "$CHECKOUTDIR"
FILECOUNT="$(find . -type f | wc -l)"
- make clean public dev-check
- make clean
+ : make clean public dev-check
+ : make clean
if [ "$FILECOUNT" != "$(find . -type f | wc -l)" ]; then
echo 'File count mismatch after "make clean".' >&2
echo "Checkout directory: $CHECKOUTDIR" >&2
exit 1
fi
- assert_install
+ assert_insta
cd - > /dev/null
}
-assert_clean_clone
-assert_clean_checkout
+set -eu
+# set -eE
+D="$(mkdtemp)"
+
+check_clean_clone && echo aaa
+exit
+if ! check_clean_clone; then
+ touch "$D"/clean-clone.err
+fi
+check_clean_clone
+# || touch "$D"/clean-clone.err
+# check_clean_checkout || touch "$D"/clean-checkout.err
+# check_no_aux
+wait
+tree "$D"
+if [ "$(find "$D" -name '*.err' | wc -l)" != 0 ]; then
+ find "$D" -name '*.err' | while read -r f; do
+ cat -- "${f%.err}"
+ done
+ exit 1
+fi
diff --git a/aux/checks/shellcheck.sh b/aux/checks/shellcheck.sh
index 40fd364..585a75f 100755
--- a/aux/checks/shellcheck.sh
+++ b/aux/checks/shellcheck.sh
@@ -1,6 +1,6 @@
#!/bin/sh
set -eu
-find . -name '*.sh' -print0 |
- xargs -0 awk 'FNR==1 && /^#!\/bin\/sh$/ { print FILENAME }' |
- xargs shellcheck
+git ls-files |
+ xargs awk '/^#!\/bin\/sh$/ { print FILENAME } { nextfile }' |
+ xargs shellcheck -x
diff --git a/aux/dev.mk b/aux/dev.mk
index e644edb..9b91786 100644
--- a/aux/dev.mk
+++ b/aux/dev.mk
@@ -6,7 +6,7 @@
.in:
sed \
-e "s:@TLD@:`cat aux/tld.txt`:g" \
- -e "s:@NAME@:`basename $$PWD`:g" \
+ -e "s:@NAME@:`basename "$$PWD"`:g" \
-e 's:@MAILING_LIST@:$(MAILING_LIST):g' \
< $< > $@
@@ -14,13 +14,13 @@
pandoc -s -r man -w html \
-H aux/headers.html \
--metadata lang="`echo $< | awk -F. '{ print $$(NF-2) }'`" \
- < $(<D)/`basename $(<F) .in` > $@
+ < $(<D)/`basename "$(<F)" .in` > $@
.md.html:
pandoc -s -r commonmark -w html \
-H aux/headers.html \
--metadata lang="`echo $(<F) | cut -d. -f2`" \
- --metadata title="`basename $$PWD` - `echo $(<F) | cut -d. -f1`" \
+ --metadata title="`basename "$$PWD"` - `echo $(<F) | cut -d. -f1`" \
--toc --toc-depth=2 \
--highlight-style pygments \
< $< > $@
@@ -38,14 +38,14 @@ public/index.html:
ln -rs public/en/index.html $@
public/ci:
- sh aux/ci/report.sh -n `basename "$$PWD"` -o $@
+ sh aux/ci/report.sh -n "`basename "$$PWD"`" -o $@
public/TODOs.html: TODOs.md aux/preamble-md
mkdir -p $(@D)
td -H | cat aux/preamble-md - | pandoc -s -r commonmark -w html \
-H aux/headers.html \
--metadata lang=en \
- --metadata title="`basename $$PWD` - TODOs" \
+ --metadata title="`basename "$$PWD"` - TODOs" \
--toc --toc-depth=2 \
--highlight-style pygments \
> $@
diff --git a/aux/lib.sh b/aux/lib.sh
index f168294..1d7dabe 100644
--- a/aux/lib.sh
+++ b/aux/lib.sh
@@ -21,7 +21,8 @@ uuid() {
}
tmpname() {
- printf '%s/uuid-tmpname with spaces.%s' "${TMPDIR:-/tmp}" "$(uuid)"
+ # printf '%s/uuid-tmpname with spaces.%s' "${TMPDIR:-/tmp}" "$(uuid)"
+ printf '%s/uuid-tmpname-without-spaces.%s' "${TMPDIR:-/tmp}" "$(uuid)"
}
mkstemp() {
@@ -32,6 +33,6 @@ mkstemp() {
mkdtemp() {
name="$(tmpname)"
- mkdir -- "$name"
+ mkdir -p -- "$name"
printf '%s' "$name"
}
diff --git a/repo.sh b/repo.sh
new file mode 100755
index 0000000..7d81867
--- /dev/null
+++ b/repo.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+set -eu
+
+f() {
+ set -e
+ bad-command
+ unreachable
+ return 0
+}
+
+f && echo 'Executed, but shoult not'
+
+if f; then
+ echo 'Also executed, but should not'
+fi
+
+f || echo 'Not executed, but should be'
+
+if ! f; then
+ echo 'Also not executed, but should be'
+fi
+
+set -x
+set +e
+f
+STATUS=$?
+set -e
+if [ "$STATUS" != 0 ]; then
+ echo 'Only one that is executed when it should be'
+fi
+
+f
+echo 'This is *actually* unreachable'
diff --git a/src/remembering.in b/src/remembering.in
index 907ffe1..89e9453 100755
--- a/src/remembering.in
+++ b/src/remembering.in
@@ -138,7 +138,7 @@ if [ -z "$CHOICE" ]; then
exit
fi
-cat "$MERGED" |
+< "$MERGED" \
cut -d' ' -f1,3- |
uniq -f1 |
awk -vCHOICE="$CHOICE" '