Skip to content

Commit

Permalink
chore: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
halostatue committed Jul 20, 2024
1 parent d036204 commit 89fdd97
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build/
tests/adr-config.expected
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ BUILDDIR:=/tmp/adr-tools-build
check: $(TESTS:tests/%.sh=$(BUILDDIR)/tests/%.diff)
@echo SUCCESS

tests/adr-config.expected: tests/adr-config.expected.tmpl
@sed -e "s!__PWD__!$(shell pwd -P)!g" < $< > $@

$(BUILDDIR)/tests/%.diff: $(BUILDDIR)/tests/%.output tests/%.expected
@diff --side-by-side $^ > $@ || ! cat $@
@diff --side-by-side --width 225 $^ > $@ || ! cat -n $@
@#diff -u $^ > $@ || ! cat $@

$(BUILDDIR)/tests/%.output: tests/%.sh tests/%.expected $(SRC)
@echo TEST: $*
Expand All @@ -24,7 +28,7 @@ $(BUILDDIR)/tests/%.output: tests/%.sh tests/%.expected $(SRC)
/bin/sh -v $(abspath $<) > $(abspath $@) 2>&1) || ! cat $@

clean:
rm -rf /tmp/adr-tools-build
@rm -rf $(BUILDDIR) tests/adr-config.expected

show-%:
@echo "$* ($(flavor $*)) = $($*)"
Expand Down
2 changes: 1 addition & 1 deletion src/adr-new
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ if [[ -z "${title}" ]]; then
exit 1
fi

if [[ -z "${newnum}" ]]; then
if [[ "${newnum}" = unassigned ]]; then
if [[ -d "${dstdir}" ]]; then
# shellcheck disable=SC2010
maxid=$(ls "${dstdir}" | grep -Eo '^[0-9]+' | sed -e 's/^0*//' | sort -rn | head -1)
Expand Down
34 changes: 12 additions & 22 deletions tests/adr-config.expected → tests/adr-config.expected.tmpl
Original file line number Diff line number Diff line change
@@ -1,53 +1,43 @@
adr config
# This script returns the configuration values for adr-tools. It does not change these values.
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_template_dir="/home/spriggsj/adr-tools-cp/src"
adr_bin_dir="__PWD__/src"
adr_template_dir="__PWD__/src"

adr config -q
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_template_dir="/home/spriggsj/adr-tools-cp/src"
adr_bin_dir="__PWD__/src"
adr_template_dir="__PWD__/src"

adr config -q
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_template_dir="/usr/local/share/adr-tools"

echo "adr_template_dir='/usr/local/share/adr-tools'" > ~/.adr-config
echo "adr_template_dir='/usr/local/share/adr-tools'" >~/.adr-config
adr config
# This script returns the configuration values for adr-tools. It does not change these values.
# Loading system values from /etc/adr-config
# Loading global values from ~/.adr-config
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_bin_dir="__PWD__/src"
adr_template_dir="/usr/local/share/adr-tools"

adr config -q
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_bin_dir="__PWD__/src"
adr_template_dir="/usr/local/share/adr-tools"

mkdir -p doc/adr
echo "adr_template_dir='/usr/local/share/adr-tools'" > doc/adr/.adr-config
echo "adr_template_dir='/usr/local/share/adr-tools'" >doc/adr/.adr-config
adr config
# This script returns the configuration values for adr-tools. It does not change these values.
# Loading system values from /etc/adr-config
# Loading global values from ~/.adr-config
# Loading local values from doc/adr/.adr-config
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_template_dir="/usr/local/share/adr-tools"

adr config -q
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_bin_dir="__PWD__/src"
adr_template_dir="/usr/local/share/adr-tools"

adr config -q
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_bin_dir="__PWD__/src"
adr_template_dir="/usr/local/share/adr-tools"

rm ~/.adr-config
adr config
# This script returns the configuration values for adr-tools. It does not change these values.
# Loading local values from doc/adr/.adr-config
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_bin_dir="__PWD__/src"
adr_template_dir="/usr/local/share/adr-tools"

adr config -q
adr_bin_dir="/home/spriggsj/adr-tools-cp/src"
adr_bin_dir="__PWD__/src"
adr_template_dir="/usr/local/share/adr-tools"
2 changes: 1 addition & 1 deletion tests/autocomplete.expected
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ config edit generate help init link list new upgrade-repository
_adr_autocomplete adr li
link list
_adr_autocomplete adr generate
graph toc
graph table toc
_adr_autocomplete adr generate to
toc
_adr_autocomplete adr ierhir
Expand Down
2 changes: 1 addition & 1 deletion tests/init-adr-repository.expected
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We need to record the architectural decisions made on this project.

## Decision

We will use Architecture Decision Records, as [described by Michael Nygard](http://blog.cognitect.com/2011/11/15/documenting-architecture-decisions.html).
We will use Architecture Decision Records, as [described by Michael Nygard](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions).

## Consequences

Expand Down

0 comments on commit 89fdd97

Please sign in to comment.