--
You received this message because you are subscribed to the Google Groups "NAR Maven plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-nar+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Jef,
Great writeup! Would you care to add it as a wiki page? Then it will be more accessible for others.
Regards,
Curtis
Hello,
If the case is not yet resolved, here is how I use the tests on nar-maven-plugin.
First, by default, the phase test-compile (goal nar:nar-testCompile) will compile the files in src/test to create one or many executables which will be linked against the library built by the project (if the <libraries> <library> <type> in <configuration> is "static" or "shared").
The compiler and the linker used when building the test executables can have some specific options, but theses options will be added to the options used to build the library !
Here is how to define those options :
<configuration>
<c>
<name>gcc</name>
<options>
...
</options>
<testOptions>
<!-- testOptions are added to regular options for test compilation -->
...
</testOptions>
</c>
<cpp>
<name>g++</name>
<options>
...
</options>
<testOptions>
<!-- testOptions are added to regular options for test compilation -->
...
</testOptions>
</cpp>
<linker>
<name>g++</name>
<options>
...
</options>
<testOptions>
<!-- testOptions are added to regular options for test linkage -->
...
</testOptions>
</linker>
</configuration>
A consequence of the fact that the test options are added to the regular options, is that if you build a static library, the <linker> <options> must be empty as the ar command doesn't take any "gcc option", but the <linker> <testOptions> must contain all the gcc linker options to build the test executables.
Second, to define the test executables which will be built, you must use the <tests> <test> elements, example :
<configuration>
<tests>
<test>
<name>testOne</name>
<link>shared</link>
<run>true</run>
</test>
<test>
<name>testTwo</name>
<link>shared</link>
<run>true</run>
<args>
<arg>param1</arg>
<arg>param2</arg>
</args>
</test>
</tests>
</configuration>
The configuration above will build 2 executables, testOne and testTwo, each executable will be built with all the test source files whose names don't correspond to the names of other tests.
If we have 4 files in src/test/c for example, main.c, util.c, testOne.c and testTwo.c, the executable testOne will be built from main.c, util.c and testOne.c (testTwo.c is not retained because it has the same name of another test), and the executable testTwo will be built from main.c, util.c and testTwo.c.
Of course you can have only one source file per test with the name of the test, each executable will then be built only from its source file.
Note : my tests files are always c++ files (src/test/c++/(filenames).cpp), the filtering of test files above works with cpp files names, but I gess it works the same with c files names.
And I set <test> <link> value with "static" or "shared" accordingly to the type of the library I test, I never tried to set the other type to see what happens ...
And third, with the <test> <run> with the value "true", the test executables are run on the phase test (goal nar:nar-test), and if the return value of one of the executions is not 0, the test is failed and the build is failed.
That's all I know, I hope it responds to the demand :)
Jef
To unsubscribe from this group and stop receiving emails from it, send an email to maven-nar+unsubscribe@googlegroups.com.