Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
japgolly opened this Issue · 8 comments

2 participants

@japgolly

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.

@japgolly

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"}
    watch(%r'^test/unit/.+_test\.rb$')

  end
end

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"}
    watch(%r'^test/spec/.+_spec\.rb$')

  end
end
@thibaudgg
Owner

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
@japgolly

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 :)

@thibaudgg
Owner

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

@japgolly

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

@thibaudgg
Owner

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

@japgolly

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

@thibaudgg
Owner

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.