-
Notifications
You must be signed in to change notification settings - Fork 13
Support for testing framework #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
As we get more and more activity on the repositories we should be more and more explicit on describing the intention of the updates at a specific PR. Please, give details on the problem and the enhancements that will bring this PR, including the reasons that triggered it. Those habits will be good to incentive discussions on the different contributions. |
# Conflicts: # CMakeLists.txt # cmake/MacroRootDict.cmake # source/framework/CMakeLists.txt
That is why I made the PR a draft, so I could fill the information as I go, but I agree I should have been a bit more detailed. Thanks! |
|
Currently there is a problem I don't know how to fix, perhaps @nkx111 or @jgalan can give me a hand. It has to do with the Currently I cannot compile the tests due to an error at the end of compilation: To get the error just compile REST with the new TEST flag on: I am not sure how/why a script is being run at compilation but for the all the tests targets I would like to avoid it, but don't know how to do this without probably breaking something since I don't understand this part of the code. This is blocking testing right now :( I think the implementation of the tests is good and I can't think of a modification that would avoid this so we probably need to modify Thanks! |
It seems that the new ExampleTest.cxx is being executed and raised this error. The part of error code is from startup.cpp and will run as long as the framework library is linked. I suggest not to avoid linking it. We can try adding those envs to gtest system. |
but how is it being executed on the build? How could we add this env to the gtest in a simple way? are you sure running some code when linking to REST library is a good practise? seems it can cause a lot of trouble. |
|
something very weird happened with this branch I cannot fix the bug |
In principle, there is no problem to do that with the present cmake system, if |
|
Perhaps you should mention somewhere that the support for old Garfield versions have been removed, since you removed |
This reverts commit e58bdf4.
I decided to keep this file and remove it in a more appropriate PR. |
| @@ -0,0 +1 @@ | |||
| <metadata p1="75" p2="12.32" p3="Aloha" /> No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not keep the convention that the xml header is the name of the c++ metadata class, which is metadataTestClass.
| EXPECT_TRUE(fs::exists(BASIC_TRESTMETADATA_RML)); | ||
|
|
||
| // Create new TRestMetadata class | ||
| class metadataTestClass: public TRestMetadata{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any REST class should be starting by TRest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any REST class should be starting by
TRest
but this is not a class, its just a cpp file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, it is a class, as it is stated in front of it name, I agree we could make an exception inside tests, but I thought it was not possible that the XML header and the class name would be different, it is this possible? @nkx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay now I see what you mean. but this is not a class definition, the same test file could contain many class definitions, it should not begin by TRest imho.
This was introduced by @DavidDiezIb and I think its a great idea to test a class such as TRestMetadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind the naming convention, we can change it if you prefer. Just I thought it was better not to use REST naming convenctions to avoid confussion with any real REST classes.
This is a fake one created to be able to test GetParameter function from TRestMetadata. It is a pure abstract class so we can't call it, we can only inherit from it.
Related to the name of the metadata section, I can modify it to coincide with name of the class, maybe is easier to read. But meta.LoadConfigFromFile(BASIC_TRESTMETADATA_RML, "metadata"); is telling where has to look for the parameters to initialize metadataTestClass (the XML section called "metadata") so doesn't seem to have any problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was introduced by @DavidDiezIb and I think its a great idea to test a class such as
TRestMetadata.
I am not debating that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right, maybe we should remove the option to select the section by hand in LoadFromConfigFile. I don't know if this is useful somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I didn't know that was possible, we never use it that way, isn't @nkx?
Int_t TRestMetadata::LoadConfigFromFile(string cfgFileName, string sectionName) {
fConfigFileName = cfgFileName;
if (TRestTools::fileExists(fConfigFileName)) {
if (sectionName == "") {
sectionName = this->ClassName();
}
So probably we should remove the second argument of that method, and just define a local variable sectionName=this->ClassName()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However I am a bit surprised, I thought the second argument was the given name, so that if I got two TRestMyMetadata definitions I am able to select the one I am interested in:
<TRestMyMetadata name="md1" />
<TRestMyMetadata name="md2" />
So that the constructor would pick up the right definition using:
TRestMyMetadata *md = new TRestMyMetadata("file.rml", "md1" );
md->LoadConfigFromFile( "file.rml", "md1");
At least thats how I am using it inside for example TRestAxionMagneticField and it works.
I guess it is because either option is posible as from the definition NameOrDeclare at:
TiXmlElement* TRestMetadata::GetElementFromFile(std::string cfgFileName, std::string NameOrDecalre)
But why do we need Declare @nkx?
|
I think we should not make any more changes to this branch from this point and merge into master unless someone has any objection @rest-for-physics/core_dev @jgalan . More tests can be added in other PRs. |
|
The upgrade at #165 should allow now to include a test using directly |
Related to #125.
The goal of this PR is to clean the CMake build system wherever possible (it is really complex, it could probably be simplified) and also modify it to support unit testing via ctest. Also I would like to install external dependencies via cmake instead of just copying them into the framework (such as tinyxml) but I won't change tinyxml since its been this way forever, if anything we should probably remove this dependency altogether and replace it by the ROOT xml library which can do what we want.
Testing is enabled via the
-DTEST=ONflag, disabled by default.Tests can be run via ´ctest´ from the build directory.
I will write the boilerplate for testing in all modules. (#163).
Some information about running tests can be found at rest-for-physics/rest-for-physics.github.io@43a1e66.