File tree Expand file tree Collapse file tree 7 files changed +84
-12
lines changed Expand file tree Collapse file tree 7 files changed +84
-12
lines changed Original file line number Diff line number Diff line change 2
2
TESTS: =$(wildcard tests/* .sh)
3
3
SRC: =$(wildcard src/* )
4
4
5
- check : $(TESTS:tests/%.sh=build/tests/%.diff )
5
+ # Run tests outside the project directory so that they cannot interfere with the project's
6
+ # own ADR directory
7
+ BUILDDIR: =/tmp/adr-tools-build
8
+
9
+ check : $(TESTS:tests/%.sh=$(BUILDDIR ) /tests/%.diff )
6
10
@echo SUCCESS
7
11
8
- build /tests/% .diff : build /tests/% .output tests/% .expected
12
+ $( BUILDDIR ) /tests/% .diff : $( BUILDDIR ) /tests/% .output tests/% .expected
9
13
@diff --side-by-side $^ > $@ || ! cat $@
10
14
11
- build /tests/% .output : tests/% .sh tests/% .expected $(SRC )
15
+ $( BUILDDIR ) /tests/% .output : tests/% .sh tests/% .expected $(SRC )
12
16
@echo TEST: $*
13
17
@rm -rf $(dir $@ ) /$*
14
18
@mkdir -p $(dir $@ ) /$*
@@ -21,8 +25,11 @@ build/tests/%.output: tests/%.sh tests/%.expected $(SRC)
21
25
/bin/sh -v $(abspath $< ) > $(abspath $@ ) 2>&1 ) || ! cat $@
22
26
23
27
clean :
24
- rm -rf build/
28
+ rm -rf /tmp/adr-tools-build
29
+
30
+ show-% :
31
+ @echo " $* ($( flavor $* ) ) = $( $* ) "
25
32
26
33
.PHONY : all clean
27
- .PRECIOUS : build /tests/% .output
34
+ .PRECIOUS : $( BUILDDIR ) /tests/% .output
28
35
.DELETE_ON_ERROR :
Original file line number Diff line number Diff line change @@ -5,4 +5,4 @@ test="${1:?test}"
5
5
6
6
test_name=$( basename $test | sed ' s/\..*//' )
7
7
8
- cp -v build/tests/$test_name .output tests/$test_name .expected
8
+ cp -v /tmp/adr-tools- build/tests/$test_name .output tests/$test_name .expected
Original file line number Diff line number Diff line change 2
2
set -e
3
3
eval " $( $( dirname $0 ) /adr-config) "
4
4
5
- if [ -f .adr-dir ]
6
- then
7
- cat .adr-dir
8
- else
9
- echo doc/adr
10
- fi
5
+ reldir=.
6
+
7
+ function mkrel() {
8
+ local d=$reldir /$1
9
+ echo ${d# ./ }
10
+ }
11
+
12
+ function absdir() {
13
+ (cd $( dirname $1 ) && pwd -P)
14
+ }
15
+
16
+ while [ $( absdir $reldir ) != / ]
17
+ do
18
+ if [ -f $( mkrel .adr-dir) ]
19
+ then
20
+ mkrel $( cat $( mkrel .adr-dir) )
21
+ exit
22
+ elif [ -d $( mkrel doc/adr) ]
23
+ then
24
+ mkrel doc/adr
25
+ exit
26
+ else
27
+ reldir=$reldir /..
28
+ fi
29
+ done
30
+ echo doc/adr
Original file line number Diff line number Diff line change
1
+ adr new First Record
2
+ doc/adr/0001-first-record.md
3
+ mkdir subdir
4
+ cd subdir
5
+ adr new Second Record
6
+ ../doc/adr/0002-second-record.md
7
+ adr list
8
+ ../doc/adr/0001-first-record.md
9
+ ../doc/adr/0002-second-record.md
10
+ cd ..
11
+ adr list
12
+ doc/adr/0001-first-record.md
13
+ doc/adr/0002-second-record.md
Original file line number Diff line number Diff line change
1
+ adr new First Record
2
+ mkdir subdir
3
+ cd subdir
4
+ adr new Second Record
5
+ adr list
6
+ cd ..
7
+ adr list
Original file line number Diff line number Diff line change
1
+ adr init architecture-log
2
+ architecture-log/0001-record-architecture-decisions.md
3
+ adr new First Record
4
+ architecture-log/0002-first-record.md
5
+ mkdir subdir
6
+ cd subdir
7
+ adr new Second Record
8
+ ../architecture-log/0003-second-record.md
9
+ adr list
10
+ ../architecture-log/0001-record-architecture-decisions.md
11
+ ../architecture-log/0002-first-record.md
12
+ ../architecture-log/0003-second-record.md
13
+ cd ..
14
+ adr list
15
+ architecture-log/0001-record-architecture-decisions.md
16
+ architecture-log/0002-first-record.md
17
+ architecture-log/0003-second-record.md
Original file line number Diff line number Diff line change
1
+ adr init architecture-log
2
+ adr new First Record
3
+ mkdir subdir
4
+ cd subdir
5
+ adr new Second Record
6
+ adr list
7
+ cd ..
8
+ adr list
You can’t perform that action at this time.
0 commit comments