-
Notifications
You must be signed in to change notification settings - Fork 481
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
New options for run_all/reload guard method #14
Comments
I totally agree ;) I push a "working in progress" feature branch today or tomorrow. |
These options seem cool to me but will it be possible for guards developer to set those without the possibility for users to overwrite these options? For example, if the developer of a guard wants to never reload or run_all on any signals, the user should not be able to specify options that would cancel this behavior. |
If a developer never want to reload/run_all on signal, actually the only way to call these methods, he just don't implement them :-) |
Ok fair enough, btw my example was the opposite of what I thought: "If a developer wants to always run_all/reload, the user should not be able to cancel this behavior". Do you have some concrete examples of the use of these options in a "real scenario"? |
In my opinion if run_all/reload should not be disabled the user need to be smart enough to not doing that. "Real scenario" Examples:
|
You can see work in progress branch at https://github.com/guard/guard/tree/guard_optionnal_actions :disable and :at_start work with this implementation you can control this in each guard code to add more optional case (but it is not recommended to overwrite normal option result). |
I like the new options and I'd like to see even more of these: it would be nice if I could make the execution of a guard dependent on the result of another guard. Let me illustrate this with a few examples:
This configuration will run all cucumber features after rspec has run all specs successfully. This would enable a autotest like configuration for guard-rspec and guard-cucumber.
This configuration would run jasmine tests for a changed file after is has been successfully compiled into JavaScript. (The Jasmine guard doesn't exist for now, but who know). If there are multiple guards of the same type configured, they can have an id options for unique identification:
This implies a change that each plugin has to return either true or false in the #run_on_change and #run_all methods. Michael |
Yes, :depends option is a good idea, but the :id stuff is maybe overkill... a smart convention could be better... don't have better idea at the moment :-) I'm thinking about another option, something like :non_blocking/threadable => true, that will make running the guard plugin without having to wait for his result (could be useful for guard-passenger). |
Guard referencing by id may be unnecessary if we switch to a notification push approach instead of a pull approach. Last week I sat down and wrote my dream Guardfile and it looks like this:
Let me dissect the above Guardfile: threadsThe thread keyword switches the Guard loop to a non-blocking mode, where the fs listener will keep listening for changes and spawns the Guard executions to the maximum number of threads defined. This allows to choose the optimal setting depending on the CPU. groupThe above example introduces groups that let me choose to run only a subset of the guardfile:
So when I am focusing on frontend development, I could omit the whole backend testing stuff. :start optionWhen the :rerun optionWhen the This would imply that a Guard must return an Array with the failed files after a run method has been triggered. If everything succeed returns nil or an empty Array. :success optionWith the The What do you guys think of this DSL extensions? Do you see any problems? I'm wondering especially about the thread option, since I have no clue why it was decided to block the fs listener on guard execution. The Thanks for any feedback. |
Here some remarks for each points: ThreadsI don't think all guard should be running in thread, for example guard-spork must always running before guard-rspec/cucumber. So there is some real dependencies between some guards. Maybe a GroupsSound like a great feature to add :start optionIt's the same as :rerun optionThis option should be added inside guard-rspec/test/cucumber instead of Guard itself, don't you think? :success optionI think using I just commit a change that remove the blockage of listeners on guards execution so a Thanks for all your suggestions/ideas. |
The change you made on Guard to not block the listeners is sufficient and makes the threading obsolete for me. I will definitely take care of the Guard Groups and you can expect a pull request in the near future. I also agree that the rerun option is very specific and should be handled in the Guard implementations that need such a feature. I will do this for guard-cucumber soon. Regarding the automatic start of a Guard and triggering other Guards after completion I also think we need to find the optimal DSL before starting the implementation. But since yannlugrin already started a branch with Thanks for the feedback. |
I think this is going to end up just a +1 comment. But I'm happy everyone is thinking about this. Would love to plug |
Hi guys, The Could we discuss it and maybe finally find a proper DSL for it? We should also define precisely all the possibility of this option. Examples: # will run the Guard::RSpec#run_all and Guard::Cucumber#run_all methods.
guard 'spork', :on_success => { :run_all => [:rspec, :cucumber] }
# will run the Guard::Cucumber#run_on_change method with the paths run by Guard::RSpec.
guard 'rspec', :on_success => { :run_on_change => :cucumber } |
+1 for the latest DSL proposal. It's perfectly self-describing. |
+1 for the latest DSL proposal too. We can make it! :) |
usually i dont like the rerun of all specs on success, as it takes a long time and stops me from quickly adding a new test and seeing it fail. But disabling it completely seems too drastic, so how about guard 'spork', :on_success => { :run_all_when_5_minutes_idle => [:rspec, :cucumber] }
guard 'spork', :on_success => { :run_all_when_50_seconds_idle => :rspec } 5_minutes_idle would be method missing, so it adjusts the idle time based on the method name |
Hi, Personally, I would prefer something like this: guard 'spork', :on_success => { :run_all => [:rspec, :cucumber], :if => { :idle_for => 5*60 } } It's maybe a bit too verbose, but the point is that I don't really like putting arguments inside a Hash key. Also note that we probably would't use |
Oh now i see, thanks for the tip, agreed :) |
You're welcome. By the way, I think your suggestion in itself, to run all the specs only when Guard has been idle for a certain amount of time is interesting. But anyway, we'll first have to implement the basis of this new |
Oh my dear GitHub issue, I've looked at you many times, because you're still in |
👍 ^^ Sent from my iPhone On 19 oct. 2012, at 00:42, Michael Kessler notifications@github.com wrote:
|
Discussed with YannLugrin, three new options should be added for run_all/reload guard method and could be specify per guard. Options are:
Example:
What do you think about that?
The text was updated successfully, but these errors were encountered: