diff --git a/.codeql-prebuild-cpp-Linux.sh b/.codeql-prebuild-cpp-Linux.sh index 244c0531..8f31178f 100644 --- a/.codeql-prebuild-cpp-Linux.sh +++ b/.codeql-prebuild-cpp-Linux.sh @@ -63,6 +63,7 @@ sudo update-alternatives --install \ mkdir -p build cd build || exit 1 cmake \ + -DBUILD_DOCS=OFF \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \ -G "Unix Makefiles" \ .. diff --git a/.codeql-prebuild-cpp-Windows.sh b/.codeql-prebuild-cpp-Windows.sh index 79158ebf..31ee6cd9 100644 --- a/.codeql-prebuild-cpp-Windows.sh +++ b/.codeql-prebuild-cpp-Windows.sh @@ -35,7 +35,9 @@ pacman -Syu --noconfirm --ignore=mingw-w64-ucrt-x86_64-curl \ # build mkdir -p build cd build || exit 1 -cmake -G "MinGW Makefiles" .. +cmake \ + -DBUILD_DOCS=OFF \ + -G "MinGW Makefiles" .. mingw32-make -j"$(nproc)" # skip autobuild diff --git a/.codeql-prebuild-cpp-macOS.sh b/.codeql-prebuild-cpp-macOS.sh index 25a364c9..0a505136 100644 --- a/.codeql-prebuild-cpp-macOS.sh +++ b/.codeql-prebuild-cpp-macOS.sh @@ -15,6 +15,7 @@ mkdir -p build cd build || exit 1 cmake \ -DBOOST_USE_STATIC=OFF \ + -DBUILD_DOCS=OFF \ -G "Unix Makefiles" .. make -j"$(sysctl -n hw.logicalcpu)" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index abb4d258..7ed9fa9f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -251,6 +251,8 @@ jobs: sudo apt-get install -y \ build-essential \ cmake \ + doxygen \ + graphviz \ gcc-10 \ g++-10 \ libayatana-appindicator3-dev \ @@ -277,7 +279,8 @@ jobs: libxfixes-dev \ libxrandr-dev \ libxtst-dev \ - python3 + python3 \ + python3-venv # clean apt cache sudo apt-get clean @@ -414,9 +417,6 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y \ - doxygen \ - graphviz \ - python3-venv \ x11-xserver-utils \ xvfb @@ -803,9 +803,6 @@ jobs: working-directory: /opt/local/var/macports/build/_Users_runner_work_Sunshine_Sunshine_ports_multimedia_Sunshine/Sunshine/work/build/tests run: | - sudo port install \ - doxygen \ - graphviz sudo ./test_sunshine --gtest_color=yes - name: Generate gcov report @@ -1038,8 +1035,8 @@ jobs: cmake \ -DBUILD_WERROR=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DPython_EXECUTABLE='${{ steps.python-path.outputs.python-path }}' \ -DSUNSHINE_ASSETS_DIR=assets \ - -DTESTS_PYTHON_EXECUTABLE='${{ steps.python-path.outputs.python-path }}' \ -DTESTS_SOFTWARE_ENCODER_UNAVAILABLE='skip' \ -G "MinGW Makefiles" \ .. diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake index 8772d6d2..f358f727 100644 --- a/cmake/prep/options.cmake +++ b/cmake/prep/options.cmake @@ -1,3 +1,4 @@ +option(BUILD_DOCS "Build documentation" ON) option(BUILD_TESTS "Build tests" ON) option(TESTS_ENABLE_PYTHON_TESTS "Enable Python tests" ON) diff --git a/cmake/targets/common.cmake b/cmake/targets/common.cmake index baa1bce1..8ceae30c 100644 --- a/cmake/targets/common.cmake +++ b/cmake/targets/common.cmake @@ -61,6 +61,11 @@ add_custom_target(web-ui ALL COMMAND_EXPAND_LISTS VERBATIM) +# docs +if(BUILD_DOCS) + add_subdirectory(docs) +endif() + # tests if(BUILD_TESTS) add_subdirectory(tests) diff --git a/docker/debian-bullseye.dockerfile b/docker/debian-bullseye.dockerfile index c2f6172a..d446045c 100644 --- a/docker/debian-bullseye.dockerfile +++ b/docker/debian-bullseye.dockerfile @@ -32,7 +32,6 @@ apt-get update -y apt-get install -y --no-install-recommends \ build-essential \ ca-certificates \ - cmake=3.18.* \ doxygen \ git \ graphviz \ @@ -67,6 +66,27 @@ apt-get clean rm -rf /var/lib/apt/lists/* _DEPS +# install cmake +# sunshine requires cmake >= 3.19 +WORKDIR /build/cmake +# https://cmake.org/download/ +ENV CMAKE_VERSION="3.29.6" +# hadolint ignore=SC3010 +RUN <<_INSTALL_CMAKE +#!/bin/bash +cmake_prefix="https://github.com/Kitware/CMake/releases/download/v" +if [[ "${TARGETPLATFORM}" == 'linux/amd64' ]]; then + cmake_arch="x86_64" +elif [[ "${TARGETPLATFORM}" == 'linux/arm64' ]]; then + cmake_arch="aarch64" +fi +url="${cmake_prefix}${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${cmake_arch}.sh" +echo "cmake url: ${url}" +wget "$url" --progress=bar:force:noscroll -q --show-progress -O ./cmake.sh +sh ./cmake.sh --prefix=/usr/local --skip-license +cmake --version +_INSTALL_CMAKE + #Install Node # hadolint ignore=SC1091 RUN <<_INSTALL_NODE diff --git a/docker/fedora-39.dockerfile b/docker/fedora-39.dockerfile index 6ed9f1fb..40d45ed1 100644 --- a/docker/fedora-39.dockerfile +++ b/docker/fedora-39.dockerfile @@ -107,6 +107,7 @@ RUN <<_MAKE set -e cmake \ -DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \ + -DBUILD_DOCS=OFF \ -DBUILD_WERROR=ON \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ @@ -116,7 +117,6 @@ cmake \ -DSUNSHINE_ENABLE_X11=ON \ -DSUNSHINE_ENABLE_DRM=ON \ -DSUNSHINE_ENABLE_CUDA=ON \ - -DTESTS_ENABLE_PYTHON_TESTS=OFF \ /build/sunshine make -j "$(nproc)" cpack -G RPM diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 00000000..3556e1a6 --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1,114 @@ +cmake_minimum_required(VERSION 3.19) + +# find doxygen and graphviz +find_package(Doxygen + REQUIRED dot) + +if(POLICY CMP0094) # https://cmake.org/cmake/help/latest/policy/CMP0094.html + cmake_policy(SET CMP0094 NEW) # FindPython should return the first matching Python +endif() + +# needed on GitHub Actions CI: actions/setup-python does not touch registry/frameworks on Windows/macOS +# this mirrors PythonInterp behavior which did not consult registry/frameworks first +if(NOT DEFINED Python_FIND_REGISTRY) + set(Python_FIND_REGISTRY "LAST") # cmake-lint: disable=C0103 +endif() +if(NOT DEFINED Python_FIND_FRAMEWORK) + set(Python_FIND_FRAMEWORK "LAST") # cmake-lint: disable=C0103 +endif() + +# find python +if(NOT DEFINED Python_EXECUTABLE) + find_package(Python3 3.9 REQUIRED COMPONENTS Interpreter) +else() + set(Python3_EXECUTABLE "${Python_EXECUTABLE}") # cmake-lint: disable=C0103 + message(STATUS "Using Python3_EXECUTABLE: ${Python3_EXECUTABLE}") +endif() + +# create venv in build dir +set(VENV_DIR "${CMAKE_BINARY_DIR}/venv") + +# create venv +execute_process( + COMMAND ${Python3_EXECUTABLE} -m venv ${VENV_DIR} + COMMAND_ERROR_IS_FATAL LAST + RESULT_VARIABLE VENV_RESULT +) + +# set Python3_EXECUTABLE to the python interpreter in the venv +if(WIN32) + set(Python3_EXECUTABLE "${VENV_DIR}/Scripts/python.exe") # cmake-lint: disable=C0103 + set(Python3_ROOT_DIR "${VENV_DIR}/Scripts") # cmake-lint: disable=C0103 +else() + set(Python3_EXECUTABLE "${VENV_DIR}/bin/python") # cmake-lint: disable=C0103 + set(Python3_ROOT_DIR "${VENV_DIR}/bin") # cmake-lint: disable=C0103 +endif() + +# print path +message(STATUS "Python3_EXECUTABLE: ${Python3_EXECUTABLE}") + +# call a simple python command +execute_process( + COMMAND ${Python3_EXECUTABLE} -c "print(' Testing Python3_EXECUTABLE')" + COMMAND_ERROR_IS_FATAL ANY + RESULT_VARIABLE PYTHON_RESULT +) + +# fail if the python command failed +if(NOT PYTHON_RESULT EQUAL 0) + message(FATAL_ERROR "Python3_EXECUTABLE failed") +endif() + +# install doc requirements +execute_process( + COMMAND ${Python3_EXECUTABLE} -m pip install -r ${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt + COMMAND_ERROR_IS_FATAL ANY + RESULT_VARIABLE PIP_RESULT +) + +# rst check +set(RST_PATTERNS + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/README.rst +) + +# check rst files +foreach(pattern ${RST_PATTERNS}) + message(STATUS "Checking RST files: ${pattern}") + execute_process( + COMMAND "${Python3_ROOT_DIR}/rstcheck" -r "${pattern}" + COMMAND_ERROR_IS_FATAL ANY + RESULT_VARIABLE RST_RESULT + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) +endforeach() + +# commands +list(APPEND SPHINX_BUILD_HTML_COMMAND + "${Python3_ROOT_DIR}/sphinx-build" + "-M" + "html" + "${CMAKE_CURRENT_SOURCE_DIR}/source" + "${CMAKE_CURRENT_BINARY_DIR}/build/html" + "-W" + "--keep-going" +) + +list(APPEND SPHINX_BUILD_EPUB_COMMAND + "${Python3_ROOT_DIR}/sphinx-build" + "-M" + "epub" + "${CMAKE_CURRENT_SOURCE_DIR}/source" + "${CMAKE_CURRENT_BINARY_DIR}/build/epub" + "-W" + "--keep-going" +) + +# build docs +add_custom_target(docs ALL + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + COMMENT "Building documentation" + COMMAND ${SPHINX_BUILD_HTML_COMMAND} + COMMAND ${SPHINX_BUILD_EPUB_COMMAND} + VERBATIM +) diff --git a/packaging/linux/Arch/PKGBUILD b/packaging/linux/Arch/PKGBUILD index bda90acd..a24af08f 100644 --- a/packaging/linux/Arch/PKGBUILD +++ b/packaging/linux/Arch/PKGBUILD @@ -32,16 +32,16 @@ depends=('avahi' 'numactl' 'openssl' 'opus' - 'python' 'udev') -checkdepends=('doxygen' - 'graphviz') makedepends=('cmake' + 'doxygen' "gcc${_gcc_version}" + 'graphviz' 'git' 'make' 'nodejs' - 'npm') + 'npm' + 'python') optdepends=('cuda: Nvidia GPU encoding support' 'libva-mesa-driver: AMD GPU encoding support' 'xorg-server-xvfb: Virtual X server for headless testing') diff --git a/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml b/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml index 1fe3eb19..d065b343 100644 --- a/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml +++ b/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml @@ -274,6 +274,7 @@ modules: npm_config_nodedir: /usr/lib/sdk/node18 NPM_CONFIG_LOGLEVEL: info config-opts: + - -DBUILD_DOCS=OFF - -DBUILD_WERROR=ON - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX=/app @@ -285,7 +286,6 @@ modules: - -DSUNSHINE_ENABLE_DRM=ON - -DSUNSHINE_ENABLE_CUDA=ON - -DSUNSHINE_BUILD_FLATPAK=ON - - -DTESTS_ENABLE_PYTHON_TESTS=OFF sources: - type: git url: "@GITHUB_CLONE_URL@" diff --git a/packaging/macos/Portfile b/packaging/macos/Portfile index 81526b1f..4a89b1d8 100644 --- a/packaging/macos/Portfile +++ b/packaging/macos/Portfile @@ -31,18 +31,17 @@ post-fetch { } # https://guide.macports.org/chunked/reference.dependencies.html -depends_build-append port:npm9 \ - port:pkgconfig +depends_build-append port:doxygen \ + port:graphviz \ + port:npm9 \ + port:pkgconfig \ + port:python311 \ + port:py311-pip depends_lib port:avahi \ port:curl \ port:libopus \ - port:miniupnpc \ - port:python311 \ - port:py311-pip - -depends_test port:doxygen \ - port:graphviz + port:miniupnpc configure.args -DBOOST_USE_STATIC=ON \ -DBUILD_WERROR=ON \ diff --git a/packaging/sunshine.rb b/packaging/sunshine.rb index a634931e..78d8f3e7 100644 --- a/packaging/sunshine.rb +++ b/packaging/sunshine.rb @@ -21,10 +21,13 @@ class @PROJECT_NAME@ < Formula end end - option "without-dynamic-boost", "Statically link Boost libraries" # default option + option "with-docs-off", "Disable docs" option "with-dynamic-boost", "Dynamically link Boost libraries" + option "without-dynamic-boost", "Statically link Boost libraries" # default option depends_on "cmake" => :build + depends_on "doxygen" => :build + depends_on "graphviz" => :build depends_on "node" => :build depends_on "pkg-config" => :build depends_on "curl" @@ -66,9 +69,16 @@ class @PROJECT_NAME@ < Formula -DSUNSHINE_ASSETS_DIR=sunshine/assets -DSUNSHINE_BUILD_HOMEBREW=ON -DSUNSHINE_ENABLE_TRAY=OFF - -DTESTS_ENABLE_PYTHON_TESTS=OFF ] + if build.with? "docs-off" + ohai "Building docs: disabled" + args << "-DBUILD_DOCS=OFF" + else + ohai "Building docs: enabled" + args << "-DBUILD_DOCS=ON" + end + if build.without? "dynamic-boost" args << "-DBOOST_USE_STATIC=ON" ohai "Statically linking Boost libraries" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a4e981b6..d49272f6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,9 +3,6 @@ cmake_minimum_required(VERSION 3.13) project(test_sunshine) -set(PYTHON_PREFERRED_VERSION 3.11) -set(PYTHON_MINIMUM_VERSION 3.9) - include_directories("${CMAKE_SOURCE_DIR}") enable_testing() @@ -38,55 +35,6 @@ endif () set(TEST_DEFINITIONS) # list will be appended as needed -# IF option TESTS_ENABLE_PYTHON_TESTS is ON, then we need to find python -if (TESTS_ENABLE_PYTHON_TESTS) - if (NOT DEFINED TESTS_PYTHON_EXECUTABLE) - # python is required for doc tests - - # https://github.com/actions/setup-python/issues/121#issuecomment-777748504 - if (POLICY CMP0094) # https://cmake.org/cmake/help/latest/policy/CMP0094.html - cmake_policy(SET CMP0094 NEW) # FindPython should return the first matching Python - endif () - - # needed on GitHub Actions CI: actions/setup-python does not touch registry/frameworks on Windows/macOS - # this mirrors PythonInterp behavior which did not consult registry/frameworks first - if (NOT DEFINED Python_FIND_REGISTRY) - set(Python_FIND_REGISTRY "LAST") # cmake-lint: disable=C0103 - endif () - if (NOT DEFINED Python_FIND_FRAMEWORK) - set(Python_FIND_FRAMEWORK "LAST") # cmake-lint: disable=C0103 - endif () - - # first, try to find preferred version of python - find_package(Python ${PYTHON_PREFERRED_VERSION} EXACT COMPONENTS Interpreter) - if (Python_FOUND) - message(STATUS - "Preferred Python ${PYTHON_PREFERRED_VERSION} found, tests dependent on Python will be enabled") - else () - # fallback to minimum version - find_package(Python ${PYTHON_MINIMUM_VERSION} COMPONENTS Interpreter) - endif () - if (Python_FOUND) - message(STATUS "Python found, tests dependent on Python will be enabled") - list(APPEND TEST_DEFINITIONS TESTS_ENABLE_VENV_TESTS=1) - list(APPEND TEST_DEFINITIONS TESTS_PYTHON_EXECUTABLE="${Python_EXECUTABLE}") - else () - message(SEND_ERROR "Python not found, tests dependent on Python will be disabled") - list(APPEND TEST_DEFINITIONS TESTS_ENABLE_VENV_TESTS=0) - endif () - else() - message(STATUS "Python executable is set to ${TESTS_PYTHON_EXECUTABLE}") - list(APPEND TEST_DEFINITIONS TESTS_ENABLE_VENV_TESTS=1) - list(APPEND TEST_DEFINITIONS TESTS_PYTHON_EXECUTABLE="${TESTS_PYTHON_EXECUTABLE}") - endif() -else () - message(STATUS "Python tests are disabled by 'TESTS_ENABLE_PYTHON_TESTS' option") - list(APPEND TEST_DEFINITIONS TESTS_ENABLE_VENV_TESTS=0) -endif () - -list(APPEND TEST_DEFINITIONS TESTS_SOURCE_DIR="${CMAKE_SOURCE_DIR}") # add source directory to TEST_DEFINITIONS -list(APPEND TEST_DEFINITIONS TESTS_DOCS_DIR="${CMAKE_SOURCE_DIR}/docs") # add docs directory to TEST_DEFINITIONS - # make sure TESTS_SOFTWARE_ENCODER_UNAVAILABLE is set to "fail" or "skip" if (NOT (TESTS_SOFTWARE_ENCODER_UNAVAILABLE STREQUAL "fail" OR TESTS_SOFTWARE_ENCODER_UNAVAILABLE STREQUAL "skip")) set(TESTS_SOFTWARE_ENCODER_UNAVAILABLE "fail") diff --git a/tests/ci/test_docs.cpp b/tests/ci/test_docs.cpp deleted file mode 100644 index 70ab2bb5..00000000 --- a/tests/ci/test_docs.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include - -class DocsTests: public DocsTestFixture, public ::testing::WithParamInterface> {}; -INSTANTIATE_TEST_SUITE_P( - DocFormats, - DocsTests, - ::testing::Values( - std::make_tuple("html", "index.html"), - std::make_tuple("epub", "Sunshine.epub"))); -TEST_P(DocsTests, MakeDocs) { - auto params = GetParam(); - std::string format = std::get<0>(params); - std::string expected_filename = std::get<1>(params); - - std::filesystem::path expected_file = std::filesystem::current_path() / "build" / format / expected_filename; - - std::string command = "make " + format; - int status = BaseTest::exec(command.c_str()); - EXPECT_EQ(status, 0); - - EXPECT_TRUE(std::filesystem::exists(expected_file)); -} - -class DocsRstTests: public DocsPythonVenvTest, public ::testing::WithParamInterface {}; -INSTANTIATE_TEST_SUITE_P( - RstFiles, - DocsRstTests, - ::testing::Values( - std::filesystem::path(TESTS_DOCS_DIR), - std::filesystem::path(TESTS_SOURCE_DIR) / "README.rst")); -TEST_P(DocsRstTests, RstCheckDocs) { - std::filesystem::path docs_dir = GetParam(); - std::string command = "rstcheck -r " + docs_dir.string(); - int status = BaseTest::exec(command.c_str()); - EXPECT_EQ(status, 0); -} diff --git a/tests/conftest.cpp b/tests/conftest.cpp index 38721b67..2a8cd37a 100644 --- a/tests/conftest.cpp +++ b/tests/conftest.cpp @@ -194,204 +194,3 @@ protected: private: std::unique_ptr deinit_guard; }; - -class DocsPythonVenvBase: public virtual BaseTest { -protected: - void - SetUp() override { -#if defined TESTS_ENABLE_VENV_TESTS && TESTS_ENABLE_VENV_TESTS == 0 - GTEST_SKIP_("TESTS_ENABLE_VENV_TESTS is disabled by CMake"); -#else - std::cout << "DocsPythonVenvTest:: starting Fixture SetUp" << std::endl; - - std::string pythonBinDirArray[] = { "bin", "Scripts" }; - std::filesystem::path pythonPath = "python"; - std::string binPath; - std::string command; - int exit_code; - - std::filesystem::path venvPath = ".venv"; - std::filesystem::path fullVenvPath = BaseTest::testBinaryDir / venvPath; - - // check for existence of venv, and create it if necessary - std::cout << "DocsPythonVenvTest:: checking for venv" << std::endl; - if (!std::filesystem::exists(fullVenvPath)) { - std::cout << "DocsPythonVenvTest:: venv not found" << std::endl; - - // create the venv - command = "\"" TESTS_PYTHON_EXECUTABLE "\" -m venv " + fullVenvPath.string(); - std::cout << "DocsPythonVenvTest:: trying to create venv with command: " << command << std::endl; - exit_code = BaseTest::exec(command.c_str()); - if (exit_code != 0) { - if (!std::filesystem::exists(fullVenvPath)) { - FAIL() << "Command failed: " << command << " with exit code: " << exit_code; - } - else { - // venv command will randomly complain that some files already exist... - std::cout << "DocsPythonVenvTest:: exit code (" << exit_code << ") indicates venv creation failed, but venv exists" << std::endl; - } - } - } - - // determine if bin directory is `bin` (Unix) or `Scripts` (Windows) - // cannot assume `Scripts` on Windows, as it could be `bin` if using MSYS2, cygwin, etc. - std::cout << "DocsPythonVenvTest:: checking structure of venv" << std::endl; - for (const std::string &binDir : pythonBinDirArray) { - // check if bin directory exists - if (std::filesystem::exists(fullVenvPath / binDir)) { - binPath = binDir; - std::cout << "DocsPythonVenvTest:: found binPath: " << binPath << std::endl; - break; - } - } - - if (binPath.empty()) { - FAIL() << "Python venv not found"; - } - - // set fullPythonPath and fullPythonBinPath - fullPythonPath = fullVenvPath / binPath / pythonPath; - fullPythonBinPath = fullVenvPath / binPath; - - std::cout << "DocsPythonVenvTest:: fullPythonPath: " << fullPythonPath << std::endl; - std::cout << "DocsPythonVenvTest:: fullPythonBinPath: " << fullPythonBinPath << std::endl; - - std::filesystem::path requirements_path = std::filesystem::path(TESTS_DOCS_DIR) / "requirements.txt"; - - // array of commands to run - std::string CommandArray[] = { - "\"" + fullPythonPath.string() + "\" -m pip install -r " + requirements_path.string(), - }; - - for (const std::string &_command : CommandArray) { - std::cout << "DocsPythonVenvTest:: running command: " << _command << std::endl; - exit_code = BaseTest::exec(_command.c_str()); - if (exit_code != 0) { - FAIL() << "Command failed: " << command << " with exit code: " << exit_code; - } - } - - // Save the original PATH - originalEnvPath = std::getenv("PATH") ? std::getenv("PATH") : ""; - std::cout << "DocsPythonVenvTest:: originalEnvPath: " << originalEnvPath << std::endl; - - // Set the temporary PATH - std::string tempPath; - std::string envPathSep; - - #ifdef _WIN32 - envPathSep = ";"; - #else - envPathSep = ":"; - #endif - tempPath = fullPythonBinPath.string() + envPathSep + originalEnvPath; - std::cout << "DocsPythonVenvTest:: tempPath: " << tempPath << std::endl; - setEnv("PATH", tempPath); - - std::cout << "DocsPythonVenvTest:: finished Fixture SetUp" << std::endl; -#endif - } - - void - TearDown() override { - std::cout << "DocsPythonVenvTest:: starting Fixture TearDown" << std::endl; - - // Restore the original PATH - if (!originalEnvPath.empty()) { - std::cout << "DocsPythonVenvTest:: restoring originalEnvPath: " << originalEnvPath << std::endl; - setEnv("PATH", originalEnvPath); - } - - std::cout << "DocsPythonVenvTest:: finished Fixture TearDown" << std::endl; - } - - // functions and variables - std::filesystem::path fullPythonPath; - std::filesystem::path fullPythonBinPath; - std::string originalEnvPath; -}; - -class DocsPythonVenvTest: public virtual BaseTest, public DocsPythonVenvBase { -protected: - void - SetUp() override { - BaseTest::SetUp(); - DocsPythonVenvBase::SetUp(); - } - - void - TearDown() override { - DocsPythonVenvBase::TearDown(); - BaseTest::TearDown(); - } -}; - -class DocsWorkingDirectoryBase: public virtual BaseTest { -protected: - void - SetUp() override { -#if defined TESTS_ENABLE_VENV_TESTS && TESTS_ENABLE_VENV_TESTS == 1 - std::cout << "DocsWorkingDirectoryTest:: starting Fixture SetUp" << std::endl; - - temp_dir = TESTS_DOCS_DIR; - std::cout << "DocsWorkingDirectoryTest:: temp_dir: " << temp_dir << std::endl; - - // change directory to `docs` - original_dir = std::filesystem::current_path(); // save original directory - std::cout << "DocsWorkingDirectoryTest:: original_dir: " << original_dir << std::endl; - std::filesystem::current_path(temp_dir); - std::cout << "DocsWorkingDirectoryTest:: working directory set to: " << std::filesystem::current_path() << std::endl; - - std::cout << "DocsWorkingDirectoryTest:: finished Fixture SetUp" << std::endl; -#endif - } - - void - TearDown() override { -#if defined TESTS_ENABLE_VENV_TESTS && TESTS_ENABLE_VENV_TESTS == 1 - std::cout << "DocsWorkingDirectoryTest:: starting Fixture TearDown" << std::endl; - - // change directory back to original - std::filesystem::current_path(original_dir); - std::cout << "DocsWorkingDirectoryTest:: working directory set to: " << std::filesystem::current_path() << std::endl; - - std::cout << "DocsWorkingDirectoryTest:: finished Fixture TearDown" << std::endl; -#endif - } - - // functions and variables - std::filesystem::path original_dir; - std::filesystem::path temp_dir; -}; - -class DocsWorkingDirectoryTest: public virtual BaseTest, public DocsWorkingDirectoryBase { -protected: - void - SetUp() override { - BaseTest::SetUp(); - DocsWorkingDirectoryBase::SetUp(); - } - - void - TearDown() override { - DocsWorkingDirectoryBase::TearDown(); - BaseTest::TearDown(); - } -}; - -class DocsTestFixture: public virtual BaseTest, public DocsPythonVenvBase, public DocsWorkingDirectoryBase { -protected: - void - SetUp() override { - BaseTest::SetUp(); - DocsPythonVenvBase::SetUp(); - DocsWorkingDirectoryBase::SetUp(); - } - - void - TearDown() override { - DocsWorkingDirectoryBase::TearDown(); - DocsPythonVenvBase::TearDown(); - BaseTest::TearDown(); - } -};