CleanCut / green

Green is a clean, colorful, fast python test runner.
MIT License
785 stars 75 forks source link

no way to exclude/omit/skip tests in subdir #216

Closed blech75 closed 4 years ago

blech75 commented 4 years ago

I'm working on a Google App Engine project (Python 2 😬) that has its libs frozen in ./lib and ./test/lib. When I run green test, it fails on tests in ./test/lib, which I don't want to be run in the first place.

Is there any way to exclude subdirectories? (I noticed that we can omit dirs from coverage reports via -o, but not from running tests.)

To work around this, I'm proposing moving our frozen test deps ./test/lib to ./lib.test, but I'd rather not rock the boat just for using Green. :-)

CleanCut commented 4 years ago

Technically, no. There isn't a way to specify paths to exclude. I could see how that could be a useful feature, though!

As a workaround, you could specify all the other paths except that directly, either by manually typing them out or getting clever with how you pass the arguments to green. For example, if you are using bash:

# Turn on extended glob patterns
shopt -s extglob
# Pass green everything except in `test/` except `test/lib`
green test/!(lib)

or

# - List everything in test
# - Filter out test/lib
# - Pass the remainder to xargs to run green with
ls -d test/* | sed -e 's/test\/lib//' | xargs green
CleanCut commented 4 years ago

I'm going to go ahead and close this issue.

I am not planning on adding this feature, because I'm subclassing and modifying unittest.TestLoader in a pretty crazy way, and I don't want to ever touch that code again if I can avoid it. 😝