Native syntax error on testSuites definition

issue-acknowledged
gradle-3570

(ZOSROTHKO) #1

Hi

I got a syntax error on the following snippet

        testSuites {
            PocoFoundationTest(CUnitTestSuiteSpec) {
                testing $.components.PocoFoundation
            }
        }
build file 'build.gradle': 69: Invalid variable name. Must include a letter but only found: $
. At [69:13]  @ line 69, column 13.
                                testing $.components.PocoFoundation

What should be the correct syntax?

TFYH


(Paul Merlin) #2

Syntax looks good. It is on par with the manual, see https://docs.gradle.org/current/userguide/native_software.html#sec:running_cunit_tests
Hard to tell what’s the issue without a more complete build script.
Is your snippet inside a model block?


(ZOSROTHKO) #3

Is your snippet inside a model block?
Yes… Here the full build.gradle

project(":Foundation") {
    model {
        def os = org.gradle.internal.os.OperatingSystem.current()
        components {
            PocoFoundation(NativeLibrarySpec) {
                sources {
                    mc {
                        source {
                            srcDir 'src'
                            include '**/*.mc'
                        }
                    }
                    rc {
                        source {
                            srcDir 'src'
                            include '**/*.rc'
                        }
                    }
                    c {
                        source {
                            srcDir 'src'
                            include '**/*.c'
                        }
                        exportedHeaders {
                            srcDir 'include'
                        }
                    }
                    cpp {
                        source {
                            srcDir 'src'
                            include '**/*.cpp'
                            exclude 'ByteOrder.cpp'
                            exclude 'String.cpp'
                            exclude 'SignalHandler.cpp'
                            exclude 'Environment_*.cpp'
                            exclude 'FPEnvironment_*.cpp'
                            exclude 'Timezone_*.cpp'
                            exclude 'DirectoryIterator_*.cpp'
                            exclude 'File_*.cpp'
                            exclude 'FileStream_*.cpp'
                            exclude 'Path_*.cpp'
                            exclude 'LogFile_*.cpp'
                            exclude 'NamedEvent_*.cpp'
                            exclude 'NamedMutex_*.cpp'
                            exclude 'PipeImpl_*.cpp'
                            exclude 'Process_*.cpp'
                            exclude 'SharedMemory_*.cpp'
                            exclude 'SharedLibrary_*.cpp'
                            exclude 'Event_*.cpp'
                            exclude 'Mutex_*.cpp'
                            exclude 'RWLock_*.cpp'
                            exclude 'Semaphore_*.cpp'
                            exclude 'Thread_*.cpp'
                            if (os.isWindows()) {
                                exclude 'SyslogChannel.cpp'
                                exclude 'OpcomChannel.cpp'
                                exclude 'AndroidLogChannel.cpp'
                            }
                        }
                        exportedHeaders {
                            srcDir 'include'
                        }
                    }
                }
            }
        }
        testSuites {
            PocoFoundationTest(CUnitTestSuiteSpec) {
                testing $.components.PocoFoundation
            }
        }
        binaries {
            all {
                if (toolChain in VisualCpp) {
                    linker.args 'ws2_32.lib'
                    linker.args 'iphlpapi.lib'
                }
            }
            withType(SharedLibraryBinarySpec) {
                if (toolChain in VisualCpp) {
                    cCompiler.define "Foundation_EXPORTS"
                    cppCompiler.define "Foundation_EXPORTS"
                }
            }
        }
    }
}

(David Falkinder) #4

Looks identical to the issue I questioned yesterday ( forum link )

I think the issue is that it’s within the project scope ( the $. syntax ) - I just don’t know whether it’s an actual issue or why.

I bet if you move the model {} to an external script, then apply from: ‘external-script’ within the project it all magically works.

Sorry to not be of more help.


(ZOSROTHKO) #5

Putting the model in an external script solves the issue…; May be you can open a bug on this point?


(David Falkinder) #6

One of the core devs kindly already did - GRADLE-3570

See the other thread I’d mentioned.