Skip to content

Commit

Permalink
Add a "find-missing-widgets" target to makefile
Browse files Browse the repository at this point in the history
This trys to find all the widget's references with
get_widget() and makes sure they are defined in glade
somewhere.
  • Loading branch information
alikins committed Jun 13, 2012
1 parent 830e9cc commit ee158bb
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RHSMCERTD_FLAGS=`pkg-config --cflags --libs glib-2.0`
PYFILES=`find src/ -name "*.py"`
TESTFILES=`find test/ -name "*.py"`
STYLEFILES=$(PYFILES) $(BIN_FILES)
GLADEFILES=`find src/subscription_manager/gui/data -name "*.glade"`

# note, set STYLETEST to something if you want
# make stylish to check the tests code
Expand Down Expand Up @@ -323,6 +324,24 @@ trailinglint:

whitespacelint: tablint trailinglint

# find widgets used via get_widget
# find widgets used as passed to init of SubscriptionManagerTab,
# find the widgets we actually find in the glade files
# see if any used ones are not defined
find-missing-widgets:
@TMPFILE=`mktemp` || exit 1; \
USED_WIDGETS="used_widgets_make.txt" ||exit 1; \
DEFINED_WIDGETS=`mktemp` ||exit 1; \
perl -n -e "if (/get_widget\([\'|\"](.*?)[\'|\"]\)/) { print(\"\$$1\n\")}" $(STYLEFILES) > $$USED_WIDGETS; \
pcregrep -h -o -M "(?:widgets|widget_names) = \[.*\s*.*?\s*.*\]" $(STYLEFILES) | perl -0 -n -e "my @matches = /[\'|\"](.*?)[\'|\"]/sg ; $$,=\"\n\"; print(@matches);" >> $$USED_WIDGETS; \
perl -n -e "if (/<widget class=\".*?\" id=\"(.*?)\">/) { print(\"\$$1\n\")}" $(GLADEFILES) > $$DEFINED_WIDGETS; \
while read line; do grep -F "$$line" $$DEFINED_WIDGETS > /dev/null ; STAT="$$?"; if [ "$$STAT" -ne "0" ] ; then echo "$$line"; fi; done < $$USED_WIDGETS | tee $$TMPFILE; \
! test -s $$TMPFILE

# look for python string formats that are known to break xgettext
# namely constructs of the forms: _("a" + "b")
# _("a" + \
# "b")
gettext_lint:
@TMPFILE=`mktemp` || exit 1; \
pcregrep -n --color=auto -M "_\(.*[\'|\"].*[\'|\"]\s*\+.*?\s*[\"|\'].*[\"|\'].*\)" $(STYLEFILES) | tee $$TMPFILE; \
Expand All @@ -338,6 +357,8 @@ rpmlint:
rpmlint -f rpmlint.config subscription-manager.spec | grep -v "^.*packages and .* specfiles checked\;" | tee $$TMPFILE; \
! test -s $$TMPFILE

stylish: pyflakes whitespacelint pep8 gettext_lint rpmlint
stylish: find-missing-widgets pyflakes whitespacelint pep8 gettext_lint rpmlint

jenkins: stylish coverage-jenkins


0 comments on commit ee158bb

Please sign in to comment.