Skip to content

Commit

Permalink
Add version option
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexB52 committed Dec 5, 2023
1 parent fc00f5f commit a89c32d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions exe/retest
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ if options.help?
return
end

if options.version?
$stdout.puts Retest::VERSION
return
end

prompt = Retest::Prompt.new
repository = Retest::Repository.new(files: Retest::VersionControl.files, prompt: prompt)
command = Retest::Command.for_options(options)
Expand Down
13 changes: 13 additions & 0 deletions features/ruby-bare/retest/flags/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class TestVersionFlag < Minitest::Test
def test_version
@output, @pid = launch_retest 'retest --version'

assert_match /^1\.\d+\.\d+/, @output.read
end

def test_version_short_flag
@output, @pid = launch_retest 'retest -v'

assert_match /^1\.\d+\.\d+/, @output.read
end
end
1 change: 1 addition & 0 deletions features/ruby-bare/retest/retest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require_relative 'scenarios/interruptions.rb'

require_relative 'flags/help.rb'
require_relative 'flags/version.rb'

$stdout.sync = true

Expand Down
10 changes: 10 additions & 0 deletions lib/retest/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ class Options
desc "Print usage"
end

flag :version do
short "-v"
long "--version"
desc "Print retest version"
end

option :polling do
long '--polling'
desc <<~DESC.strip
Expand Down Expand Up @@ -133,6 +139,10 @@ def help?
params[:help]
end

def version?
params[:version]
end

def full_suite?
params[:all]
end
Expand Down
1 change: 1 addition & 0 deletions test/retest/options/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Options:
--rake Shortcut for a standard Rake setup
--rspec Shortcut for a standard RSpec setup
--ruby Shortcut for a Ruby project
-v, --version Print retest version

Examples:
Runs a matching rails test after a file change
Expand Down
11 changes: 11 additions & 0 deletions test/retest/options_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ def test_help_text
assert_equal File.read('test/retest/options/help.txt'), @subject.help
end

def test_version?
@subject.args = ["--version"]
assert @subject.version?

@subject.args = ["-v"]
assert @subject.version?

@subject.args = ["-h"]
refute @subject.version?
end

def test_notify?
refute @subject.notify?
@subject.args = ["--notify"]
Expand Down

0 comments on commit a89c32d

Please sign in to comment.