Skip to content
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

proper build structure of tests #2

Open
fnrizzi opened this issue Mar 9, 2020 · 3 comments
Open

proper build structure of tests #2

fnrizzi opened this issue Mar 9, 2020 · 3 comments
Assignees

Comments

@fnrizzi
Copy link
Member

fnrizzi commented Mar 9, 2020

Right now we have to copy the python test files into the same directory as the .so file so we can easily import pressio4py into the python test files. We want to place the test files in the correct subfolders. One option is to add a temporary python path in the beginning of the .py test file so that the python file doesn’t have to be in the same directory as the python .so file. Alternatively, we need to look for a method to somehow temporarily add a path to the python file (similar to the addpath functionality) but using a cmake directive in case we might need to change the directory structure.

Right now, when you build you get this structure (subdirectories are marked with *):

*burgers1d_galerkin
*burgers1d_lspg
burgers1d_sparse_jacobian.py
cmake_install.cmake
CMakeCache.txt
*CMakeFiles
Makefile
pressio4py.cpython-36m-darwin.so
test_burgers1d_galerkin.py
test_burgers1d_lspg.py
test_decoder.py
test_wrapper_module.cpython-36m-darwin.so
test_wrapper.py
*tests

what I would like is to have all tests inside tests, which means tests should have the same structure that is has in the source as follows:

tests
  /regression
    /burgers1d_galerkin
    /burgers1d_lapg
  /unit
    test_decoder.py
    test_wrapper.py 
    test_wrapper_module.cpython-36m-darwin.so

and the top-level build then looks like this:

cmake_install.cmake
CMakeCache.txt
*CMakeFiles
Makefile
pressio4py.cpython-36m-darwin.so
*tests
@kennychowdhary
Copy link
Collaborator

After some quick googling, there might be three options here:

  1. Move all test files to their respective folders and just add an "addpath" line to the beginning of the test*py file that includes the directory of the .so file
  2. There might be an option in pytest to temporarily define a python path when you call pytest from the command line. But then the user has to know where the .so file is in the build directory.
  3. CMAKE's ctest function might be able to handle the execution of pytest all together. I think you can define pytest as the command to perform the test in CMAKE. This last option could work in combination with (1) and (2).

I will try (1) since that is the easiest, and then see if (2) or (3) is a possibility.

@fnrizzi
Copy link
Member Author

fnrizzi commented Mar 11, 2020

  1. Move all test files to their respective folders and just add an "addpath" line to the beginning of the test*py file that includes the directory of the .so file

This is fine with me!
Please keep the structure consistent between source and build like said above.

@kennychowdhary
Copy link
Collaborator

We can now do this. We just need to setup the relative paths correctly so that when we import modules in the test scripts it find the right libraries. Let's discuss soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants