添加额外的 make/test 目标到 autotools 项目

发布于 2024-08-05 20:00:17 字数 633 浏览 3 评论 0原文

我们有一个自动工具项目,它混合了单元测试和集成测试,所有这些测试都通过“make check”运行。这并不理想,因为某些集成测试需要一段时间,并且具有各种依赖项(数据库等),

我想分离集成测试并为它们分配自己的 make 目标。这样,单元测试仍然可以经常运行(通过 make check),并且集成测试可以根据需要以类似的方式运行。

是否有一种简单(或其他)的方法来添加额外的 make 目标?

注意:我可能还应该补充一点,这是一个大项目,因此手动编辑/维护每个 makefile 是不可取的。如果可能的话,我想用“自动工具方式”来做。

-- 更新 1 --

我尝试了 Jon 的解决方案,它更接近了一步,但还没有完全实现。我仍然有几个问题:

1)递归 - 我可以修改构建树根目录中的 makefile.am 以及包含测试的任何目录,但似乎应该有一种方法这样做我不必更改层次结构中的每个 Makefile.am 。 (毕竟,检查目标是这样工作的)

2) .PHONY - 我不断收到有关 .PHONY 被重新定义的消息。这是可以理解的,因为它是由另一个包(特别是 doxygen)设置的。怎样才能让两个人一起玩得愉快呢?

We have an autotools project that has a mixture of unit and integration tests, all of which run via 'make check'. This isn't ideal, as some of the integration tests take a while, and have all sorts of dependencies (database, etc.)

I'd like to separate the integration tests and assign them their own make target. That way, unit tests can still be run often (via make check), and the integration tests can be run as needed in a similar fashion.

Is there a straightforward (or otherwise) way to add an additional make target?

NOTE: I should probably also add that this is a large project, so editing/maintaining every makefile by hand is not desirable. I'd like to do it the 'autotools way' if possible.

-- UPDATE 1 --

I've attempted Jon's solution, and it's a step closer, but not quite there. I still have a couple of issues:

1) Recursion - I'm OK with modifying the makefile.am in the root of the build tree, as well as any directory that contains the tests, but it seems like there should be a way to do this where I don't have to change every Makefile.am in the hierarchy. (the check target works this way, after all)

2) .PHONY - I keep getting messages about .PHONY being redefined. Which is understandable, because it's being set by another package (specifically, doxygen). How do I make the two play nice together?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

溺深海 2024-08-12 20:00:17

在 am 文件中,所有 make 语法都会传递到生成的 Makefile 中。因此,如果您想要一个新目标,只需像在 Makefile 中一样创建它,它将出现在自动生成的 Makefile 中。将以下内容放在 am 文件的底部。

integration-tests: prerequisites....
        commands to run test

.PHONY: integration-tests

In your am files, all make syntax is passed into the generated Makefile. So if you want a new target just create it like you would in a Makefile and it will appear in the auto generated Makefile. Put the following at the bottom of your am files.

integration-tests: prerequisites....
        commands to run test

.PHONY: integration-tests
小嗲 2024-08-12 20:00:17

由于没有更多回复,我将用我的解决方案来回答。

我通过完全消除递归来解决递归问题。使用此页面
作为指导,我将整个项目从递归 make 切换为非递归 make。然后,我将非递归检查相关目标(check、check-am、check-TESTS 等)克隆到一组新的集成测试目标中。到目前为止,这种方法效果非常好。

注意:您可能想知道为什么我不直接克隆递归目标。坦白说,我找不到它们。要么我不知道在哪里查找(规则不在生成的 Makefile 中),要么隐式发生了一些事情,而且我对自动工具的理解不够好,无法遵循它。

至于.PHONY被重新定义的问题,除了在进行集成测试时有条件地排除其他定义之外,我还没有找到解决方案。

Since there haven't been any more responses, I'm going to answer with my solution.

I solved the recursion issue by eliminating the recursion altogether. Using this page
as a guide, I switched the entire project from recursive make to non-recursive make. I then cloned the non-recursive check-related targets (check, check-am, check-TESTS, etc.) into a new set of targets for the integration tests. So far, this works extremely well.

Note: you may be wondering why I didn't just clone the recursive targets instead. Quite frankly, I couldn't find them. Either I didn't know where to look (the rules weren't in the generated Makefile) or something is happening implicitly, and I don't understand autotools well enough to follow it.

As for the issue with .PHONY being redefined, I still haven't found a solution, other than to conditionally exclude the other definition when I'm doing the integration tests.

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