Ensure unit tests can find test data (#15). #70
Conversation
# Drop in the test data | ||
fusiontestdir = os.path.join(testdir, 'fusion') | ||
shutil.rmtree(fusiontestdir, ignore_errors=True) | ||
shutil.copytree('../../fusion', fusiontestdir) |
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 seems will copy src/fusion to ${bin}/tests/fusion? Why do we need this?
I couldn't find an issue for this fix,
Can you please add an issue, so it will be easier to figure out what this fix is for?
Thanks.
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 is issue #15 - the tests look for data in that location.
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.
Thank you.
I believe you need to copy only src/fusion/testdata.
Another solution could be updating tests to report more informative message that test needs to be run from src-dir...
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.
The build instructions (https://github.com/google/earthenterprise/wiki/Build-Instructions#building-earth-enterprise-fusion-server-on-ubuntu-1404-lts-and-rhel-7) say to run it from the build dir.
If you run from the source root, you'll end up with some test products in the source dir (rather than the build dir). That is messy (pollutes git, which could be overcome with .gitignore) and might be an issue for building on multiple architectures when we get to that stage.
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'm a little torn on this issue. On the one hand, it seems more natural to run the tests from the build directory instead of src, and I certainly don't want to keep track of a bunch of random temp files in .gitignore. But, on the other, copying all the test data can end up taking up a lot of space. I think ideally we would read the data out of the source data but keep the working directory under /bin/tests. I'll leave this up to you, @bradh, how much more effort you'd like to put into it. But, I do agree with @andreisel that we should minimize the data that is copied by limiting to the testdata directory if possible. It's 113MB for testdata vs. 317M for all of fusion.
# Drop in the test data | ||
fusiontestdir = os.path.join(testdir, 'fusion') | ||
shutil.rmtree(fusiontestdir, ignore_errors=True) | ||
shutil.copytree('../../fusion', fusiontestdir) |
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'm a little torn on this issue. On the one hand, it seems more natural to run the tests from the build directory instead of src, and I certainly don't want to keep track of a bunch of random temp files in .gitignore. But, on the other, copying all the test data can end up taking up a lot of space. I think ideally we would read the data out of the source data but keep the working directory under /bin/tests. I'll leave this up to you, @bradh, how much more effort you'd like to put into it. But, I do agree with @andreisel that we should minimize the data that is copied by limiting to the testdata directory if possible. It's 113MB for testdata vs. 317M for all of fusion.
As discussed on slack, a better solution would be to do the mkdir() for |
I considered adding a symlink, but since the tests create files in the test data directory, a copy seemed safer.