Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect TAP test prerequisites with CMake #3299

Merged
merged 1 commit into from Jun 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/linux-build-and-test.yaml
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')"
nikkhils marked this conversation as resolved.
Show resolved Hide resolved
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
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_CHECKS=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
32 changes: 32 additions & 0 deletions CMakeLists.txt
Expand Up @@ -487,6 +487,38 @@ if (CODECOVERAGE)
add_link_options(--coverage)
endif (CODECOVERAGE)

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

if (TAP_CHECKS)
find_package(Perl 5.8)

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

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

if (NOT PROVE)
message(FATAL_ERROR "The prove binary was not found. Disable TAP tests with -DTAP_CHECKS=OFF.")
endif ()

# Check for the IPC::Run module
execute_process(COMMAND ${PERL_EXECUTABLE} -MIPC::Run -e ""
ERROR_QUIET RESULT_VARIABLE PERL_MODULE_STATUS)

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

if (UNIX)
add_subdirectory(scripts)
endif (UNIX)
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
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_CHECKS=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_CHECKS=OFF"

test_script:
- ps: >-
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker-build.sh
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_CHECKS=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
8 changes: 3 additions & 5 deletions tsl/test/CMakeLists.txt
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_CHECKS)
add_custom_target(provecheck
COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/tmp_check
COMMAND BUILDIR=${CMAKE_BINARY_DIR}
Expand All @@ -71,12 +69,12 @@ 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"
t/*.pl
USES_TERMINAL)
list(APPEND _install_checks provecheck)
endif()

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

endif()
Expand Down