Skip to content

Commit

Permalink
Add unit test for license headers
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 4, 2018
1 parent bb2e15c commit d16ec3e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/code_layout/CMakeLists.txt
Expand Up @@ -2,6 +2,7 @@ IF(WITH_ASTYLE)
ADD_TEST(qgis_indentation ${CMAKE_SOURCE_DIR}/scripts/verify-indentation.sh)
ENDIF(WITH_ASTYLE)

ADD_TEST(qgis_licenses ${CMAKE_SOURCE_DIR}/tests/code_layout/test_licenses.sh)
ADD_TEST(qgis_spelling ${CMAKE_SOURCE_DIR}/scripts/spell_check/spell_test.sh)

ADD_TEST(qgis_sipify ${CMAKE_SOURCE_DIR}/tests/code_layout/test_sipify.sh)
Expand Down
20 changes: 20 additions & 0 deletions tests/code_layout/test_licenses.sh
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# This test checks that all source files correctly have license headers

INCLUDE_EXTENSIONS="h|cpp|hpp|py|c"
EXCLUDE_LIST="(.*\/(qtermwidget)\/|ui_defaults\\.h|CREDITS|TODO|README|URI|^[^.]*$|.*\\.(?!($INCLUDE_EXTENSIONS)$))"

DIR=$(git rev-parse --show-toplevel)

pushd ${DIR} > /dev/null
missing=$(! { licensecheck -r -i "$EXCLUDE_LIST" src & licensecheck -r -i "$EXCLUDE_LIST" python; } | grep UNKNOWN)

popd > /dev/null

if [[ $missing ]]; then
echo " *** Found source files without valid license headers"
echo "$missing"
exit 1
fi

0 comments on commit d16ec3e

Please sign in to comment.