2015-02-09 20 views

回答

1

我這樣做是通過創建這個Makefile.amtests目錄,所有的測試代碼爲:

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 [email protected] $< 

這樣做是編譯runner-autogen.cpp進入測試程序(稱爲tests),並與make check運行它。如果列出的任何.hpp文件發生更改,它將運行cxxtestgen重新創建runner-autogen.cpp

因爲runner-autogen.cpp被列爲源文件,它會被包括在make dist釋放歸檔,因此除非他們改變.hpp文件之一的用戶將不再需要cxxtest存在。