简体   繁体   English

Autotools:如何使用make check运行单个测试?

[英]Autotools: How to run a single test using make check?

I'm currently working on a project that uses autotools to generate a makefile. 我目前正在开发一个使用autotools生成makefile的项目。 As usual, this makefile supports make check , to run the entire test suite. 像往常一样,这个makefile支持make check ,以运行整个测试套件。 However, I'm working on a small part of the program, where only a few unit tests apply. 但是,我正在研究该程序的一小部分,其中只有少数单元测试适用。 Is it possible, using make check , to run a single unit test or a selection of unit tests, instead of the entire suite? 是否可以使用make check来运行单个单元测试或选择单元测试,而不是整个套件?

Edit: Evan VanderZee suggests that it depends on the directory structure, so let me explain a bit more about the directory structure. 编辑: Evan VanderZee建议它取决于目录结构,所以让我解释一下目录结构。 The directory structure for this project is pretty flat. 该项目的目录结构非常平坦。 Most source files are in the src/ directory, with some grouped in a subdirectory under src/ . 大多数源文件位于src/目录中,其中一些文件分组在src/下的子目录中。 The unit tests are in src/tests . 单元测试在src/tests None of the source directories contain a Makefile. 没有源目录包含Makefile。 There is only a makefile (generated by configure) at the top level. 顶层只有一个makefile(由configure生成)。

If you are using Automake's TESTS variable to list the tests that make check runs, then there is an easy shortcut: make check TESTS='name-of-test1 name-of-test2' The TESTS variable passed on the command line overrides the one in the Makefile. 如果您使用Automake的TESTS变量列出make check运行的测试,那么有一个简单的快捷方式: make check TESTS='name-of-test1 name-of-test2'在命令行上传递的TESTS变量覆盖了一个在Makefile中。

Alternatively, export TESTS='names-of-tests'; make -e check 或者, export TESTS='names-of-tests'; make -e check export TESTS='names-of-tests'; make -e check to take the value of TESTS from the environment. export TESTS='names-of-tests'; make -e check从环境中获取TESTS的值。

If you are not using TESTS but instead check-local or some other target, then this won't work. 如果你没有使用TESTS ,而是check-local或其他目标,那么这将不起作用。

The answer to that depends on the specific makefiles you are using. 答案取决于您使用的特定makefile。 If the tests have a directory structure, you can often navigate to a subdirectory and run make check in the subdirectory. 如果测试具有目录结构,您通常可以导航到子目录并在子目录中运行make check

Since you explained later that your directory structure is flat, it is hard to say without actually seeing some of the makefile. 由于您后来解释说您的目录结构是扁平的,因此很难说没有实际看到一些makefile。 If you know the name of the executable that is created for the specific test you want to run, you might be able to run make name_of_test to build the test that you want to run. 如果您知道为要运行的特定测试创建的可执行文件的名称,则可以运行make name_of_test来构建要运行的测试。 This will not run the test, it will only build it. 这不会运行测试,它只会构建它。 The test may reside in the test directory after it is built. 构建之后,测试可以驻留在测试目录中。 After this you can go into the test directory and run the test in the typical way you would run an executable, but if the test depends on libraries, you may need to tell the test where to find those libraries, perhaps by adding some libraries to the LD_LIBRARY_PATH . 在此之后,您可以进入测试目录并以运行可执行文件的典型方式运行测试,但如果测试依赖于库,您可能需要告诉测试在哪里找到这些库,可能通过添加一些库来LD_LIBRARY_PATH

If this is something you would want to do often, the makefile can probably be modified to support running the specific tests that you want to run. 如果这是您经常要做的事情,可能会修改makefile以支持运行您要运行的特定测试。 Typically this would involve editing a Makefile.am or Makefile.in and then reconfiguring, but I don't have enough information yet to advise what edits you would need to make. 通常这将涉及编辑Makefile.amMakefile.in然后重新配置,但我还没有足够的信息来建议您需要进行哪些编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您如何使用 GNU 自动工具为“make check”创建测试 - How do you create tests for "make check" with GNU autotools 如何使用 Unit::Test 在 Ruby on Rails 3.0.7 中运行单个测试? - How to run a single test in Ruby on Rails 3.0.7 using Unit::Test? 如何使 autotools 测试读取文件? - how to make autotools tests read files? 如何使用Kotlin运行单个Android测试? - How can I run a single Android Test using Kotlin? 如何使用 kotest/kotlintest 在上下文中运行单个测试 - How to run a single test in a context using kotest/kotlintest 如何使用 Gradle 命令在 Android 中运行单个测试类? - How to run single test class in Android using Gradle command? 如何使用Gradle在grails-core项目中运行单个测试? - How to run single test in grails-core project using Gradle? 如何使用Selenium连续运行一个测试用例? - How do I continuously run a single test case using Selenium? 使用Maven多次运行单个测试 - Run a single test multiple times using maven 如何使用 gradle 2.4 运行单个 Android 本地单元测试。 不支持测试过滤 - How to run single Android local unit test using gradle 2.4. Test filtering is not supported
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM