Skip to content

Commit

Permalink
bash: Move test generator file to a separate directory
Browse files Browse the repository at this point in the history
  • Loading branch information
JussiPekonen committed Aug 7, 2020
1 parent 57f5f97 commit 409a0d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion bash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
project(bib2web-bash)

add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(tools)
add_subdirectory(test)
6 changes: 3 additions & 3 deletions bash/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ if(BIB2WEB_SHUNIT2_EXISTS)
set(BASH_TEST_MASTER_FILE "${CMAKE_CURRENT_BINARY_DIR}/.bash-test.sh")
add_custom_command(
OUTPUT "${BASH_TEST_MASTER_FILE}"
COMMAND /bin/bash ARGS "${CMAKE_CURRENT_SOURCE_DIR}/generate-test-master.bash" "${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" "${BIB2WEB_SHUNIT2}" "${BASH_TEST_MASTER_FILE}" ${BASH_TEST_FILES}
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generate-test-master.bash" "${BASH_TEST_FILES}")
COMMAND /bin/bash ARGS "${CMAKE_CURRENT_SOURCE_DIR}/../tools/generate-test-master.bash" "${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" "${BIB2WEB_SHUNIT2}" "${BASH_TEST_MASTER_FILE}" ${BASH_TEST_FILES}
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../tools/generate-test-master.bash" "${BASH_TEST_FILES}")

add_custom_target(bash-test
DEPENDS "${BASH_TEST_MASTER_FILE}")
Expand All @@ -32,7 +32,7 @@ if(BIB2WEB_SHELLCHECK_EXISTS)
add_custom_target(bash-test-lint)
add_custom_command(
TARGET bash-test-lint
COMMAND shellcheck ARGS "-x" "${CMAKE_CURRENT_SOURCE_DIR}/generate-test-master.bash" ${BASH_TEST_FILES}
COMMAND shellcheck ARGS "-x" ${BASH_TEST_FILES}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

# Set the version, just in case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ shunit2File="$1"
shift
testFile="$1"
shift
awkFile="${testDir}/test-gen.awk"
awkFile="${outDir}/.test-gen.awk"
cat <<EOF > "${awkFile}"
/^#!.*/ {
print \$0
Expand All @@ -31,7 +31,7 @@ END {
EOF
echo "#!/bin/bash" > "${testFile}"
for file in "$@"; do
outputfile=$(basename "${file}")
awk -f "${awkFile}" "${testDir}/${file}" > "${outDir}/${outputfile}"
echo "/bin/bash ${outDir}/${outputfile}" >> "${testFile}"
filebase=$(basename "${file}")
awk -f "${awkFile}" "${testDir}/${filebase}" > "${outDir}/${filebase}"
echo "/bin/bash ${outDir}/${filebase}" >> "${testFile}"
done

0 comments on commit 409a0d1

Please sign in to comment.