diff options
author | Jan Lehnardt <jan@apache.org> | 2023-01-05 12:24:24 +0100 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2023-01-05 12:42:21 +0100 |
commit | dcaef649e36d48d42106451656fed90feddd9ccb (patch) | |
tree | 65c4fa41f84fb6cb63d9c76c0ca1a11bf1be6b60 | |
parent | 33ee2164e6e73429193bc353a2c7dfb9d27a7790 (diff) | |
download | couchdb-feat/xref-fails-build.tar.gz |
feat(build): fail build if xref complainsfeat/xref-fails-build
-rw-r--r-- | Makefile | 7 | ||||
-rwxr-xr-x | build-aux/xref-helper.sh | 23 | ||||
-rw-r--r-- | test/fixtures/allowed-xref.txt | 4 |
3 files changed, 31 insertions, 3 deletions
@@ -152,6 +152,7 @@ escriptize: couch .PHONY: check # target: check - Test everything check: all + @$(MAKE) find-bugs @$(MAKE) exunit @$(MAKE) eunit @$(MAKE) mango-test @@ -350,10 +351,10 @@ dialyze: .rebar @$(REBAR) -r dialyze $(DIALYZE_OPTS) -.PHONY: find_bugs +.PHONY: find-bugs # target: xref - find unused exports etc -find_bugs: - @$(REBAR) --keep-going --recursive xref $(DIALYZE_OPTS) +find-bugs: + @./build-aux/xref-helper.sh $(REBAR) $(DIALYZE_OPTS) .PHONY: introspect # target: introspect - Check for commits difference between rebar.config and repository diff --git a/build-aux/xref-helper.sh b/build-aux/xref-helper.sh new file mode 100755 index 000000000..977537e78 --- /dev/null +++ b/build-aux/xref-helper.sh @@ -0,0 +1,23 @@ +#!/bin/sh -x +REBAR=$1 +DIALYZE_OPTS=$2 + +# run rebar xref, grep out rebar meta output (==> and WARN) +# pipe the rest into a file +$REBAR --keep-going --recursive xref $DIALYZE_OPTS | \ + grep -v '==>' | \ + grep -v 'WARN' | \ + grep -v hastings > ./tmp/xref-output.txt + +# compare result against known allowed output +mkdir -p ./tmp +DIFF=`diff -u ./tmp/xref-output.txt ./test/fixtures/allowed-xref.txt` + +# if the actual output differs from the allowed output +# print the difference and exit with 1 +if [ -n "$DIFF" ]; then + echo "$DIFF" + exit 1 +else + exit 0 +fi diff --git a/test/fixtures/allowed-xref.txt b/test/fixtures/allowed-xref.txt new file mode 100644 index 000000000..54163363a --- /dev/null +++ b/test/fixtures/allowed-xref.txt @@ -0,0 +1,4 @@ +file.erl: Warning: file:delete/2 is undefined function (Xref) +src/smoosh_persist.erl:136: Warning: smoosh_persist:delete_file/1 calls undefined function file:delete/2 (Xref) +src/ioq.erl: Warning: ioq:get_disk_queues/0 is undefined function (Xref) +src/weatherreport_check_ioq.erl:95: Warning: weatherreport_check_ioq:check_legacy_int/1 calls undefined function ioq:get_disk_queues/0 (Xref) |