Skip to content

Commit

Permalink
Remove .puts (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexB52 committed Dec 1, 2024
1 parent 21d1a3d commit e01d2a9
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
26 changes: 13 additions & 13 deletions exe/retest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'retest'
$stdout.sync = true
listen_rd, listen_wr = IO.pipe
Signal.trap(:INT) do
$stdout.puts "Goodbye"
puts "Goodbye"
listen_rd.close
listen_wr.close
exit
Expand All @@ -14,12 +14,12 @@ end
options = Retest::Options.new(ARGV)

if options.help?
$stdout.puts options.help
puts options.help
return
end

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

Expand All @@ -28,13 +28,7 @@ repository = Retest::Repository.new(files: Retest::VersionControl.files, prompt:
command = Retest::Command.for_options(options)
runner = Retest::Runner.new(command)
sounds = Retest::Sounds.for(options)
watcher = Retest::Watcher.for(options.watcher).tap do |tool|
if tool == Retest::Watcher::Watchexec
puts "Watcher: [WATCHEXEC]"
else Retest::Watcher::Default
puts "Watcher: [LISTEN]"
end
end
watcher = Retest::Watcher.for(options.watcher)

sounds.play(:start)
runner.add_observer(sounds)
Expand All @@ -50,25 +44,31 @@ if options.params[:diff]
return
end

if watcher == Retest::Watcher::Watchexec
puts "Watcher: [WATCHEXEC]"
else Retest::Watcher::Default
puts "Watcher: [LISTEN]"
end

launching_message = "Launching Retest..."
if options.force_polling?
launching_message = "Launching Retest with polling method..."
end

# Main action

$stdout.puts launching_message
puts launching_message
Retest.listen(options, listener: watcher) do |modified, added, removed|
begin
repository.sync(added: added, removed: removed)
runner.sync(added: added, removed: removed)

listen_wr.puts "file changed: #{(modified + added).first}"
rescue => e
$stdout.puts "Something went wrong: #{e.message}"
puts "Something went wrong: #{e.message}"
end
end
$stdout.puts "Ready to refactor! You can make file changes now"
puts "Ready to refactor! You can make file changes now"

def run_command(input:, program:)
program.clear_terminal
Expand Down
2 changes: 2 additions & 0 deletions features/hanami-app/retest/retest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_with_no_command

assert_match <<~OUTPUT, @output.read
Setup identified: [RAKE]. Using command: 'bundle exec rake test TEST=<test>'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT
Expand All @@ -81,6 +82,7 @@ def test_with_no_command_all

assert_match <<~OUTPUT, @output.read
Setup identified: [RAKE]. Using command: 'bundle exec rake test'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT
Expand Down
2 changes: 2 additions & 0 deletions features/rails-app/retest/retest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_with_no_command

assert_match <<~OUTPUT, @output.read
Setup identified: [RAILS]. Using command: 'bin/rails test <test>'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT
Expand All @@ -81,6 +82,7 @@ def test_with_no_command_all

assert_match <<~OUTPUT, @output.read
Setup identified: [RAILS]. Using command: 'bin/rails test'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT
Expand Down
2 changes: 2 additions & 0 deletions features/rspec-rails/retest/retest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_with_no_command

assert_match <<~OUTPUT, @output.read
Setup identified: [RSPEC]. Using command: 'bundle exec rspec <test>'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT
Expand All @@ -81,6 +82,7 @@ def test_with_no_command_all

assert_match <<~OUTPUT, @output.read
Setup identified: [RSPEC]. Using command: 'bundle exec rspec'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT
Expand Down
1 change: 1 addition & 0 deletions features/rspec-ruby/retest/retest_test/flags_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_with_no_command

assert_match <<~OUTPUT, @output.read
Setup identified: [RSPEC]. Using command: 'bundle exec rspec <test>'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT
Expand Down
1 change: 1 addition & 0 deletions features/ruby-app/retest/retest_test/flags_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_with_no_command

assert_match <<~OUTPUT, @output.read
Setup identified: [RUBY]. Using command: 'bundle exec ruby <test>'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT
Expand Down
1 change: 1 addition & 0 deletions features/ruby-bare/retest/scenarios/auto_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def test_start_retest

assert_match <<~OUTPUT, @output.read
Setup identified: [RUBY]. Using command: 'ruby <test>'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def test_start_retest
launch_retest(COMMAND)

assert_match <<~EXPECTED, @output.read
Watcher: [WATCHEXEC]
Setup identified: [RUBY]. Using command: 'bundle exec ruby <test>'
Watcher: [WATCHEXEC]
Launching Retest...
Ready to refactor! You can make file changes now
EXPECTED
Expand Down

0 comments on commit e01d2a9

Please sign in to comment.