gow icon indicating copy to clipboard operation
gow copied to clipboard

Proposal: Add option to watch `testdata` subdirectories

Open sean-ahn opened this issue 2 years ago • 5 comments

Hello,

Firstly, kudos for your valuable contributions through the gow package.

Considering that the use of testdata directories is idiomatic in Go[^1], introducing an option such as --testdata to automatically monitor all testdata subdirectories within the current watch directory could be beneficial.

Please feel free to correct me if my understanding of the gow's capabilities is inaccurate.

[^1]: For instance, see https://github.com/golang/go/tree/master/src/image/testdata

Best regards.

sean-ahn avatar May 30 '23 04:05 sean-ahn

Pretty sure this is already possible via -w=testdata. 🙂

mitranim avatar May 30 '23 11:05 mitranim

Minor correction: -w would require you to list the path to each testdata (either comma-separated or by repeating the -w flag with another value). There's currently no support for specifying path patterns. It could be added if desired.

mitranim avatar May 30 '23 14:05 mitranim

@mitranim, thank you for your support! IMO, it would significantly enhance the utility of gow if it could support glob patterns for specifying file paths to watch. This feature could be handy, especially in larger codebases where numerous testdata subdirectories could be present. Could you consider adding this feature? Is it feasible? Also, I'm open to contributing to this work directly if possible. 🙂

sean-ahn avatar Jun 01 '23 16:06 sean-ahn

Currently, I can currently do this with the command below: gow -v -c -w $(find . -type d -name "testdata" | tr '\n' ',') test -race -v ./...

sean-ahn avatar Jun 01 '23 17:06 sean-ahn

I have a tentative local implementation that would add new flags -W (counterpart to -w) and -I (counterpart to -i) that use filepath.Match for glob-like functionality. It supports * to match arbitrary names, but doesn't support matching arbitrary sub-paths via **. Would that satisfy your use case, or is it insufficient?

mitranim avatar Jun 06 '23 11:06 mitranim