Skip to content

Commit

Permalink
Add a script to check for name clashes in test module file names
Browse files Browse the repository at this point in the history
  • Loading branch information
erszcz committed Jul 14, 2022
1 parent 748cbf8 commit 82e3ea9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ clean:
rm -rf bin/gradualizer ebin cover test/*.beam

.PHONY: tests eunit compile-tests cli-tests
tests: build_test_data eunit cli-tests
tests: check_name_clashes build_test_data eunit cli-tests

test_erls=$(wildcard test/*.erl)
test_beams=$(test_erls:test/%.erl=test/%.beam)
Expand Down Expand Up @@ -216,6 +216,10 @@ dialyze: app $(DIALYZER_PLT)
dialyze-tests: app $(DIALYZER_PLT)
dialyzer $(DIALYZER_OPTS) $(test_data_erls)

.PHONY: check_name_clashes
check_name_clashes:
test/check_name_clashes.sh

# DIALYZER_PLT is a variable understood directly by Dialyzer.
# Exit status 2 = warnings were emitted
$(DIALYZER_PLT):
Expand Down
26 changes: 26 additions & 0 deletions test/check_name_clashes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

#set -x

if [ x$(uname) == x"Darwin" ]; then
BASENAME=basename
else
BASENAME="basename -a"
fi

UNIQ=$(find test/should_pass test/should_fail test/known_problems/*/ -name \*.erl \
| xargs $BASENAME \
| sort \
| uniq -c \
| sort -n \
| tail -1)

COUNT=$(echo $UNIQ | awk '{print $1}')

if [ "$COUNT" == 1 ]; then
exit 0
else
echo "Name clash in tests:"
find test -name $(echo $UNIQ | awk '{print $2}')
exit 1
fi

0 comments on commit 82e3ea9

Please sign in to comment.