Automake:如何处理全局和本地“make check”有效地?

发布于 2024-08-19 09:33:55 字数 1128 浏览 7 评论 0原文

在一个较大的项目中,我设置了 ./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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倒带 2024-08-26 09:33:55

打破你的测试。在你的tests/Makefile.am中做:

TESTS = foo_test bar_test

并使用类似现在的内容适当地构建foo_test bar_test

foo_test_SOURCES = foo/foo_wrapper.c foo/foo_test.c
bar_test_SOURCES = bar/bar_wrapper.c bar/bar_test.c

,如果你执行原始的“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:

TESTS = foo_test bar_test

and build foo_test bar_test appropriately with something like

foo_test_SOURCES = foo/foo_wrapper.c foo/foo_test.c
bar_test_SOURCES = bar/bar_wrapper.c bar/bar_test.c

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'.

你是我的挚爱i 2024-08-26 09:33:55

您不能从“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.)

ぇ气 2024-08-26 09:33:55

我认为您可以覆盖顶层的 check 规则来定义环境变量:

check:
        DISABLE_SUBTESTS=1 make check-recursive

然后在子目录中测试 DISABLE_SUBTESTS 来决定是否实际运行测试与否。

(就我个人而言,我宁愿通过隐藏测试的输出来安排在现有的 make check 框架中工作,而不是像这样覆盖生成的规则。)

I think you could maybe overwrite the check rule at the top-level to define an environment variable:

check:
        DISABLE_SUBTESTS=1 make check-recursive

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文