poco/Foundation/testsuite/build.gradle

121 lines
3.0 KiB
Groovy

import org.gradle.nativeplatform.test.cppunit.CppUnitTestSuiteSpec
model {
components {
/*
withType(NativeComponentSpec) {
binaries.withType(NativeBinarySpec) {
if (buildType == buildTypes.debug) {
if (it instanceof NativeExecutableBinarySpec) {
executable.file = toLocalBin(appendDebugSuffix(executable.file), targetPlatform)
}
} else
if (buildType == buildTypes.release) {
if (it instanceof NativeExecutableBinarySpec) {
executable.file = toLocalBin(executable.file, targetPlatform)
}
}
}
}
*/
TestLibrary(NativeLibrarySpec) {
sources {
cpp {
source {
srcDir 'src'
include 'TestLibrary.cpp'
include 'TestPlugin.cpp'
}
lib project: ':Foundation', library: 'Foundation', linkage: 'shared'
}
}
}
TestApp(NativeExecutableSpec) {
sources {
cpp {
source {
srcDir 'src'
include 'TestApp.cpp'
}
}
}
}
TestSuite(NativeLibrarySpec) {
sources {
cpp {
source {
srcDir 'src'
include '**/*.cpp'
exclude '*Driver.cpp'
exclude '*_WINCE.cpp'
exclude 'TestApp*.cpp'
}
exportedHeaders {
srcDir 'src'
}
lib project: ':CppUnit', library: 'CppUnit', linkage: 'shared'
lib project: ':Foundation', library: 'Foundation', linkage: 'shared'
}
}
}
}
testSuites {
FoundationTestSuite(org.gradle.nativeplatform.test.cppunit.CppUnitTestSuiteSpec) {
testing $.components.TestSuite
binaries.all {
println "---Task ${tasks.run.name} is associated with platform ${targetPlatform.name}"
String PATH = tasks.run.environment.get("PATH")
String Path = tasks.run.environment.get("Path")
println "===PATH=" + PATH
println ">>>Path=" + Path
String testAppDir = project.buildDir
testAppDir += "/exe" + "/testApp"
testAppDir += "/" + targetPlatform.name
if (buildType == buildTypes.debug)
testAppDir += "/debug"
else
if (buildType == buildTypes.release)
testAppDir += "/release"
if (targetPlatform.name.startsWith("win"))
testAppDir = testAppDir.replace('/', '\\')
Path = testAppDir + File.pathSeparator + Path
println "===" + Path
println ""
tasks.run.environment "Path", Path
}
}
}
binaries {
withType(org.gradle.nativeplatform.test.cppunit.CppUnitTestSuiteBinarySpec) {
lib project: ':CppUnit', library: 'CppUnit', linkage: 'shared'
lib library: 'TestLibrary', linkage: 'shared'
if (toolChain in VisualCpp) {
if (buildType == buildTypes.debug) {
cCompiler.args "/MDd"
cppCompiler.args "/MDd"
} else
if (buildType == buildTypes.release) {
cCompiler.args "/MD"
cppCompiler.args "/MD"
} else {
throw new GradleException("Unknown buildType" + buildType)
}
}
if (toolChain in Gcc) {
}
}
}
}
task testsuite { dependsOn "assemble" }
tasks.withType(RunTestExecutable) {
environment "POCO_BASE", "$rootDir"
args test
}