Skip to content

Commit

Permalink
Check that the string table does not include unused entries
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Apr 25, 2018
1 parent a4b51c8 commit c889412
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ jobs:
script: scripts/travis_lint.sh
before_cache:

- &string-table-check
stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
env: NAME="string-table"
install:
script: scripts/string_table_check.sh
before_cache:

- stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
env: NAME="DOXYGEN-CHECK"
addons:
Expand Down
30 changes: 30 additions & 0 deletions scripts/string_table_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

whitelist=" \
"

cleanup()
{
rm -f "$ids_file"
}

ids_file=$(mktemp)

trap cleanup EXIT

gcc -E -P -x c src/util/irep_ids.def \
-D'IREP_ID_ONE(x)=ID_ ## x' -D'IREP_ID_TWO(x,y)=ID_ ## x' > $ids_file

for w in $whitelist
do
perl -p -i -e "s/^$w\n//" $ids_file
done

for i in $(<$ids_file)
do
if ! git grep -w -q -c -F $i
then
echo "$i is never used"
exit 1
fi
done

0 comments on commit c889412

Please sign in to comment.