The CxxTest documentation has an example of a Makefile that generates and runs unit tests. How do I do the same for automake (Makefile.am)?
CxxTest文档有一个生成并运行单元测试的Makefile示例。我如何为automake(Makefile.am)做同样的事情?
1 个解决方案
#1
1
I did this by creating this Makefile.am
in a tests
directory, where all the test code was:
我是通过在tests目录中创建这个Makefile.am来完成的,其中所有测试代码都是:
check_PROGRAMS = tests
EXTRA_tests_SOURCES = test_example1.hpp
EXTRA_tests_SOURCES += test_example2.hpp
tests_SOURCES = runner-autogen.cpp
BUILT_SOURCES = runner-autogen.cpp
MAINTAINERCLEANFILES = runner-autogen.cpp
runner-autogen.cpp: $(EXTRA_tests_SOURCES)
/path/to/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o $@ $<
What this does is compile runner-autogen.cpp
into the test program (called tests
) and runs it with make check
. If any of the listed .hpp
files change, it will run cxxtestgen
to recreate runner-autogen.cpp
.
这样做是将runner-autogen.cpp编译到测试程序(称为测试)并使用make check运行它。如果列出的任何.hpp文件发生更改,它将运行cxxtestgen以重新创建runner-autogen.cpp。
Because runner-autogen.cpp
is listed as a source file, it will be included in the release archive by make dist
, so the user won't need cxxtest present unless they modify one of the .hpp
files.
因为runner-autogen.cpp被列为源文件,所以它将被make dist包含在发布存档中,因此用户不需要存在cxxtest,除非他们修改其中一个.hpp文件。
#1
1
I did this by creating this Makefile.am
in a tests
directory, where all the test code was:
我是通过在tests目录中创建这个Makefile.am来完成的,其中所有测试代码都是:
check_PROGRAMS = tests
EXTRA_tests_SOURCES = test_example1.hpp
EXTRA_tests_SOURCES += test_example2.hpp
tests_SOURCES = runner-autogen.cpp
BUILT_SOURCES = runner-autogen.cpp
MAINTAINERCLEANFILES = runner-autogen.cpp
runner-autogen.cpp: $(EXTRA_tests_SOURCES)
/path/to/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o $@ $<
What this does is compile runner-autogen.cpp
into the test program (called tests
) and runs it with make check
. If any of the listed .hpp
files change, it will run cxxtestgen
to recreate runner-autogen.cpp
.
这样做是将runner-autogen.cpp编译到测试程序(称为测试)并使用make check运行它。如果列出的任何.hpp文件发生更改,它将运行cxxtestgen以重新创建runner-autogen.cpp。
Because runner-autogen.cpp
is listed as a source file, it will be included in the release archive by make dist
, so the user won't need cxxtest present unless they modify one of the .hpp
files.
因为runner-autogen.cpp被列为源文件,所以它将被make dist包含在发布存档中,因此用户不需要存在cxxtest,除非他们修改其中一个.hpp文件。