diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2020-12-24 09:39:37 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-24 21:00:10 +0100 |
commit | d46de3aeb48c61ffe641f9aebc8f2ea39a9cce57 (patch) | |
tree | 1986af0cefa64aad97d8f5d5bc6d06298275c316 | |
parent | e5ac1fcd00a7fa4859c54954ba7b373490384669 (diff) | |
download | serenity-d46de3aeb48c61ffe641f9aebc8f2ea39a9cce57.zip |
Meta: Verify all AK test files are listed in CMake
Problem:
- It is possible for a new test file to be added to the `AK/Tests`
directory without being added to the corresponding
`CMakeLists.txt`. This results in the tests not being run.
Solution:
- As part of CI linting, verify that all the `AK/Tests/Test*.cpp`
files are mentioned in the `CMakeLists.txt`.
-rwxr-xr-x | Meta/check-ak-test-files.sh | 25 | ||||
-rwxr-xr-x | Meta/lint-ci.sh | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/Meta/check-ak-test-files.sh b/Meta/check-ak-test-files.sh new file mode 100755 index 0000000000..3a657a76bb --- /dev/null +++ b/Meta/check-ak-test-files.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -eo pipefail + +script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P) +cd "${script_path}/.." + +MISSING_FILES=n + +while IFS= read -r FILENAME; do + # Simply search whether the CMakeLists.txt *ever* mention the test files. + if ! grep -qP "${FILENAME}" AK/Tests/CMakeLists.txt ; then + echo "AK/Tests/CMakeLists.txt is missing the test file ${FILENAME}" + MISSING_FILES=y + fi +done < <( + git ls-files 'AK/Tests/Test*.cpp' | xargs -i basename {} +) + +if [ "n" != "${MISSING_FILES}" ] ; then + echo "Some files are missing from the AK/Tests/CMakeLists.txt." + echo "If a new test file is being added, ensure it is in the CMakeLists.txt." + echo "This ensures the new tests are always run." + exit 1 +fi diff --git a/Meta/lint-ci.sh b/Meta/lint-ci.sh index 8b2cb76756..c659d8857b 100755 --- a/Meta/lint-ci.sh +++ b/Meta/lint-ci.sh @@ -6,6 +6,7 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P) cd "${script_path}/.." || exit 1 for cmd in \ + Meta/check-ak-test-files.sh \ Meta/check-debug-flags.sh \ Meta/check-style.sh \ Meta/lint-executable-resources.sh \ |