Running tests in Aspect

Hello,
I am working on writing tests for our modified function of read_and_distribute_file_content that can now read from URLs. I was curious as to how Aspect’s current tests are written/implemented and how I should go about setting up regression/unit tests to test our modified function?

Thanks,
Kodi

Did you see the section about running/writing tests in the manual?
https://tjhei.github.io/aspect-www-manual/#sec:testing

Testing loading from URLs is a bit difficult. I would hate if our automated tests need internet access. I am not sure what best to do in this case…

Are prm files the only way to test new code? I will try to think of ways to test the url reader without a constant internet connection, but right now I can’t think of too many ways to do that…

It may be able to be tested if a localhost is setup and then the url reader pulls data from the example files on there?

You can test individual functions by writing a unit test, see https://github.com/geodynamics/aspect/tree/master/unit_tests
This is a better place to test a function than with a .prm. Note that you can not test parallel things there right now.

That said, having unittests make http requests is also not great. One thing we could do is that you set up your function to allow “mocking” in some way (you simulate the download for testing). Do you have your code pushed online already? Maybe we can get an idea by looking at the code.

Yes, I have our code on a forked repository here: https://github.com/OPENDAP/aspect

We came up with a solution that we could make our addition to the read_and_distribute_file_content() a conditional. The user can add the option when they run cmake to include the libdap libraries required for reading the url data, and if this option is set to “ON” then our code is used (this code is still able to read local files).

We couldn’t think of any ways to test an online function without being online. Maybe this could help some way with testing, this way the automated server won’t have to worry about checking the online tests unless given the option to.

That makes sense. What are you planning to have the function return if the dependency is not set up?

Right now if the dependency is not set up it will just run the original function. If someone tries to pass in a url as a filename I will have it output an error indicating the dependency is not set up.