本文档翻译自:https://docs.conan.io/en/latest/reference/commands/creator/test.html
$ conan test [-h] [-tbf TEST_BUILD_FOLDER] [-b [BUILD]] [-r REMOTE] [-u][-l [LOCKFILE]] [-e ENV_HOST] [-e:b ENV_BUILD][-e:h ENV_HOST] [-o OPTIONS_HOST] [-o:b OPTIONS_BUILD][-o:h OPTIONS_HOST] [-pr PROFILE_HOST] [-pr:b PROFILE_BUILD][-pr:h PROFILE_HOST] [-s SETTINGS_HOST][-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST]path reference
使用test()方法从conanfile.py测试使用它的程序包。
此命令将安装conanfile依赖项(包括已测试的软件包),调用“ conan build”以构建测试应用程序,并最终执行test()方法。 测试配方不需要名称或版本,也不要求package()或package_info()方法的定义。 要测试的程序包必须存在于本地缓存或任何已配置的远程服务器中。
positional arguments:path Path to the "testing" folder containing a conanfile.pyor to a recipe file with test() methode.g. conantest_package/conanfile.py pkg/version@user/channelreference pkg/version@user/channel of the package to be testedoptional arguments:-h, --help show this help message and exit-tbf TEST_BUILD_FOLDER, --test-build-folder TEST_BUILD_FOLDERWorking directory of the build process.-b [BUILD], --build [BUILD]Optional, specify which packages to build from source.Combining multiple '--build' options on one commandline is allowed. For dependencies, the optional'build_policy' attribute in their conanfile.py takesprecedence over the command line parameter. Possibleparameters: --build Force build for all packages, donot use binary packages. --build=never Disallow buildfor all packages, use binary packages or fail if abinary package is not found. Cannot be combined withother '--build' options. --build=missing Buildpackages from source whose binary package is notfound. --build=outdated Build packages from sourcewhose binary package was not generated from the latestrecipe or is not found. --build=cascade Build packagesfrom source that have at least one dependency beingbuilt from source. --build=[pattern] Build packagesfrom source whose package reference matches thepattern. The pattern uses 'fnmatch' style wildcards.Default behavior: If you omit the '--build' option,the 'build_policy' attribute in conanfile.py will beused if it exists, otherwise the behavior is like '--build=never'.-r REMOTE, --remote REMOTELook in the specified remote server-u, --update Check updates exist from upstream remotes-l [LOCKFILE], --lockfile [LOCKFILE]Path to a lockfile or folder containing 'conan.lock'file. Lockfile can be updated if packages change-e ENV_HOST, --env ENV_HOSTEnvironment variables that will be set during thepackage build (host machine). e.g.: -eCXX=/usr/bin/clang++-e:b ENV_BUILD, --env:build ENV_BUILDEnvironment variables that will be set during thepackage build (build machine). e.g.: -e:bCXX=/usr/bin/clang++-e:h ENV_HOST, --env:host ENV_HOSTEnvironment variables that will be set during thepackage build (host machine). e.g.: -e:hCXX=/usr/bin/clang++-o OPTIONS_HOST, --options OPTIONS_HOSTDefine options values (host machine), e.g.: -oPkg:with_qt=true-o:b OPTIONS_BUILD, --options:build OPTIONS_BUILDDefine options values (build machine), e.g.: -o:bPkg:with_qt=true-o:h OPTIONS_HOST, --options:host OPTIONS_HOSTDefine options values (host machine), e.g.: -o:hPkg:with_qt=true-pr PROFILE_HOST, --profile PROFILE_HOSTApply the specified profile to the host machine-pr:b PROFILE_BUILD, --profile:build PROFILE_BUILDApply the specified profile to the build machine-pr:h PROFILE_HOST, --profile:host PROFILE_HOSTApply the specified profile to the host machine-s SETTINGS_HOST, --settings SETTINGS_HOSTSettings to build the package, overwriting thedefaults (host machine). e.g.: -s compiler=gcc-s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILDSettings to build the package, overwriting thedefaults (build machine). e.g.: -s:b compiler=gcc-s:h SETTINGS_HOST, --settings:host SETTINGS_HOSTSettings to build the package, overwriting thedefaults (host machine). e.g.: -s:h compiler=gcc
该命令可用于测试以前已构建的现有软件包(例如,使用conan create)。 如果在conanfile.py之外找到了test_package文件夹,或者为conan create提供了—test-folder参数,conan create将自动运行此测试。
Example:
$ conan new hello/0.1 -s -t$ mv test_package test_package2$ conan create . user/testing# doesn't automatically run test, it has been renamed# now run test$ conan test test_package2 hello/0.1@user/testing
测试包文件夹可以位于其他位置,甚至可以应用于包的不同版本。
