padrino-framework
padrino-framework copied to clipboard
More inteligent running of test tasks
Related to #1937 and #1979.
Let me know what you think. I do have some issues with things like this. I just piggybacked on it as poor man's way to avoid two sets of test tasks but, in the case of the DB tasks, why is it needed? Shouldn't this sort of stuff be handled by adding the :environment
task as a prerequisite? Anywayz...
For minitest, since the spec format is being used (but also see #1848), I think the task should look for *_spec.rb
files and maybe the same goes for bacon, but I left them as is to minimize future impact.
In summary:
This generates test tasks based on the presence of test files and groups tasks by subapp (apps named "app" are ignored).
Previously, everything under the test directory was added
as an individual test task, which resulted in N invocations
of rake test
, often times on directories that had no tests (e.g.,
support or factory files).
Additional changes, note that these should only affect new projects:
-
{test,spec}/*.rake
is no longer generated. Instead, a modification to the project's Rakefile is made to callPadrinoTasks.use(:xxx)
. This seems to be more in line with Padrino methodology (starting at v0.11 I think). - The default rake task will be the test (or spec) task.
This generates test tasks based on the presence of test filesand groups tasks by subapp (apps named "app" are ignored).
Let me elaborate with an example. Here, foo
is an app:
/tmp/padrino-rspec >tree spec
spec
├── app
│ ├── controllers
│ │ └── bar_controller_spec.rb
│ └── helpers
│ └── bar_helper_spec.rb
├── foo
│ └── models
│ └── bar_spec.rb
├── models
│ └── sshaw_spec.rb
├── not_a_app
│ ├── bar_spec.rb
│ └── foo.rb
└── spec_helper.rb
7 directories, 7 files
/tmp/padrino-rspec >rake -T spec
=> Executing Rake -T spec ...
rake spec # Run application test suite
rake spec:controllers # Run specs in spec/app/controllers
rake spec:foo # Run all the specs for the foo app
rake spec:foo:models # Run specs in spec/foo/models
rake spec:helpers # Run specs in spec/app/helpers
rake spec:models # Run specs in spec/models
rake spec:not_a_app # Run specs in spec/not_a_app
I love your approach. Thanks for the patch!
It looks like it conflicts with this feature request: #765
It looks like it conflicts with this feature request: #765
What do you want to do? Has that feature been implemented? If not I say we go with this until the other feature is ready. Current test tasks are broken and can be annoying (see #1937 and #1979). This will fix it.
Is there any interest in merging all or part of this? #765 has not been merged and current test behavior has two issues: one small yet annoying and the other somewhat big.
-
rake -T
shows what are essentially noop tasks:spec:factories
,spec:support
, etc... - Because
rake spec
(orrake test
) uses the subfolder based tasks as dependencies, a failing spec prevents all other specs from running.