Automake:如何处理全局和本地“make check”有效地?
在一个较大的项目中,我设置了 ./tests/Makefile.am
在调用 make check
时运行许多测试。文件 global_wrapper.c
包含设置/故障代码,并且它调用在多个子目录中实现的测试函数。
TESTS = global_test
check_PROGRAMS = global_test
global_test_SOURCES = global_wrapper.c foo/foo_test.c bar/bar_test.c
效果很好。但测试需要很长时间,因此我希望能够选择仅从单个子目录执行测试。我一开始就是这样做的。
我添加了子目录:
SUBDIRS = foo bar
在子目录中,我添加了本地包装器和 Makefile.am
's:
TESTS = foo_test
check_PROGRAMS = foo_test
# the foo_test.c here is of course the same as in the global Makefile.am
foo_test_SOURCES = foo_wrapper.c foo_test.c
这也非常有效 - 当我在子目录中调用 make check
时 < code>foo,仅执行 foo 测试。
但是,当我现在在 ./tests
中调用 make check
时,所有测试都会执行两次。一次通过global_test
,一次通过本地测试程序。
如果我在全局 Makefile.am
中省略 SUBDIRS
语句,则子目录 makefile 不会被构建。如果我从本地 Makefile.am
中省略 TESTS
,则 make check
不会对本地目录执行任何操作。
我对 automake 不太熟悉,但我很确定有某种方法可以解决这个困境。这里有人可以给我提示吗?
In a larger project, I have set up ./tests/Makefile.am
to run a number of tests when I call make check
. The file global_wrapper.c
contains the setup / breakdown code, and it calls test functions implemented in several subdirectories.
TESTS = global_test
check_PROGRAMS = global_test
global_test_SOURCES = global_wrapper.c foo/foo_test.c bar/bar_test.c
Works great. But the tests take a long time, so I would like to be able to optionally execute only tests from a single subdir. This is how I did it at first.
I added the subdirectories:
SUBDIRS = foo bar
In the subdirectories, I added local wrappers and Makefile.am
's:
TESTS = foo_test
check_PROGRAMS = foo_test
# the foo_test.c here is of course the same as in the global Makefile.am
foo_test_SOURCES = foo_wrapper.c foo_test.c
This, too, works great - when I call make check
in the subdirectory foo
, only the foo tests are executed.
However, when I now call make check
in ./tests
, all tests are executed twice. Once through global_test
, and once through the local test programs.
If I omit the SUBDIRS
statement in the global Makefile.am
, the subdirectory makefiles don't get build. If I omit TESTS
from the local Makefile.am
's, make check
doesn't do anything for the local directories.
I'm not that familiar with automake, but I am pretty sure there is some way to solve this dilemma. Can anybody here give me a hint?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
打破你的测试。在你的tests/Makefile.am中做:
并使用类似现在的内容适当地构建foo_test bar_test
,如果你执行原始的“make check”,则两个测试都将运行。如果您只想运行一项测试,则可以使用“make check TESTS=foo_test”或“make check TESTS=bar_test”来执行此操作,并且只会运行适当的测试。通常,Makefile.am 列出了 TESTS 中默认运行的所有测试,并且用户在 make-time 中选择备用测试。当然,如果您经常运行测试,则可以在 shell 会话中“export TESTS=foo_test”,然后仅键入“make check”。
Break your tests up. In your tests/Makefile.am do:
and build foo_test bar_test appropriately with something like
Now, if you do a raw 'make check', both tests will be run. If you only want to run one test, you can do that with 'make check TESTS=foo_test' or 'make check TESTS=bar_test' and only the appropriate test will run. Typically, the Makefile.am lists all the tests that will be run by default in TESTS and the user selects alternate tests at make-time. Naturally, if you are running the tests a lot, you can 'export TESTS=foo_test' in your shell session and then only type 'make check'.
您不能从“global_test”中删除任何已在子目录中执行的测试吗? (这样他们就不会被处决两次。)
Can't you remove from "global_test" any test that is already executed in a subdirectory? (Just so they simply don't get executed twice.)
我认为您可以覆盖顶层的
check
规则来定义环境变量:然后在子目录中测试
DISABLE_SUBTESTS
来决定是否实际运行测试与否。(就我个人而言,我宁愿通过隐藏测试的输出来安排在现有的 make check 框架中工作,而不是像这样覆盖生成的规则。)
I think you could maybe overwrite the
check
rule at the top-level to define an environment variable:and then test
DISABLE_SUBTESTS
in your sub-directories to decide whether to actually run the tests or not.(Personally, I'd rather arrange to work in the existing
make check
framework by concealing the output of my tests, rather than overwriting the produced rules like this.)