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

Make cython tests portable #376

Closed

Conversation

bryanwweber
Copy link
Member

@bryanwweber bryanwweber commented Oct 26, 2016

Makes the Cython test suite portable by removing relative file references and ensuring all input files are in the in-package test/data directory. This enables running the entire test suite out-of-build directory, particularly in the conda package.

Rather than changing to the work directory, ensure all input/output files come from
the the in-package test/data directory. This makes the Cython test suite standalone
and the tests can be run using unittest as: python -m unittest -v cantera.test
@speth
Copy link
Member

speth commented Oct 26, 2016

Funny story: I just wrote the same thing yesterday, but hadn't gotten around to pushing it to Github yet. Oh well.

@bryanwweber
Copy link
Member Author

Ha I was wondering if I should make a post on the Group about this. Oh well, it only took me a few hours today to figure it all out. Actually, I made #375 as I was trying to debug this PR.

@bryanwweber
Copy link
Member Author

bryanwweber commented Oct 27, 2016

@speth If you don't have any code comments, I think this is good to merge

p = self.get_test_data_directory()
convertMech(pjoin(p, 'gri30.inp'),
transportFile=pjoin(p, 'gri30_tran.dat'),
outName=pjoin(p, 'gri30_test.cti'), quiet=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By setting the output name like this, you put the output file into the test/data directory which (a) pollutes that directory and (b) won't work if that directory isn't writable, e.g. if Cantera is installed as an Ubuntu package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I was trying to avoid spraying random output files all over the user's file system. Would it be better to use a temporary directory in the OS's temp storage?

@speth
Copy link
Member

speth commented Oct 27, 2016

You can avoid introducing duplicate copies of input files by adding the following to interfaces/cython/SConscript:

for f in ['inputs/h2o2.inp', 'inputs/gri30.inp', 'transport/gri30_tran.dat']:
    build(localenv.Install('#interfaces/cython/cantera/test/data/', '#data/'+f))

I pushed my implementation of this to https://github.com/speth/cantera/tree/python-testsuite if you want to compare approaches and see if there are ideas from each that we should use.

@bryanwweber
Copy link
Member Author

@speth Thanks for the comments. I'll work on this over the weekend and push a new PR.

@bryanwweber bryanwweber mentioned this pull request Nov 9, 2016
@bryanwweber
Copy link
Member Author

Closing in favor of #381

@bryanwweber bryanwweber closed this Nov 9, 2016
@bryanwweber bryanwweber deleted the make_cython_tests_portable branch November 11, 2016 22:46
@speth speth mentioned this pull request Nov 29, 2016
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

Successfully merging this pull request may close these issues.

2 participants