You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2023/01/05 11:38:40 UTC

[couchdb] branch feat/xref-fails-build created (now 2859ab007)

This is an automated email from the ASF dual-hosted git repository.

jan pushed a change to branch feat/xref-fails-build
in repository https://gitbox.apache.org/repos/asf/couchdb.git


      at 2859ab007 feat(build): fail build if xref complains

This branch includes the following new commits:

     new 2859ab007 feat(build): fail build if xref complains

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: feat(build): fail build if xref complains

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch feat/xref-fails-build
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 2859ab00712edb8f359f69ad91d0f400cdb873d6
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Thu Jan 5 12:24:24 2023 +0100

    feat(build): fail build if xref complains
---
 Makefile                       |  6 +++---
 build-aux/xref-helper.sh       | 23 +++++++++++++++++++++++
 test/fixtures/allowed-xref.txt |  4 ++++
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 00036cc68..dba30b43d 100644
--- a/Makefile
+++ b/Makefile
@@ -350,10 +350,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)