我有在gradle這個本機C應用gradle這個項目(2.10版本)來測試本機應用程序:如何使用CUNIT從多個組件由多個部件
components {
component_1(NativeLibrarySpec)
component_2(NativeLibrarySpec)
...
component_n(NativeLibrarySpec)
main_component(NativeExecutableSpec){
sources {
c.lib library: "component_1", linkage: "static"
c.lib library: "component_2", linkage: "static"
...
c.lib library: "component_n", linkage: "static"
}
}
}
具有應用的主要思想在這種形式下更容易測試各個組件。然而,我有兩個大問題:
main_component
是一個應用程序,因此有一個主要功能,併產生此錯誤:multiple definition of 'main'
... gradle_cunit_main.c:(.text+0x0): first defined here
。這是我們期望的,並在文檔中提到,但我想知道是否有辦法避免這個問題,例如,阻止主要組件包含在測試中。這涉及到下一個問題
的CUNIT插件(截至gradle這個2.10版本)抱怨,當我嘗試定義要測試的組成部分如下:
testSuites {
component_1Test(CUnitTestSuiteSpec){
testing $.components.component_1
}
}
}
gradle這個抱怨:
Cannot create 'testSuites.component_1Test' using creation rule 'component_1Test(org.gradle.nativeplatform.test.cunit.CUnitTestSuiteSpec) { ... } @ build.gradle line 68, column 9' as the rule 'CUnitPlugin.Rules#createCUnitTestSuitePerComponent > create(component_1Test)' is already registered to create this model element
總之,我想指示cunit插件僅測試一些組件,並防止主要組件(包含主函數)被編譯用於測試。再次請注意,我使用的是gradle 2.10,無法升級到更新的版本,因爲這會扼制我們的CI工具鏈。
在此先感謝您的意見。