configuring guard groups to only run a group of tests

28 views
Skip to first unread message

david conner

unread,
Feb 21, 2013, 1:16:31 PM2/21/13
to guar...@googlegroups.com
so i configured my guardfile with a few groups: backend, frontend, redis, app, integration.

https://gist.github.com/dcunited001/140a4a518cc0896a25a8

here's the behavior i want:
- when any of the files from "app" are changed: reload the environment, dont do anything else (working)
- when any of the files from "backend" are changed, run that file's tests (not the all group's tests) (working)
- same behavior for the other groups (frontend, redis, app, integration) (working)
- when i start guard, i want no tests to run at start (working)
- when i start guard, i want it in the correct scope (working)

most importantly:
- when i press enter at the guard prompt in the :groups scope, run all the select groups scopes.  any way to do this?

Michael Kessler

unread,
Feb 22, 2013, 2:42:13 AM2/22/13
to guar...@googlegroups.com
David,

> so i configured my guardfile with a few groups: backend, frontend, redis, app, integration.
> https://gist.github.com/dcunited001/140a4a518cc0896a25a8

That's a really nice Guardfile!

> - when i press enter at the guard prompt in the :groups scope, run all the select groups scopes. any way to do this?

That should already be possible. I added a simple debug statement to the runner to make it visible:


https://github.com/guard/guard/blob/master/lib/guard/runner.rb#L54

def run(task, scopes = {})
Lumberjack.unit_of_work do
scoped_guards(scopes) do |guard|
puts "Run plugin #{ guard.inspect } from group #{ guard.group.inspect }" # <== Added this
run_supervised_task(guard, task)
end
end
end

and the output with your `Guardfile` is as follows:

08:41:13 - INFO - Guard uses Growl to send notifications.
08:41:13 - INFO - Guard uses TerminalTitle to send notifications.
Run plugin Minitest from group :app
Run plugin Minitest from group :frontend
Run plugin Minitest from group :backend
Run plugin Minitest from group :redis
08:41:13 - INFO - Guard is now watching at '/Users/michi/Desktop/test'
[1] {App,Frontend,Backend,Redis} guard(main)>
08:41:16 - INFO - Run App,Frontend,Backend,Redis
Run plugin Minitest from group :app
Run plugin Minitest from group :frontend
Run plugin Minitest from group :backend
Run plugin Minitest from group :redis
[2] {App,Frontend,Backend,Redis} guard(main)> o app
[3] {App} guard(main)>
08:41:24 - INFO - Run App
Run plugin Minitest from group :app
[4] {App} guard(main)> o frontend
[5] {Frontend} guard(main)>
08:41:33 - INFO - Run Frontend
Run plugin Minitest from group :frontend
[1] {Frontend} guard(main)>
Run plugin Minitest from group :frontend
08:41:38 - INFO - Bye bye…

I do not have the files, but as you can see it triggers the correct plugin from the current scope.

Michael



Reply all
Reply to author
Forward
0 new messages