具有多个测试套件的 Automake(编码/部署)

发布于 2024-11-16 04:15:54 字数 305 浏览 4 评论 0原文

我正在将 Automake 用于一个项目,除了典型的单元测试之外,该项目还开始运行更长时间的集成/部署样式测试。问题是,在正常编程期间,不需要运行较长的测试,只需运行较短的单元测试集。然而,最终的合并和/或存储库构建必须运行完整的测试套件。

automake 有没有标准的方法来处理这个问题?理想情况下,我只想有两个目标,一个是运行所有内容的正常 check 目标,另一个是运行精简测试的 check-lite 目标。

该项目分布在多个子项目和目录中,因此标准的 automake 方法是确保一致性的理想选择。

I'm using Automake for a project that is starting to have longer running integration/deployment style tests in addition to the typical unit tests. The issue is that during normal programming there is no need to run the longer tests, only the shorter set of unit tests. However, the final merge, and/or repository build, must run the complete test suite.

Is there a standard way to handle this with automake? Ideally I'd like to just have two targets, the normal check target to run everything and perhaps a check-lite to run the reduced test.

The project is spread across several sub-projects and directories, thus a standard automake approach would be ideal to ensure consistency.

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

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

发布评论

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

评论(2

标点 2024-11-23 04:15:54

我建议在您的 configure 脚本中添加一个 --enable-extended-tests 选项:

AC_MSG_CHECKING([whether to run extended tests])
AC_ARG_ENABLE([extended-tests],
  [AS_HELP_STRING([--enable-extended-tests], [run full integration tests])],
  [enable_extended_tests="yes"], [enable_extended_tests="no"])
AC_MSG_RESULT([$enable_extended_tests])

AM_CONDITIONAL([EXTENDED_TESTS], [test "X$enable_extended_tests" != "Xno"])

然后您可以在 Makefile.am 中使用 Automake 条件:

if EXTENDED_TESTS
EXTRA_TESTS = extra_test1 extra_test2 ...
else
EXTRA_TESTS =
endif

TESTS = $(EXTRA_TESTS) normal_test1 normal_test2 ...

I suggest adding a --enable-extended-tests option to your configure script:

AC_MSG_CHECKING([whether to run extended tests])
AC_ARG_ENABLE([extended-tests],
  [AS_HELP_STRING([--enable-extended-tests], [run full integration tests])],
  [enable_extended_tests="yes"], [enable_extended_tests="no"])
AC_MSG_RESULT([$enable_extended_tests])

AM_CONDITIONAL([EXTENDED_TESTS], [test "X$enable_extended_tests" != "Xno"])

Then you can use an Automake conditional in your Makefile.am:

if EXTENDED_TESTS
EXTRA_TESTS = extra_test1 extra_test2 ...
else
EXTRA_TESTS =
endif

TESTS = $(EXTRA_TESTS) normal_test1 normal_test2 ...
诗酒趁年少 2024-11-23 04:15:54

如果您已根据测试类型将测试套件拆分为单独的目录,则可以向顶级 Makefile.am 添加一些其他目标来执行部分测试套件运行。

例如,如果您的树组织如下:

$(srcdir)
  - tests
     - unit
     - integration

您可以将以下内容添加到 makefile:

check-unit:
    $(MAKE) $(AM_MAKEFLAGS) -C tests/unit check

check-integration:
    $(MAKE) $(AM_MAKEFLAGS) -C tests/integration check

现在,当您运行 make check-unit 时,它只会运行您的单元测试。运行 make check-integration 将运行另一半测试。标准 make check 目标将继续运行整个套件。

如果您无法将所有测试组织在一个目录下,则可以向目标添加额外的 $(MAKE) 调用。它确实需要了解顶层项目结构的一些知识,但没有明确的方法从子目录中的 Makefile.am 文件向上传递所需信息。

If you have split your test suite into separate directories based on the test type, then you can add some additional targets to the top level Makefile.am to do partial test suite runs.

For example, if your tree is organised as:

$(srcdir)
  - tests
     - unit
     - integration

You could add the following to the makefile:

check-unit:
    $(MAKE) $(AM_MAKEFLAGS) -C tests/unit check

check-integration:
    $(MAKE) $(AM_MAKEFLAGS) -C tests/integration check

Now when you run make check-unit, it will only run your unit tests. And running make check-integration will run the other half of the tests. The standard make check target will continue to run the whole suite.

If you can't organise all the tests under a single directory, you can add additional $(MAKE) invocations to the targets. It does require some knowledge of the project structure at the top level, but there isn't a clear way to pass the required information up from the Makefile.am files in subdirectories.

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