1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-10-24 03:48:58 +03:00

cmake: split integration tests into steps

Closes #1529
This commit is contained in:
Viktor Szakats
2025-01-31 03:32:08 +01:00
parent 131480d2d5
commit 7d5a4c7651
3 changed files with 47 additions and 25 deletions

View File

@@ -52,18 +52,22 @@ jobs:
build_integration:
name: 'integration'
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 5
env:
CC: clang
MAKEFLAGS: -j5
steps:
- name: 'install prereqs'
run: sudo apt-get -o Dpkg::Use-Pty=0 install libssl-dev
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false
- name: 'cmake'
run: |
sudo apt-get -o Dpkg::Use-Pty=0 install libssl-dev
./tests/cmake/test.sh
- name: 'via FetchContent'
run: ./tests/cmake/test.sh FetchContent
- name: 'via add_subdirectory'
run: ./tests/cmake/test.sh add_subdirectory
- name: 'via find_package'
run: ./tests/cmake/test.sh find_package
build_linux:
name: 'linux'

View File

@@ -10,10 +10,17 @@ option(TEST_INTEGRATION_MODE "Integration mode" "find_package")
message(STATUS "TEST_INTEGRATION_MODE: ${TEST_INTEGRATION_MODE}")
if(TEST_INTEGRATION_MODE STREQUAL "FetchContent" AND CMAKE_VERSION VERSION_LESS 3.14)
message(FATAL_ERROR "This test requires CMake 3.14 or upper")
endif()
if(TEST_INTEGRATION_MODE STREQUAL "find_package")
find_package(libssh2 REQUIRED CONFIG)
find_package(libssh2 REQUIRED CONFIG) # test for double-inclusion
foreach(result_var IN ITEMS libssh2_FOUND libssh2_VERSION)
find_package(libssh2 REQUIRED CONFIG) # Double-inclusion test
foreach(result_var IN ITEMS
libssh2_FOUND
libssh2_VERSION
)
if(${result_var})
message(STATUS "${result_var}: |${${result_var}}|")
else()

View File

@@ -3,26 +3,37 @@
# Copyright (C) Viktor Szakats
# SPDX-License-Identifier: BSD-3-Clause
set -e
set -u
set -eu
cd "$(dirname "$0")"
rm -rf bld-fetchcontent; cmake -B bld-fetchcontent \
-DTEST_INTEGRATION_MODE=FetchContent \
-DFROM_GIT_REPO="${PWD}/../.." \
-DFROM_GIT_TAG="$(git rev-parse HEAD)"
cmake --build bld-fetchcontent
mode="${1:-all}"
rm -rf libssh2; ln -s ../.. libssh2
rm -rf bld-add_subdirectory; cmake -B bld-add_subdirectory \
-DTEST_INTEGRATION_MODE=add_subdirectory
cmake --build bld-add_subdirectory
if [ "${mode}" = 'all' ] || [ "${mode}" = 'FetchContent' ]; then
rm -rf bld-fetchcontent
cmake -B bld-fetchcontent \
-DTEST_INTEGRATION_MODE=FetchContent \
-DFROM_GIT_REPO="${PWD}/../.." \
-DFROM_GIT_TAG="$(git rev-parse HEAD)"
cmake --build bld-fetchcontent
fi
rm -rf bld-libssh2; cmake ../.. -B bld-libssh2
cmake --build bld-libssh2
cmake --install bld-libssh2 --prefix bld-libssh2/_pkg
rm -rf bld-find_package; cmake -B bld-find_package \
-DTEST_INTEGRATION_MODE=find_package \
-DCMAKE_PREFIX_PATH="${PWD}/bld-libssh2/_pkg/lib/cmake/libssh2"
cmake --build bld-find_package
if [ "${mode}" = 'all' ] || [ "${mode}" = 'add_subdirectory' ]; then
rm -rf libssh2; ln -s ../.. libssh2
rm -rf bld-add_subdirectory
cmake -B bld-add_subdirectory \
-DTEST_INTEGRATION_MODE=add_subdirectory
cmake --build bld-add_subdirectory
fi
if [ "${mode}" = 'all' ] || [ "${mode}" = 'find_package' ]; then
rm -rf bld-libssh2
cmake ../.. -B bld-libssh2
cmake --build bld-libssh2
cmake --install bld-libssh2 --prefix bld-libssh2/_pkg
rm -rf bld-find_package
cmake -B bld-find_package \
-DTEST_INTEGRATION_MODE=find_package \
-DCMAKE_PREFIX_PATH="${PWD}/bld-libssh2/_pkg/lib/cmake/libssh2"
cmake --build bld-find_package
fi