3 ms·
Something I'm still working out.... I have a directory tree full of test data. As the project goes along, the test data will evolve, and thus should go under
by thyrsus 11y ago
Something I'm still working out....
I have a directory tree full of test data. As the project goes along, the test data will evolve, and thus should go under revision control.
Testing needs to start with known files, so, hey!, git checkout test_data - except that means my latest code revisions need to go into the test_data branch even before they're tested :-(.
Then the tests make their changes to the data, which the tests check, and which I then want to throw away. So: "git checkout test_data -f; git clean -f" -- except that cleans out the source code area as well as the test data area.
I'm thinking the test data should be separate repository. Is that a mistake?
[Edit] I've tried looking at stackoverflow.com, but searching for "git testing" returned ~7000 articles, the first few hundred of which didn't look relevant.
- phaemon 11y agoYou can do: git checkout test_data 'testdata/' to only grab the 'testdata/' directory from that branch. You can do this with files with a pattern, like '*.c', as well.
- nothrabannosir 11y agotry putting test data templates in test_templates (under rev control), and doing rm -rf test_data, cp -r test_templates test_data at the start of your testing routine. Put test_data in .gitignore. does that help?
- lmm 11y agoKeep the "pristine" version of the test data in src/ (checked into git), have the build process copy it into target/ (or build/ or whatever you want to call it; either way, ignored in git) before starting testing.
- thyrsus 11y agoThanks! On the one hand, git seems to restore the test data to its initial state faster than rm -r; cp -r, but I'm getting a strong hint from these answers that keeping the test data explicitly in sync with the code is worth the minor delay.
- pjc50 11y agoSounds like something that would be a lot easier to handle with "svn revert"..
- lmm 11y agoOnly if you're looking for excuses to prefer svn. You can do the exact same thing you would with 'svn revert' with 'git checkout --'.