Skip to content

Commit

Permalink
Fix test/all_headers_included.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
schanur committed Apr 28, 2016
1 parent ab89568 commit 958f367
Showing 1 changed file with 45 additions and 12 deletions.
57 changes: 45 additions & 12 deletions test/all_headers_included.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
#! /bin/bash

if [ -f src/all.h ]; then
for HEADER in src/*.h; do
if [ $(basename ${HEADER}) == "all.h" ]; then
continue
fi
if [ ! $(grep $(basename ${HEADER}) src/all.h) ]; then
echo ${HEADER} is not included in all.h
set -o errexit
set -o nounset
set -o pipefail

HEADER_PATH="src/platform"

function file_included() {
local HEADER_TO_GREP=${1}
local HEADER_TO_SERACH=${2}
local OCCUR_CNT

# grep -c $(basename ${HEADER_TO_SEARCH}) < ${HEADER_TO_GREP}
# exit 1
OCCUR_CNT=$(grep -c $(basename ${HEADER_TO_SEARCH}) < ${HEADER_TO_GREP} || true)
case "${OCCUR_CNT}" in
1)
true
;;
0)
echo "${HEADER_TO_SEARCH} is not included in ${HEADER_TO_GREP}"
;;
*)
echo "Parse error"
exit 1
fi
done
exit 0
fi
exit 1
;;
esac
}

function main() {
local ERR=0
local HEADER
local HEADER_TO_GREP="${HEADER_PATH}/all.h"
if [ -f ${HEADER_TO_GREP} ]; then
for HEADER_TO_SEARCH in ${HEADER_PATH}/*.h; do
if [ $(basename ${HEADER_TO_SEARCH}) == "all.h" ]; then
continue
fi
# echo "Check ${HEADER_TO_SEARCH}"
file_included ${HEADER_TO_GREP} ${HEADER_TO_SEARCH}
done
exit ${ERR}
fi
exit 1
}

main

0 comments on commit 958f367

Please sign in to comment.