FindSquish

-- 典型用法

此模块可以用于查找 Squish。

SQUISH_FOUND                    If false, don't try to use Squish
SQUISH_VERSION                  The full version of Squish found
SQUISH_VERSION_MAJOR            The major version of Squish found
SQUISH_VERSION_MINOR            The minor version of Squish found
SQUISH_VERSION_PATCH            The patch version of Squish found
SQUISH_INSTALL_DIR              The Squish installation directory
                                (containing bin, lib, etc)
SQUISH_SERVER_EXECUTABLE        The squishserver executable
SQUISH_CLIENT_EXECUTABLE        The squishrunner executable
SQUISH_INSTALL_DIR_FOUND        Was the install directory found?
SQUISH_SERVER_EXECUTABLE_FOUND  Was the server executable found?
SQUISH_CLIENT_EXECUTABLE_FOUND  Was the client executable found?

它提供了函数 squish_add_test(),用于在使用 Squish >= 4.x 的 cmake 中添加 squish 测试。

squish_add_test(cmakeTestName
  AUT targetName SUITE suiteName TEST squishTestName
  [SETTINGSGROUP group] [PRE_COMMAND command] [POST_COMMAND command] )

在 3.18 版本中变更: 在之前的 CMake 版本中,此函数名为 squish_v4_add_test

参数具有以下含义

cmakeTestName

这将用作 add_test() 的第一个参数

AUT targetName

将用作 AUT 的 cmake 目标的名称,即将被测试的可执行文件。

SUITE suiteName

这可以是 squish 套件的完整路径,或者只是套件的最后一个目录,即套件名称。在这种情况下,调用 squish_add_test() 的 CMakeLists.txt 必须位于套件目录的父目录中。

TEST squishTestName

squish 测试的名称,即套件目录内测试子目录的名称。

SETTINGSGROUP group

已弃用,此参数将被忽略。

PRE_COMMAND command

如果指定,则在开始 squish 测试之前执行给定的命令。

POST_COMMAND command

与 PRE_COMMAND 相同,但在 squish 测试执行完毕后执行。

enable_testing()
find_package(Squish 6.5)
if (SQUISH_FOUND)
   squish_add_test(myTestName
     AUT myApp
     SUITE ${CMAKE_SOURCE_DIR}/tests/mySuite
     TEST someSquishTest
     )
endif ()

对于 Squish 3.x 版本的用户,提供了宏 squish_v3_add_test()

squish_v3_add_test(testName applicationUnderTest testCase envVars testWrapper)
Use this macro to add a test using Squish 3.x.
enable_testing()
find_package(Squish 3.0)
if (SQUISH_FOUND)
  squish_v3_add_test(myTestName myApplication testCase envVars testWrapper)
endif ()