check-ak-test-files.sh 789 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. set -eo pipefail
  3. script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
  4. cd "${script_path}/.."
  5. MISSING_FILES=n
  6. while IFS= read -r FILENAME; do
  7. # Simply search whether the CMakeLists.txt *ever* mention the test files.
  8. if ! grep -qF "${FILENAME}" Tests/AK/CMakeLists.txt ; then
  9. echo "Tests/AK/CMakeLists.txt is either missing the test file ${FILENAME} or is not in the commit's staged changes"
  10. MISSING_FILES=y
  11. fi
  12. done < <(
  13. git ls-files 'Tests/AK/Test*.cpp' | xargs basename
  14. )
  15. if [ "n" != "${MISSING_FILES}" ] ; then
  16. echo "Some files are missing from the Tests/AK/CMakeLists.txt."
  17. echo "If a new test file is being added, ensure it is in the CMakeLists.txt."
  18. echo "This ensures the new tests are always run."
  19. exit 1
  20. fi