Skip to content
Permalink
Browse files

Add unit test for license headers

  • Loading branch information
nyalldawson committed Jun 4, 2018
1 parent bb2e15c commit d16ec3e2571e83be1976f0b8774c509b58d3d309
Showing with 21 additions and 0 deletions.
  1. +1 −0 tests/code_layout/CMakeLists.txt
  2. +20 −0 tests/code_layout/test_licenses.sh
@@ -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)
@@ -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.
You can’t perform that action at this time.