diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2024-05-21 01:29:20 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2024-05-21 01:29:20 +0200 |
commit | b54b8f5b25403cf3b9623804b2491ec78a8b913e (patch) | |
tree | 8100b69a2fd1e37d1eb400a33c92ec3c984f208b /tests | |
parent | 0bbc18869720ad042b668742ca48e5cb8a37491a (diff) | |
download | blogc-b54b8f5b25403cf3b9623804b2491ec78a8b913e.tar.gz blogc-b54b8f5b25403cf3b9623804b2491ec78a8b913e.tar.bz2 blogc-b54b8f5b25403cf3b9623804b2491ec78a8b913e.zip |
build: replace autotools with cmake
this patch removes all the autoconf/automake/libtool build
infrastructure and replaces it with cmake.
notable default behavior changes:
- man pages are not pre-built, and are not built by default, must be
enabled with `-DBUILD_MANPAGES=ON`.
removed features:
- srpm packaging, to be reintroduced at some point.
- deb packaging, now handled externally via rafaelmartins/deb.rgm.io
more stuff must be missing, please report bugs!
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 91 | ||||
-rw-r--r-- | tests/blogc-git-receiver/CMakeLists.txt | 19 | ||||
-rwxr-xr-x | tests/blogc-git-receiver/check_post_receive.sh.in | 4 | ||||
-rwxr-xr-x | tests/blogc-git-receiver/check_pre_receive.sh.in | 4 | ||||
-rwxr-xr-x | tests/blogc-git-receiver/check_shell.sh.in | 3 | ||||
-rw-r--r-- | tests/blogc-make/CMakeLists.txt | 19 | ||||
-rwxr-xr-x | tests/blogc-make/check_blogc_make.sh.in | 47 | ||||
-rw-r--r-- | tests/blogc-runserver/CMakeLists.txt | 11 | ||||
-rw-r--r-- | tests/blogc/CMakeLists.txt | 33 | ||||
-rwxr-xr-x | tests/blogc/check_blogc.sh.in | 48 | ||||
-rw-r--r-- | tests/common/CMakeLists.txt | 12 |
11 files changed, 242 insertions, 49 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..e1ca881 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,91 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +find_package(PkgConfig REQUIRED) +pkg_check_modules(CMOCKA IMPORTED_TARGET cmocka) + +find_program(BASH bash HINTS /bin /usr/bin REQUIRED) +find_program(DIFF diff REQUIRED) +find_program(TEE tee REQUIRED) + +try_compile(HAVE_LD_WRAP + SOURCE_FROM_CONTENT + main.c + "#include <stdlib.h>\nvoid __real_exit(int status);\nvoid __wrap_exit(int s){__real_exit(0);}\nint main(){exit(1);}" + LINK_OPTIONS + "-Wl,--wrap=exit" +) + +function(blogc_executable_test _libname _src) + if (NOT CMOCKA_FOUND) + message(STATUS "Skipping test (cmocka not found): ${_libname}_check_${_src}") + return() + endif() + + cmake_parse_arguments(_blogc_executable_test + "" + "" + "WRAP" + ${ARGN} + ) + + if(DEFINED _blogc_executable_test_WRAP) + if(NOT HAVE_LD_WRAP) + message(STATUS "Skipping test (no ld wrap): ${_libname}_check_${_src}") + return() + endif() + endif() + + add_executable(${_libname}_check_${_src} + check_${_src}.c + ) + + if(DEFINED _blogc_executable_test_WRAP) + list(JOIN _blogc_executable_test_WRAP ",--wrap=" _wrap) + set_target_properties(${_libname}_check_${_src} + PROPERTIES LINK_FLAGS + "-Wl,--wrap=${_wrap}" + ) + endif() + + target_link_libraries(${_libname}_check_${_src} PRIVATE + PkgConfig::CMOCKA + lib${_libname} + ) + + add_test( + NAME ${_libname}_check_${_src} + COMMAND + ${CMAKE_SOURCE_DIR}/cmake/scripts/test.sh + ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_check_${_src} + ) +endfunction() + +function(blogc_script_test _libname _src) + configure_file( + check_${_src}.sh.in + ${_libname}_check_${_src}.sh + @ONLY + ) + add_test( + NAME ${_libname}_check_${_src}.sh + COMMAND + ${CMAKE_SOURCE_DIR}/cmake/scripts/test.sh + ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_check_${_src}.sh + ) +endfunction() + +add_subdirectory(common) +add_subdirectory(blogc) + +if(BUILD_BLOGC_MAKE OR BUILD_BLOGC_MAKE_EMBEDDED) + add_subdirectory(blogc-make) +endif() + +if(BUILD_BLOGC_RUNSERVER) + add_subdirectory(blogc-runserver) +endif() + +if(BUILD_BLOGC_GIT_RECEIVER) + add_subdirectory(blogc-git-receiver) +endif() diff --git a/tests/blogc-git-receiver/CMakeLists.txt b/tests/blogc-git-receiver/CMakeLists.txt new file mode 100644 index 0000000..c0e88a7 --- /dev/null +++ b/tests/blogc-git-receiver/CMakeLists.txt @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +if(NOT Git_FOUND) + message(FATAL_ERROR "blogc-git-receiver tests require Git.") +endif() + +find_program(MAKE make gmake REQUIRED) +find_program(TAR tar REQUIRED) + +blogc_executable_test(blogc_git_receiver pre_receive_parser) +blogc_executable_test(blogc_git_receiver settings + WRAP + realpath +) +blogc_executable_test(blogc_git_receiver shell_command_parser) +blogc_script_test(blogc_git_receiver post_receive) +blogc_script_test(blogc_git_receiver pre_receive) +blogc_script_test(blogc_git_receiver shell) diff --git a/tests/blogc-git-receiver/check_post_receive.sh.in b/tests/blogc-git-receiver/check_post_receive.sh.in index 53535f4..831e032 100755 --- a/tests/blogc-git-receiver/check_post_receive.sh.in +++ b/tests/blogc-git-receiver/check_post_receive.sh.in @@ -7,6 +7,8 @@ set -xe -o pipefail export LC_ALL=C +export BLOGC_GIT_RECEIVER="@CMAKE_BINARY_DIR@/src/blogc-git-receiver/blogc-git-receiver" + TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -20,7 +22,7 @@ trap trap_func EXIT mkdir -p "${TEMP}/repos" git init --bare "${TEMP}/repos/foo.git" &> /dev/null -ln -s "@abs_top_builddir@/blogc-git-receiver" "${TEMP}/repos/foo.git/hooks/post-receive" +ln -s "${BLOGC_GIT_RECEIVER}" "${TEMP}/repos/foo.git/hooks/post-receive" cat > "${TEMP}/tmp.txt" <<EOF blob diff --git a/tests/blogc-git-receiver/check_pre_receive.sh.in b/tests/blogc-git-receiver/check_pre_receive.sh.in index 2c36f4c..6a5dd30 100755 --- a/tests/blogc-git-receiver/check_pre_receive.sh.in +++ b/tests/blogc-git-receiver/check_pre_receive.sh.in @@ -7,6 +7,8 @@ set -xe -o pipefail export LC_ALL=C +export BLOGC_GIT_RECEIVER="@CMAKE_BINARY_DIR@/src/blogc-git-receiver/blogc-git-receiver" + TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -20,7 +22,7 @@ trap trap_func EXIT mkdir -p "${TEMP}/repos" git init --bare "${TEMP}/repos/foo.git" &> /dev/null -SELF="@abs_top_builddir@/blogc-git-receiver" +SELF="${BLOGC_GIT_RECEIVER}" ln -s "${SELF}" "${TEMP}/repos/foo.git/hooks/pre-receive" diff --git a/tests/blogc-git-receiver/check_shell.sh.in b/tests/blogc-git-receiver/check_shell.sh.in index bf25029..fca9dea 100755 --- a/tests/blogc-git-receiver/check_shell.sh.in +++ b/tests/blogc-git-receiver/check_shell.sh.in @@ -6,6 +6,7 @@ set -xe -o pipefail export LC_ALL=C +export BLOGC_GIT_RECEIVER="@CMAKE_BINARY_DIR@/src/blogc-git-receiver/blogc-git-receiver" TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -17,7 +18,7 @@ trap_func() { trap trap_func EXIT -SELF="@abs_top_builddir@/blogc-git-receiver" +SELF="${BLOGC_GIT_RECEIVER}" call_bgr() { [[ -n "${VALGRIND}" ]] && export __VALGRIND_ENABLED=1 diff --git a/tests/blogc-make/CMakeLists.txt b/tests/blogc-make/CMakeLists.txt new file mode 100644 index 0000000..9990eae --- /dev/null +++ b/tests/blogc-make/CMakeLists.txt @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +blogc_executable_test(blogc_make atom) +blogc_executable_test(blogc_make exec + WRAP + access +) +blogc_executable_test(blogc_make rules) +blogc_executable_test(blogc_make settings) +blogc_executable_test(blogc_make utils) + +if(BUILD_BLOGC_MAKE_EMBEDDED) + set(_BLOGC_MAKE "${CMAKE_BINARY_DIR}/src/blogc/blogc -m") +else() + set(_BLOGC_MAKE "${CMAKE_BINARY_DIR}/src/blogc-make/blogc-make") +endif() + +blogc_script_test(blogc_make blogc_make) diff --git a/tests/blogc-make/check_blogc_make.sh.in b/tests/blogc-make/check_blogc_make.sh.in index d999840..429632c 100755 --- a/tests/blogc-make/check_blogc_make.sh.in +++ b/tests/blogc-make/check_blogc_make.sh.in @@ -7,7 +7,8 @@ set -xe -o pipefail export LC_ALL=C -export BLOGC=@abs_top_builddir@/blogc +export BLOGC="@CMAKE_BINARY_DIR@/src/blogc/blogc" +export BLOGC_MAKE="@_BLOGC_MAKE@" TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -33,7 +34,7 @@ SITE_TAGLINE = WAT?! BASE_DOMAIN = http://example.org EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 ### default settings with some posts @@ -81,7 +82,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/page/1/index\\.html" "${TEMP}/output.txt" @@ -198,7 +199,7 @@ post10 post11 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/post/post01/index\\.html" "${TEMP}/output.txt" @@ -487,7 +488,7 @@ cat > "${TEMP}/proj/templates/atom.tmpl" <<EOF </feed> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/post/post01/index\\.html" "${TEMP}/output.txt" @@ -695,7 +696,7 @@ post10 post11 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/post/post01/index\\.html" "${TEMP}/output.txt" grep "_build/post/post02/index\\.html" "${TEMP}/output.txt" grep "_build/post/post03/index\\.html" "${TEMP}/output.txt" @@ -769,7 +770,7 @@ qwe asd EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/post/post01/index\\.html" "${TEMP}/output.txt" grep "_build/post/post02/index\\.html" "${TEMP}/output.txt" grep "_build/post/post03/index\\.html" "${TEMP}/output.txt" @@ -874,7 +875,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/page/1/index\\.html" "${TEMP}/output.txt" @@ -981,7 +982,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/page/1/index\\.html" "${TEMP}/output.txt" @@ -1096,7 +1097,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/page/1/index\\.html" "${TEMP}/output.txt" @@ -1203,7 +1204,7 @@ tag1 tag2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/atom/tag1\\.xml" "${TEMP}/output.txt" @@ -1408,7 +1409,7 @@ page1 page2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/atom/tag1\\.xml" "${TEMP}/output.txt" @@ -1531,7 +1532,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/pagination/1\\.html" "${TEMP}/output.txt" @@ -1631,7 +1632,7 @@ tag1 tag2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1780,7 +1781,7 @@ page1 page2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1864,7 +1865,7 @@ d/xd f EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1903,7 +1904,7 @@ test "$(cat "${TEMP}/proj/_build/f/XDDDD")" = "FFFUUUUUU" ### clean rule -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" clean 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" clean 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1936,7 +1937,7 @@ rm "${TEMP}/output.txt" export OUTPUT_DIR="${TEMP}/___blogc_build" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "___blogc_build/posts\\.html" "${TEMP}/output.txt" grep "___blogc_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "___blogc_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1965,7 +1966,7 @@ grep "___blogc_build/f/XDDDD" "${TEMP}/output.txt" rm "${TEMP}/output.txt" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" clean 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" clean 2>&1 | tee "${TEMP}/output.txt" grep "___blogc_build/posts\\.html" "${TEMP}/output.txt" grep "___blogc_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "___blogc_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -2001,7 +2002,7 @@ unset OUTPUT_DIR ### atom_dump rule -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" atom_dump | tee "${TEMP}/atom.xml" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" atom_dump | tee "${TEMP}/atom.xml" cat > "${TEMP}/expected-atom-dump.xml" <<EOF <?xml version="1.0" encoding="utf-8"?> @@ -2101,7 +2102,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/index\\.xml" "${TEMP}/output.txt" grep "_build/1/index\\.html" "${TEMP}/output.txt" @@ -2231,7 +2232,7 @@ tag1 tag2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/index\\.xml" "${TEMP}/output.txt" grep "_build/tag1/index\\.xml" "${TEMP}/output.txt" @@ -2406,7 +2407,7 @@ page1 page2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/index\\.xml" "${TEMP}/output.txt" grep "_build/tag1/index\\.xml" "${TEMP}/output.txt" diff --git a/tests/blogc-runserver/CMakeLists.txt b/tests/blogc-runserver/CMakeLists.txt new file mode 100644 index 0000000..b2cdc4d --- /dev/null +++ b/tests/blogc-runserver/CMakeLists.txt @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +blogc_executable_test(blogc_runserver httpd_utils + WRAP + read +) +blogc_executable_test(blogc_runserver mime + WRAP + access +) diff --git a/tests/blogc/CMakeLists.txt b/tests/blogc/CMakeLists.txt new file mode 100644 index 0000000..0156d7a --- /dev/null +++ b/tests/blogc/CMakeLists.txt @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +blogc_executable_test(blogc content_parser) +blogc_executable_test(blogc datetime_parser) +blogc_executable_test(blogc filelist_parser) +blogc_executable_test(blogc funcvars + WRAP + bc_file_get_contents +) +blogc_executable_test(blogc loader + WRAP + bc_file_get_contents +) +blogc_executable_test(blogc renderer) +blogc_executable_test(blogc rusage + WRAP + getrusage +) +blogc_executable_test(blogc source_parser) +blogc_executable_test(blogc sysinfo + WRAP + bc_file_get_contents + getenv + gethostbyname + gethostname + gmtime + time +) +blogc_executable_test(blogc sysinfo2) +blogc_executable_test(blogc template_parser) +blogc_executable_test(blogc toctree) +blogc_script_test(blogc blogc) diff --git a/tests/blogc/check_blogc.sh.in b/tests/blogc/check_blogc.sh.in index 8b23d3e..2bb2d75 100755 --- a/tests/blogc/check_blogc.sh.in +++ b/tests/blogc/check_blogc.sh.in @@ -7,6 +7,8 @@ set -xe -o pipefail export LC_ALL=C +export BLOGC="@CMAKE_BINARY_DIR@/src/blogc/blogc" + TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -16,7 +18,7 @@ trap_func() { trap trap_func EXIT -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc -v | grep blogc +${TESTS_ENVIRONMENT} ${BLOGC} -v | grep blogc cat > "${TEMP}/post1.txt" <<EOF TITLE: foo @@ -112,7 +114,7 @@ cat > "${TEMP}/expected-output.xml" <<EOF </feed> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D AUTHOR_NAME=Chunda \ @@ -126,7 +128,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output.xml" "${TEMP}/expected-output.xml" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D AUTHOR_NAME=Chunda \ @@ -140,7 +142,7 @@ echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_b diff -uN "${TEMP}/output2.xml" "${TEMP}/expected-output.xml" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D AUTHOR_NAME=Chunda \ @@ -153,7 +155,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output3.xml" "${TEMP}/expected-output.xml" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D AUTHOR_NAME=Chunda \ @@ -259,7 +261,7 @@ cat > "${TEMP}/expected-output.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -272,7 +274,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output.html" "${TEMP}/expected-output.html" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -285,7 +287,7 @@ echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_b diff -uN "${TEMP}/output2.html" "${TEMP}/expected-output.html" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -297,7 +299,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output3.html" "${TEMP}/expected-output.html" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -342,7 +344,7 @@ cat > "${TEMP}/expected-output2.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -353,7 +355,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output5.html" "${TEMP}/expected-output2.html" -echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -364,7 +366,7 @@ echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output6.html" "${TEMP}/expected-output2.html" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -374,7 +376,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output7.html" "${TEMP}/expected-output2.html" -echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -422,7 +424,7 @@ cat > "${TEMP}/expected-output3.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -435,7 +437,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output9.html" "${TEMP}/expected-output3.html" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -448,7 +450,7 @@ echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_b diff -uN "${TEMP}/output10.html" "${TEMP}/expected-output3.html" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -460,7 +462,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output11.html" "${TEMP}/expected-output3.html" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -510,7 +512,7 @@ cat > "${TEMP}/expected-output4.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -565,7 +567,7 @@ cat > "${TEMP}/expected-output5.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -607,7 +609,7 @@ cat > "${TEMP}/expected-output6.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -620,20 +622,20 @@ diff -uN "${TEMP}/output15.html" "${TEMP}/expected-output6.html" echo "{% block listig %}foo{% endblock %}\n" > "${TEMP}/error.tmpl" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -t "${TEMP}/error.tmpl" \ "${TEMP}/post1.txt" 2>&1 | tee "${TEMP}/output.txt" || true grep "blogc: error: template: Invalid block type" "${TEMP}/output.txt" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D 123=a 2>&1 | tee "${TEMP}/output.txt" || true grep \ "blogc: error: invalid value for -D (first character in configuration key must be uppercase): 123" \ "${TEMP}/output.txt" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D A1-3=a 2>&1 | tee "${TEMP}/output.txt" || true grep \ diff --git a/tests/common/CMakeLists.txt b/tests/common/CMakeLists.txt new file mode 100644 index 0000000..9d784fa --- /dev/null +++ b/tests/common/CMakeLists.txt @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +blogc_executable_test(blogc_common config_parser) +blogc_executable_test(blogc_common error) +blogc_executable_test(blogc_common sort) +blogc_executable_test(blogc_common stdin + WRAP + fgetc +) +blogc_executable_test(blogc_common utf8) +blogc_executable_test(blogc_common utils) |