Skip to content

Commit

Permalink
Detect TAP test prerequisites with CMake
Browse files Browse the repository at this point in the history
CMake now detects if the necessary prerequisites for running TAP
tests are installed on the local system. This includes perl
installation and other dependencies, such as the IPC::Run module and
prove binary.
  • Loading branch information
erimatnor committed Jun 3, 2021
1 parent 5719c50 commit e517283
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/linux-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
sudo apt-get update
sudo apt-get install flex bison lcov systemd-coredump gdb libipc-run-perl libtest-most-perl ${{ matrix.extra_packages }}
- name: Install macOS Dependencies using perl 5.18
- name: Install macOS Dependencies using Perl
if: runner.os == 'macOS'
run: |
sudo perl5.18 -MCPAN -e "CPAN::Shell->notest('install', 'IPC::Run')"
sudo perl5.18 -MCPAN -e "CPAN::Shell->notest('install', 'Test::Most')"
sudo perl -MCPAN -e "CPAN::Shell->notest('install', 'IPC::Run')"
sudo perl -MCPAN -e "CPAN::Shell->notest('install', 'Test::Most')"
# on macOS the path used is depending on the runner version leading to cache failure
# when the runner version changes so we extract runner version from path and add it
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
choco feature disable --name=showDownloadProgress
choco install postgresql${{ matrix.pg }} --version ${{ matrix.pkg_version }} --force -y --install-args="'--prefix $HOME\PostgreSQL\${{ matrix.pg }} --extract-only yes'"
- name: Configure [${{ matrix.build_type }}]
run: cmake -B ${{ matrix.build_type }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DREGRESS_CHECKS=OFF -DPG_PATH="$HOME/PostgreSQL/${{ matrix.pg }}" -DOPENSSL_ROOT_DIR="$HOME/PostgreSQL/${{ matrix.pg }}"
run: cmake -B ${{ matrix.build_type }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DREGRESS_CHECKS=OFF -DPG_PATH="$HOME/PostgreSQL/${{ matrix.pg }}" -DOPENSSL_ROOT_DIR="$HOME/PostgreSQL/${{ matrix.pg }}" -DTAP=OFF
# Build step: could potentially speed things up with --parallel
# <num_cpu> or "-- -m:<num_cpu>", but MSBuild doesn't seem to be
# able to realize interdependencies between targets, which leads
Expand Down
45 changes: 45 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,51 @@ if (CODECOVERAGE)
add_link_options(--coverage)
endif (CODECOVERAGE)

# TAP test support
option(TAP "Enable TAP test support" ON)

if (TAP)
include(FindPerlLibs)
find_package(PerlLibs 5.8)

if (PERLLIBS_FOUND)
get_filename_component(PERL_BIN_PATH ${PERL_EXECUTABLE} DIRECTORY)

find_program(PROVE prove
PATHS
${PERL_BIN_PATH}
"/usr/bin"
NO_DEFAULT_PATH)

if (NOT PROVE)
message(FATAL_ERROR "The prove binary was not found. Disable TAP tests with -DTAP=OFF.")
endif ()
#execute_process(COMMAND ${PERL_EXECUTABLE} -MIPC::Run -e ""
# ERROR_QUIET RESULT_VARIABLE PERL_MODULE_STATUS)

find_file(PERL_IPC_RUN Run.pm
PATHS
"${PERL_PRIVLIB}"
"${PERL_UPDATE_PRIVLIB}"
"${PERL_VENDORLIB}"
"${PERL_SITELIB}"
"/usr/share/perl"
"/usr/share/perl5"
"/usr/share/perl6"
"$ENV{HOME}/perl/lib/perl"
"$ENV{HOME}/perl5/lib/perl5"
"$ENV{HOME}/perl6/lib/perl6"
PATH_SUFFIXES
IPC)

if (NOT PERL_IPC_RUN)
message(FATAL_ERROR "IPC::Run Perl module not found. Disable TAP tests with -DTAP=OFF.")
endif ()
else ()
message(FATAL_ERROR "Perl not found. Disable TAP tests with -DTAP=OFF or set -DPERL_EXECUTABLE=<path/to/perl>. Requires Perl 5.8 or greater (http://perlbrew.pl).")
endif()
endif (TAP)

if (UNIX)
add_subdirectory(scripts)
endif (UNIX)
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ build_script:
# build timescale
.\bootstrap -DUSE_OPENSSL=0 -DPG_PATH="C:\Program Files\PostgreSQL\12" -DREGRESS_CHECKS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CONFIGURATION_TYPES=Debug -DCMAKE_C_FLAGS=/MP
.\bootstrap -DUSE_OPENSSL=0 -DPG_PATH="C:\Program Files\PostgreSQL\12" -DREGRESS_CHECKS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CONFIGURATION_TYPES=Debug -DCMAKE_C_FLAGS=/MP -DTAP=OFF
# Filter ssl and local configuration from pg_hba.conf file since
# we have turned off SSL and local (unix domain socket)
Expand Down Expand Up @@ -178,7 +178,7 @@ build_script:
docker exec -it pgregress /bin/bash -c "git clone --depth 1 https://github.com/timescale/timescaledb.git /timescaledb && cd /timescaledb && git fetch -q origin $commit && git checkout -qf FETCH_HEAD"
docker exec -it pgregress /bin/bash -c "cd /timescaledb && ./bootstrap -DCMAKE_BUILD_TYPE=Debug -DREGRESS_CHECKS=OFF -DPG_REGRESS=/usr/local/bin/pg_regress -DTEST_PGHOST=docker.for.win.localhost -DTEST_PGPORT_LOCAL=55432"
docker exec -it pgregress /bin/bash -c "cd /timescaledb && ./bootstrap -DCMAKE_BUILD_TYPE=Debug -DREGRESS_CHECKS=OFF -DPG_REGRESS=/usr/local/bin/pg_regress -DTEST_PGHOST=docker.for.win.localhost -DTEST_PGPORT_LOCAL=55432 -DTAP=OFF"
test_script:
- ps: >-
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ build_timescaledb()

# Build and install the extension with debug symbols and assertions
tar -c -C ${BASE_DIR} {src,sql,test,scripts,tsl,version.config,CMakeLists.txt,timescaledb.control.in} | docker cp - ${BUILD_CONTAINER_NAME}:/build/
docker exec -u root ${BUILD_CONTAINER_NAME} /bin/bash -c "cd /build/debug && cmake -DUSE_OPENSSL=${USE_OPENSSL} -DREGRESS_CHECKS=OFF -DCMAKE_BUILD_TYPE=${BUILD_TYPE} .. && make && make install && echo \"shared_preload_libraries = 'timescaledb'\" >> /usr/local/share/postgresql/postgresql.conf.sample && echo \"timescaledb.telemetry_level=off\" >> /usr/local/share/postgresql/postgresql.conf.sample && cd / && rm -rf /build"
docker exec -u root ${BUILD_CONTAINER_NAME} /bin/bash -c "cd /build/debug && cmake -DUSE_OPENSSL=${USE_OPENSSL} -DREGRESS_CHECKS=OFF -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DTAP=OFF .. && make && make install && echo \"shared_preload_libraries = 'timescaledb'\" >> /usr/local/share/postgresql/postgresql.conf.sample && echo \"timescaledb.telemetry_level=off\" >> /usr/local/share/postgresql/postgresql.conf.sample && cd / && rm -rf /build"
if [ $? -ne 0 ]; then
echo "Building timescaledb failed"
return 1
Expand Down
11 changes: 5 additions & 6 deletions tsl/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ add_subdirectory(ssl)
set(_local_install_checks)
set(_install_checks)

find_program(PROVE prove
"/usr/bin")

if(PG_REGRESS)
add_custom_target(regresscheck-t
COMMAND ${CMAKE_COMMAND} -E env
Expand Down Expand Up @@ -62,6 +59,7 @@ if(PG_REGRESS)
${PG_REGRESS_OPTS_LOCAL_INSTANCE}
USES_TERMINAL)

if (TAP)
add_custom_target(provecheck
COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/tmp_check
COMMAND BUILDIR=${CMAKE_BINARY_DIR}
Expand All @@ -71,12 +69,13 @@ if(PG_REGRESS)
PG_REGRESS=${PG_REGRESS}
${PROVE} -I "${PG_SOURCE_DIR}/src/test/perl"
-I "${CMAKE_SOURCE_DIR}/test/perl"
-I "$ENV{HOME}/perl5/lib/perl5"
-I "${PERL_PRIVLIB}"
t/*.pl
USES_TERMINAL)

list(APPEND _install_checks regresscheck-shared)
list(APPEND _install_checks provecheck)
endif()

list(APPEND _install_checks regresscheck-shared)
list(APPEND _local_install_checks regresschecklocal-shared)

endif()
Expand Down

0 comments on commit e517283

Please sign in to comment.