coala / coala

coala provides a unified command-line interface for linting and fixing all your code, regardless of the programming languages you use.
https://coala.io/
GNU Affero General Public License v3.0
3.55k stars 1.31k forks source link

green test runner #4060

Open jayvdb opened 7 years ago

jayvdb commented 7 years ago

Very likely due to https://github.com/coala/coala/issues/3808 and other issues, on c929a8b45, this is the output of https://github.com/CleanCut/green

green -vv
3
Ran 0 tests in 0.160s

No Tests Found
userzimmermann commented 7 years ago

@jayvdb The actual problem is stated at https://github.com/CleanCut/green#external-structure

  1. The test modules need to start with test.
userzimmermann commented 7 years ago

@jayvdb Take a look at https://github.com/pchomik/pytest-spec

It gives equally nice (and colored) output:

$ py.test -vv --spec
...
tests/bears/BearTest.py::BearTest
    [PASS]  Bad bear
    [PASS]  Check prerequisites
    [PASS]  Default aspects
    [PASS]  Dependencies
    [PASS]  Detect and fix aspects
    [PASS]  Get config dir
    [PASS]  Get non optional settings
    [PASS]  Inconvertible
    [PASS]  Message queue
    [PASS]  New result
    [PASS]  No detect aspects
    [PASS]  No fix aspects
    [PASS]  No queue
    [PASS]  Print filename LocalBear
    [PASS]  Print no filename GlobalBear
    [PASS]  Simple api
...
jayvdb commented 7 years ago

green is more than an output formatter.

And this bug is about that 3 in that output, and the configuration needed for green to work correctly by default, or discussing any changes needed.

userzimmermann commented 7 years ago

@jayvdb You can run our tests with green --file-pattern "*Test.py"

Or you create some arbitrarily named config file, let's say .green (which is the name of the global config file green looks for in $HOME), containing:

file-pattern = *Test.py

and run green --config .green

Regarding the 3: I debugged it but I couldn't find any reason for that so far :/

CleanCut commented 7 years ago

@jayvdb coala/tests/misc/test_caching_multi_results/test.py has a print statement at global scope:

a = 3
print(a)

@userzimmermann is correct ... you can either follow the default unittest discovery structure of filenames matching test*py, or you can specify your own file-matching pattern with command-line options or config files.

Either way, Green expects tests to be methods of a unittest.TestCase subclass and methods that match a specific naming pattern (test* by default, also overridable).

userzimmermann commented 7 years ago

@CleanCut And I am debugging my time away instead of just grep'ing for the most obvious :D

CleanCut commented 7 years ago

That just means you are a much harder worker than I am... ;-)

jayvdb commented 7 years ago

Note that test discovery without patterns is https://github.com/CleanCut/green/issues/87

And per project configuration is https://github.com/CleanCut/green/issues/116

[edit] or re-use setup.py test information : https://github.com/CleanCut/green/issues/158

We need either of those to work before we can support green.

CleanCut commented 7 years ago

Ah, well per-project configuration has been at the top of the list for me, so...it's at the top of the list. :-/ Gotta make time.

CleanCut commented 7 years ago

@jayvdb Wife and son sick with the flu today. In between taking care of them I implemented per-project configuration support for green. Included in Green 2.8.0 (just released).