-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from terhorstd/license_headers
Fix license headers in code files
- Loading branch information
Showing
5 changed files
with
101 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bats | ||
load test_helper | ||
|
||
test_planfiles_startwith() { | ||
# This helper function searches for all files matching $2 pattern | ||
# and complains about those not matching $1 regex. | ||
FILESTART="$1" | ||
NLINES="$(echo "$FILESTART" | wc -l)" | ||
N_BAD=0 | ||
for file in $(find "$BATS_TEST_DIRNAME/../plans" -type f -not -name "*.module" -not -name "*.txt" -not -name "*.sw*"); do | ||
[ "$FILESTART" = "$(head -n $NLINES "$file")" ] || { | ||
echo "$file does not contain correct copyright statement"; | ||
echo "" | ||
head -n $NLINES "$file" | diff -u /dev/stdin --label "$file" /dev/fd/9 --label "correct" 9<<<"$FILESTART" | ||
echo "" | ||
N_BAD=$(( $N_BAD + 1 )) | ||
}; | ||
done | ||
[ $N_BAD -eq 0 ] || { | ||
echo "$N_BAD BAD FILES" | ||
false | ||
} | ||
} | ||
|
||
test_codefiles_startwith() { | ||
# This helper function searches for all files matching $2 pattern | ||
# and complains about those not matching $1 regex. | ||
FILESTART="$1" | ||
NLINES="$(echo "$FILESTART" | wc -l)" | ||
N_BAD=0 | ||
for file in $(find "$BATS_TEST_DIRNAME/.." -maxdepth 2 -type f -name "*.sh"); do | ||
[ "$FILESTART" = "$(head -n $NLINES "$file")" ] || { | ||
echo "$file does not contain correct copyright statement"; | ||
echo "" | ||
head -n $NLINES "$file" | diff -u /dev/stdin --label "$file" /dev/fd/9 --label "correct" 9<<<"$FILESTART" | ||
echo "" | ||
N_BAD=$(( $N_BAD + 1 )) | ||
}; | ||
done | ||
[ $N_BAD -eq 0 ] || { | ||
echo "$N_BAD BAD FILES" | ||
false | ||
} | ||
} | ||
|
||
@test "check planfiles start with LICENSE header" { | ||
run test_planfiles_startwith "$(<$BATS_TEST_DIRNAME/license-header.txt)" | ||
if [ ${status} -ne 0 ]; then | ||
cat <<EOT | ||
--------------------------------------------------------------------------- | ||
Planfiles that are part of builder should start with an appropriate copyright | ||
header. Please open any planfile and copy the first 16 lines verbatim into any | ||
new planfile. | ||
--------------------------------------------------------------------------- | ||
EOT | ||
emit_debug_output && return 1 | ||
fi | ||
} | ||
|
||
@test "check source code starts with LICENSE header" { | ||
run test_codefiles_startwith "$(<$BATS_TEST_DIRNAME/license-header.txt)" | ||
if [ ${status} -ne 0 ]; then | ||
cat <<EOT | ||
--------------------------------------------------------------------------- | ||
Source code that are part of builder should start with an appropriate copyright | ||
header. Please make sure each file starts exactly (!) with the content of the | ||
file "tests/license-header.txt" | ||
--------------------------------------------------------------------------- | ||
EOT | ||
emit_debug_output && return 1 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# | ||
# Builder – Compile scripts for local installs of software packages. | ||
# Copyright (C) 2020 Forschungszentrum Jülich GmbH, INM-6 | ||
# | ||
# Builder is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Builder is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Builder. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters