Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Guard clears screen more than once per single watch event #316

japgolly opened this Issue · 8 comments

2 participants


Hi. If you run guard with the -c option Guard is clears the screen before running new tests. There is a problem, however, when used in conjunction with multiple guard groups. See the following example of a scenario with two groups

  1. File modified.
  2. Guard checks Group A
    1. Clear screen.
    2. Matching rule found - run test.
  3. Guard checks Group B
    1. Clear screen.
    2. No matching rule found - do nothing.

Which means the user sees tests run and then they disappear before they can be read.


Extra info:

With my setup, this is consistently replicatable.
Given the Guardfile below, if I edit anything under lib/blah/ the screen gets clears twice.
If I edit anything under test/unit or test/spec then it correctly only gets cleared once.

Guardfile (simplified)

# Ignore Vim swap files
ignore /~$/
ignore /^(?:.*[\\\/])?\.[^\\\/]+\.sw[p-z]$/

group :unit do
  guard 'minitest', test_folders: 'test/unit', test_file_patterns: '*_test.rb' do

    watch(%r'^lib/blah/(.+)\.rb$') {|m| "test/unit/#{m[1]}_test.rb"}


group :spec do
  guard 'rspec', binstubs: true, spec_paths: ['test/spec'], all_on_start: false, all_after_pass: false do

    watch(%r'^lib/blah/(.+)\.rb$') {|m| "test/spec/#{m[1]}_spec.rb"}


Yeah, it's a known issue.
We could memorize if the screen has been already clean per run, and skip a second screen clean.

@thibaudgg thibaudgg was assigned

Sounds like a plan. Maybe it'd help to have the clear-screen code could be in it's own class that then gets passed around to anyone interested, that would make it easy for it to maintain its own state. Just an idea :)


Yeah good idea, I'll try to have a look at that this week-end. Thanks!


No worries mate! If there's anything you'd like me to help with just give me a shout ;)


Committed on this PR (#318) could you give it a try please.


Just tested it out, I couldn't reproduce the problem, works perfectly! Nice work mate!!


Thanks, Guard 1.3.2 has been released with this fix!

@thibaudgg thibaudgg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.