project-layout icon indicating copy to clipboard operation
project-layout copied to clipboard

What about "testdata"

Open niondir opened this issue 7 years ago • 7 comments

It seems common to have a "testdata" directory for additional test data. Any specific reason why it's not included in this repo?

niondir avatar Mar 31 '18 00:03 niondir

The /test directory is the place to store test data in addition to any extra test tools you need, so you might have /test/data and /test/tools or some other subdirectory structure.

kcq avatar Apr 13 '18 00:04 kcq

@Niondir As an example: https://github.com/openshift/origin/tree/master/test There is a top level testdata directory within the test directory, but also testdata directories inside of each more specific type of test directory. You can also create other files and/or directories inside of the testdata directory to provide further organization.

coreydaley avatar Apr 14 '18 02:04 coreydaley

@coreydaley nice example! The same OpenShift repo includes a number of other common project layout patterns: /cmd (https://github.com/openshift/origin/tree/master/cmd), /pkg (https://github.com/openshift/origin/tree/master/pkg), /tools (https://github.com/openshift/origin/tree/master/tools), /api (https://github.com/openshift/origin/tree/master/api) and /docs (https://github.com/openshift/origin/tree/master/docs).

kcq avatar Apr 14 '18 22:04 kcq

fwiw, a testdata directory is special, because it will be skipped by go commands like go install ./.... test/data does not have this effect.

h8liu avatar May 22 '18 17:05 h8liu

True, testdata is special, so you can make it test/testdata if you want to take advantage of it :-)

kcq avatar Jun 28 '18 03:06 kcq

Would y'all accept a doc PR mentioning how testdata is special?

adamdecaf avatar Oct 02 '18 18:10 adamdecaf

fwiw, a testdata directory is special, because it will be skipped by go commands like go install ./.... test/data does not have this effect.

I don't think you're right. Take a look inside $GOPATH/bin after running go install ./... and testdata contains some files with package main declaration. I'm still trying to understand what's so special about this dir

scirlig-ellation avatar Oct 18 '19 14:10 scirlig-ellation