Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More inteligent running of test tasks #1981

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sshaw
Copy link
Contributor

@sshaw sshaw commented Oct 25, 2015

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:

  1. {test,spec}/*.rake is no longer generated. Instead, a modification to
    the project's Rakefile is made to call PadrinoTasks.use(:xxx). This
    seems to be more in line with Padrino methodology (starting at v0.11 I
    think).
  2. The default rake task will be the test (or spec) task.

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:

1. {test,spec}/*.rake is no longer generated. Instead, a modification to
the project's Rakefile is made to call PadrinoTasks.use(:xxx). This
seems to be more in line with Padrino methodology (starting at v0.11 I
think).

2. The default rake task will be the test (or spec) task.
@sshaw
Copy link
Contributor Author

sshaw commented Oct 25, 2015

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

@namusyaka namusyaka added the test label Dec 16, 2015
@namusyaka
Copy link
Contributor

I love your approach. Thanks for the patch!

@ujifgc
Copy link
Member

ujifgc commented May 4, 2016

It looks like it conflicts with this feature request: #765

@sshaw
Copy link
Contributor Author

sshaw commented May 5, 2016

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.

@ujifgc ujifgc mentioned this pull request May 9, 2016
@sshaw
Copy link
Contributor Author

sshaw commented Feb 12, 2017

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.

  1. rake -T shows what are essentially noop tasks: spec:factories, spec:support, etc...
  2. Because rake spec (or rake test) uses the subfolder based tasks as dependencies, a failing spec prevents all other specs from running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants