Keep 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.
You 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.
Re:How to undo almost anything with Git
by nothrabannosir on Monday June 08, 2015 @04:17PM
(#9682082)
try 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?
Thanks! 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.
Sounds like something that would be a lot easier to handle with "svn revert"..
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.