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

Launching test at specific line #154

Open
alain-andre opened this issue Apr 5, 2018 · 0 comments
Open

Launching test at specific line #154

alain-andre opened this issue Apr 5, 2018 · 0 comments

Comments

@alain-andre
Copy link

I have created a class returning the file and the first changed line based on git. I want to launch the test of the file at only this line.

class GitModifiedMatcher
  class MyMatchData
    def initialize(result)
      @result = result
    end

    def to_a
      @result.values
    end

    def [](name)
      @result[name]
    end
  end

  def match(file)
    diff = `git diff --no-ext-diff --unified=0 --exit-code -a --no-prefix #{file}`
    modified_lines = diff.to_enum(:scan, /^@@ -\d+,?.* [+](\d+),?.* @@.*/).map { Regexp.last_match(1) }

    MyMatchData.new(file: file, lines: modified_lines.first)
  end
end

So in my Guardfile I am able to do something like this (notice the m[:file] and m[:line]) :

guard :minitest, all_on_start: false do
  watch(GitModifiedMatcher.new) { |m| "#{m[:file]} --line #{m[:line]}" }
end

I could not find a way to make it. Anyone can help ?

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

No branches or pull requests

1 participant