retest 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/bin/test/bundler-app +3 -3
- data/bin/test/git-ruby +10 -3
- data/bin/test/hanami-app +13 -5
- data/bin/test/rails-app +10 -3
- data/bin/test/rspec-rails +10 -3
- data/bin/test/rspec-ruby +10 -3
- data/bin/test/ruby-app +10 -3
- data/bin/test/ruby-bare +10 -3
- data/exe/retest +16 -3
- data/lib/retest/command/base.rb +49 -12
- data/lib/retest/command/hardcoded.rb +14 -1
- data/lib/retest/command/rails.rb +5 -14
- data/lib/retest/command/rake.rb +16 -10
- data/lib/retest/command/rspec.rb +16 -10
- data/lib/retest/command/ruby.rb +14 -4
- data/lib/retest/command.rb +24 -32
- data/lib/retest/program.rb +1 -6
- data/lib/retest/runner.rb +8 -5
- data/lib/retest/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7eb4992f6d7149b443a2833f6481694b551fcf3ca98355acbe014f9209ed68c0
         | 
| 4 | 
            +
              data.tar.gz: f1c50bb7340803ae2abc65178c204b983fe0a99471ac502ad0726d94d7219638
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 69b59be1bf2c414d66fa9b80eb656e430d32ede6fd88734169096d7b0b7c1f64d48edfcceabc4b48676a5dcf36cf307379926030b75e6fffa95525a504c9e279
         | 
| 7 | 
            +
              data.tar.gz: c063a98b171140f21e66567a2c37d1014f8a3aed5c85f935e6a2e99f8d0845db84c046ccd47f7e739cc115e894111afc07d08b3564f02bdce09698c1a6674f03
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -48,8 +48,10 @@ retest --diff origin/main                           # Test changes from a branch | |
| 48 48 | 
             
            Stay in control with an interactive shell for test management. Start Retest and enter `h` to explore available commands.  
         | 
| 49 49 |  | 
| 50 50 | 
             
            ```
         | 
| 51 | 
            -
            Setup | 
| 51 | 
            +
            Setup: [RAKE]
         | 
| 52 | 
            +
            Command: 'bundle exec rake test TEST=<test>'
         | 
| 52 53 | 
             
            Watcher: [WATCHEXEC]
         | 
| 54 | 
            +
             | 
| 53 55 | 
             
            Launching Retest...
         | 
| 54 56 | 
             
            Ready to refactor! You can make file changes now
         | 
| 55 57 |  | 
    
        data/bin/test/bundler-app
    CHANGED
    
    | @@ -4,10 +4,10 @@ FOLDER="features/bundler-app" | |
| 4 4 |  | 
| 5 5 | 
             
            bundle install
         | 
| 6 6 | 
             
            bundle exec rake build
         | 
| 7 | 
            -
            cp -R features/support  | 
| 8 | 
            -
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{}  | 
| 7 | 
            +
            cp -R features/support $FOLDER/retest
         | 
| 8 | 
            +
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{} $FOLDER/retest.gem
         | 
| 9 9 |  | 
| 10 | 
            -
            if [[ "$1" == "-- | 
| 10 | 
            +
            if [[ "$1" == "--nobuild" ]]; then
         | 
| 11 11 | 
             
            	docker compose -f "$FOLDER/docker-compose.yml" up --exit-code-from retest
         | 
| 12 12 | 
             
            else
         | 
| 13 13 | 
             
            	docker compose -f "$FOLDER/docker-compose.yml" up --build --exit-code-from retest
         | 
    
        data/bin/test/git-ruby
    CHANGED
    
    | @@ -1,7 +1,14 @@ | |
| 1 1 | 
             
            #!/usr/bin/env bash
         | 
| 2 2 |  | 
| 3 | 
            +
            FOLDER="features/git-ruby"
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            bundle install
         | 
| 4 6 | 
             
            bundle exec rake build
         | 
| 5 | 
            -
            cp -R features/support  | 
| 6 | 
            -
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{}  | 
| 7 | 
            -
             | 
| 7 | 
            +
            cp -R features/support $FOLDER/retest
         | 
| 8 | 
            +
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{} $FOLDER/retest.gem
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            if [[ "$1" == "--nobuild" ]]; then
         | 
| 11 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --exit-code-from retest
         | 
| 12 | 
            +
            else
         | 
| 13 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --build --exit-code-from retest
         | 
| 14 | 
            +
            fi
         | 
    
        data/bin/test/hanami-app
    CHANGED
    
    | @@ -1,9 +1,17 @@ | |
| 1 1 | 
             
            #!/usr/bin/env bash
         | 
| 2 2 |  | 
| 3 | 
            +
            FOLDER="features/hanami-app"
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            bundle install
         | 
| 4 6 | 
             
            bundle exec rake build
         | 
| 5 | 
            -
            cp -R features/support  | 
| 6 | 
            -
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{}  | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
            docker compose -f  | 
| 7 | 
            +
            cp -R features/support $FOLDER/retest
         | 
| 8 | 
            +
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{} $FOLDER/retest.gem
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            if [[ "$1" == "--nobuild" ]]; then
         | 
| 11 | 
            +
              docker compose -f $FOLDER/docker-compose.yml run retest sh bin/test_setup
         | 
| 12 | 
            +
              docker compose -f $FOLDER/docker-compose.yml up --exit-code-from retest
         | 
| 13 | 
            +
            else
         | 
| 14 | 
            +
              docker compose -f $FOLDER/docker-compose.yml build
         | 
| 15 | 
            +
              docker compose -f $FOLDER/docker-compose.yml run retest sh bin/test_setup
         | 
| 16 | 
            +
              docker compose -f $FOLDER/docker-compose.yml up --exit-code-from retest
         | 
| 17 | 
            +
            fi
         | 
    
        data/bin/test/rails-app
    CHANGED
    
    | @@ -1,7 +1,14 @@ | |
| 1 1 | 
             
            #!/usr/bin/env bash
         | 
| 2 2 |  | 
| 3 | 
            +
            FOLDER="features/rails-app"
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            bundle install
         | 
| 4 6 | 
             
            bundle exec rake build
         | 
| 5 | 
            -
            cp -R features/support  | 
| 6 | 
            -
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{}  | 
| 7 | 
            -
             | 
| 7 | 
            +
            cp -R features/support $FOLDER/retest
         | 
| 8 | 
            +
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{} $FOLDER/retest.gem
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            if [[ "$1" == "--nobuild" ]]; then
         | 
| 11 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --exit-code-from retest
         | 
| 12 | 
            +
            else
         | 
| 13 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --build --exit-code-from retest
         | 
| 14 | 
            +
            fi
         | 
    
        data/bin/test/rspec-rails
    CHANGED
    
    | @@ -1,7 +1,14 @@ | |
| 1 1 | 
             
            #!/usr/bin/env bash
         | 
| 2 2 |  | 
| 3 | 
            +
            FOLDER="features/rspec-rails"
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            bundle install
         | 
| 4 6 | 
             
            bundle exec rake build
         | 
| 5 | 
            -
            cp -R features/support  | 
| 6 | 
            -
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{}  | 
| 7 | 
            -
             | 
| 7 | 
            +
            cp -R features/support $FOLDER/retest
         | 
| 8 | 
            +
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{} $FOLDER/retest.gem
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            if [[ "$1" == "--nobuild" ]]; then
         | 
| 11 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --exit-code-from retest
         | 
| 12 | 
            +
            else
         | 
| 13 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --build --exit-code-from retest
         | 
| 14 | 
            +
            fi
         | 
    
        data/bin/test/rspec-ruby
    CHANGED
    
    | @@ -1,7 +1,14 @@ | |
| 1 1 | 
             
            #!/usr/bin/env bash
         | 
| 2 2 |  | 
| 3 | 
            +
            FOLDER="features/rspec-ruby"
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            bundle install
         | 
| 4 6 | 
             
            bundle exec rake build
         | 
| 5 | 
            -
            cp -R features/support  | 
| 6 | 
            -
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{}  | 
| 7 | 
            -
             | 
| 7 | 
            +
            cp -R features/support $FOLDER/retest
         | 
| 8 | 
            +
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{} $FOLDER/retest.gem
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            if [[ "$1" == "--nobuild" ]]; then
         | 
| 11 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --exit-code-from retest
         | 
| 12 | 
            +
            else
         | 
| 13 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --build --exit-code-from retest
         | 
| 14 | 
            +
            fi
         | 
    
        data/bin/test/ruby-app
    CHANGED
    
    | @@ -1,7 +1,14 @@ | |
| 1 1 | 
             
            #!/usr/bin/env bash
         | 
| 2 2 |  | 
| 3 | 
            +
            FOLDER="features/ruby-app"
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            bundle install
         | 
| 4 6 | 
             
            bundle exec rake build
         | 
| 5 | 
            -
            cp -R features/support  | 
| 6 | 
            -
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{}  | 
| 7 | 
            -
             | 
| 7 | 
            +
            cp -R features/support $FOLDER/retest
         | 
| 8 | 
            +
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{} $FOLDER/retest.gem
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            if [[ "$1" == "--nobuild" ]]; then
         | 
| 11 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --exit-code-from retest
         | 
| 12 | 
            +
            else
         | 
| 13 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --build --exit-code-from retest
         | 
| 14 | 
            +
            fi
         | 
    
        data/bin/test/ruby-bare
    CHANGED
    
    | @@ -1,7 +1,14 @@ | |
| 1 1 | 
             
            #!/usr/bin/env bash
         | 
| 2 2 |  | 
| 3 | 
            +
            FOLDER="features/ruby-bare"
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            bundle install
         | 
| 4 6 | 
             
            bundle exec rake build
         | 
| 5 | 
            -
            cp -R features/support  | 
| 6 | 
            -
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{}  | 
| 7 | 
            -
             | 
| 7 | 
            +
            cp -R features/support $FOLDER/retest
         | 
| 8 | 
            +
            ls -t pkg | head -n1 | xargs -I {} mv pkg/{} $FOLDER/retest.gem
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            if [[ "$1" == "--nobuild" ]]; then
         | 
| 11 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --exit-code-from retest
         | 
| 12 | 
            +
            else
         | 
| 13 | 
            +
              docker compose -f "$FOLDER/docker-compose.yml" up --build --exit-code-from retest
         | 
| 14 | 
            +
            fi
         | 
    
        data/exe/retest
    CHANGED
    
    | @@ -39,25 +39,38 @@ program = Retest::Program.new( | |
| 39 39 | 
             
              runner: runner
         | 
| 40 40 | 
             
            )
         | 
| 41 41 |  | 
| 42 | 
            +
            # === LOGGING ===
         | 
| 43 | 
            +
            case command
         | 
| 44 | 
            +
            when Retest::Command::Rails then puts "Setup: [RAILS]"
         | 
| 45 | 
            +
            when Retest::Command::Rspec then puts "Setup: [RSPEC]"
         | 
| 46 | 
            +
            when Retest::Command::Rake  then puts "Setup: [RAKE]"
         | 
| 47 | 
            +
            when Retest::Command::Ruby  then puts "Setup: [RUBY]"
         | 
| 48 | 
            +
            else                             puts "Setup: [UNKNOWN]"
         | 
| 49 | 
            +
            end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            puts "Command: '#{command}'"
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            # === DIFF ACTION ===
         | 
| 42 54 | 
             
            if options.params[:diff]
         | 
| 43 55 | 
             
              program.diff(options.params[:diff])
         | 
| 44 56 | 
             
              return
         | 
| 45 57 | 
             
            end
         | 
| 46 58 |  | 
| 59 | 
            +
            # === LOGGING ===
         | 
| 47 60 | 
             
            if watcher == Retest::Watcher::Watchexec
         | 
| 48 61 | 
             
              puts "Watcher: [WATCHEXEC]"
         | 
| 49 62 | 
             
            else
         | 
| 50 63 | 
             
              puts "Watcher: [LISTEN]"
         | 
| 51 64 | 
             
            end
         | 
| 52 65 |  | 
| 53 | 
            -
            launching_message = " | 
| 66 | 
            +
            launching_message = "\nLaunching Retest..."
         | 
| 54 67 | 
             
            if options.force_polling?
         | 
| 55 68 | 
             
              launching_message = "Launching Retest with polling method..."
         | 
| 56 69 | 
             
            end
         | 
| 57 70 |  | 
| 58 | 
            -
            # Main action
         | 
| 59 | 
            -
             | 
| 60 71 | 
             
            puts launching_message
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            # === MAIN ACTION ===
         | 
| 61 74 | 
             
            Retest.listen(options, listener: watcher) do |modified, added, removed|
         | 
| 62 75 | 
             
              begin
         | 
| 63 76 | 
             
                repository.sync(added: added, removed: removed)
         | 
    
        data/lib/retest/command/base.rb
    CHANGED
    
    | @@ -1,16 +1,35 @@ | |
| 1 1 | 
             
            module Retest
         | 
| 2 2 | 
             
              class Command
         | 
| 3 3 | 
             
                class MultipleTestsNotSupported < StandardError; end
         | 
| 4 | 
            +
                class AllTestsNotSupported < StandardError; end
         | 
| 4 5 |  | 
| 5 6 | 
             
                class Base
         | 
| 7 | 
            +
                  attr_reader :file_system, :command
         | 
| 8 | 
            +
             | 
| 6 9 | 
             
                  def initialize(all: false, file_system: FileSystem, command: nil)
         | 
| 7 10 | 
             
                    @file_system = file_system
         | 
| 8 | 
            -
                    @ | 
| 9 | 
            -
                    @command = command
         | 
| 11 | 
            +
                    @command = command || default_command(all: all)
         | 
| 10 12 | 
             
                  end
         | 
| 11 13 |  | 
| 12 | 
            -
                  def  | 
| 13 | 
            -
                     | 
| 14 | 
            +
                  def to_s
         | 
| 15 | 
            +
                    all ? all_command : batched_command
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  def eql?(other)
         | 
| 19 | 
            +
                    hash == other.hash
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                  alias == eql?
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def hash
         | 
| 24 | 
            +
                    [self.class, file_system, command].hash
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  def switch_to(type)
         | 
| 28 | 
            +
                    case type.to_s
         | 
| 29 | 
            +
                    when 'all'     then clone(command: all_command)
         | 
| 30 | 
            +
                    when 'batched' then clone(command: batched_command)
         | 
| 31 | 
            +
                    else raise ArgumentError, "unknown type to switch to: #{type}"
         | 
| 32 | 
            +
                    end
         | 
| 14 33 | 
             
                  end
         | 
| 15 34 |  | 
| 16 35 | 
             
                  def hardcoded?
         | 
| @@ -18,24 +37,42 @@ module Retest | |
| 18 37 | 
             
                  end
         | 
| 19 38 |  | 
| 20 39 | 
             
                  def has_changed?
         | 
| 21 | 
            -
                     | 
| 40 | 
            +
                    command.include?('<changed>')
         | 
| 22 41 | 
             
                  end
         | 
| 23 42 |  | 
| 24 43 | 
             
                  def has_test?
         | 
| 25 | 
            -
                     | 
| 26 | 
            -
                  end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                  def to_s
         | 
| 29 | 
            -
                    @command
         | 
| 44 | 
            +
                    command.include?('<test>')
         | 
| 30 45 | 
             
                  end
         | 
| 31 46 |  | 
| 32 47 | 
             
                  def format_batch(*files)
         | 
| 33 | 
            -
                     | 
| 48 | 
            +
                    raise_multiple_test_not_supported
         | 
| 34 49 | 
             
                  end
         | 
| 35 50 |  | 
| 36 51 | 
             
                  private
         | 
| 37 52 |  | 
| 38 | 
            -
                   | 
| 53 | 
            +
                  def all
         | 
| 54 | 
            +
                    !has_test?
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  def batched_command
         | 
| 58 | 
            +
                    raise NotImplementedError, 'must define a BATCHED command'
         | 
| 59 | 
            +
                  end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                  def all_command
         | 
| 62 | 
            +
                    raise NotImplementedError, 'must define a ALL command'
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  def default_command(all: false)
         | 
| 66 | 
            +
                    raise NotImplementedError, 'must define a DEFAULT command'
         | 
| 67 | 
            +
                  end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  def clone(params = {})
         | 
| 70 | 
            +
                    self.class.new(**{ all: all, file_system: file_system, command: command }.merge(params))
         | 
| 71 | 
            +
                  end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  def raise_multiple_test_not_supported
         | 
| 74 | 
            +
                    raise MultipleTestsNotSupported, "Multiple test files run not supported for command: '#{to_s}'"
         | 
| 75 | 
            +
                  end
         | 
| 39 76 | 
             
                end
         | 
| 40 77 | 
             
              end
         | 
| 41 78 | 
             
            end
         | 
    
        data/lib/retest/command/rails.rb
    CHANGED
    
    | @@ -1,26 +1,17 @@ | |
| 1 1 | 
             
            module Retest
         | 
| 2 2 | 
             
              class Command
         | 
| 3 | 
            -
                class Rails <  | 
| 4 | 
            -
                  def to_s
         | 
| 5 | 
            -
                    if all
         | 
| 6 | 
            -
                      root_command
         | 
| 7 | 
            -
                    else
         | 
| 8 | 
            -
                      "#{root_command} <test>"
         | 
| 9 | 
            -
                    end
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  def format_batch(*files)
         | 
| 13 | 
            -
                    files.join(' ')
         | 
| 14 | 
            -
                  end
         | 
| 3 | 
            +
                class Rails < Rspec
         | 
| 15 4 |  | 
| 16 5 | 
             
                  private
         | 
| 17 6 |  | 
| 18 | 
            -
                  def  | 
| 19 | 
            -
                    if file_system | 
| 7 | 
            +
                  def default_command(all:)
         | 
| 8 | 
            +
                    command = if file_system&.exist? 'bin/rails'
         | 
| 20 9 | 
             
                      'bin/rails test'
         | 
| 21 10 | 
             
                    else
         | 
| 22 11 | 
             
                      'bundle exec rails test'
         | 
| 23 12 | 
             
                    end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    all ? command : "#{command} <test>"
         | 
| 24 15 | 
             
                  end
         | 
| 25 16 | 
             
                end
         | 
| 26 17 | 
             
              end
         | 
    
        data/lib/retest/command/rake.rb
    CHANGED
    
    | @@ -1,26 +1,32 @@ | |
| 1 1 | 
             
            module Retest
         | 
| 2 2 | 
             
              class Command
         | 
| 3 3 | 
             
                class Rake < Base
         | 
| 4 | 
            -
                  def to_s
         | 
| 5 | 
            -
                    if all
         | 
| 6 | 
            -
                      root_command
         | 
| 7 | 
            -
                    else
         | 
| 8 | 
            -
                      "#{root_command} TEST=<test>"
         | 
| 9 | 
            -
                    end
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
             | 
| 12 4 | 
             
                  def format_batch(*files)
         | 
| 13 5 | 
             
                    files.size > 1 ? %Q{"{#{files.join(',')}}"} : files.first
         | 
| 14 6 | 
             
                  end
         | 
| 15 7 |  | 
| 16 8 | 
             
                  private
         | 
| 17 9 |  | 
| 18 | 
            -
                  def  | 
| 19 | 
            -
                    if file_system | 
| 10 | 
            +
                  def default_command(all: false)
         | 
| 11 | 
            +
                    command = if file_system&.exist? 'bin/rake'
         | 
| 20 12 | 
             
                      'bin/rake test'
         | 
| 21 13 | 
             
                    else
         | 
| 22 14 | 
             
                      'bundle exec rake test'
         | 
| 23 15 | 
             
                    end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                    all ? command : "#{command} TEST=<test>"
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def all_command
         | 
| 21 | 
            +
                    return command if all
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    command.gsub('TEST=<test>', '').strip
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  def batched_command
         | 
| 27 | 
            +
                    return command unless all
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    "#{command} TEST=<test>"
         | 
| 24 30 | 
             
                  end
         | 
| 25 31 | 
             
                end
         | 
| 26 32 | 
             
              end
         | 
    
        data/lib/retest/command/rspec.rb
    CHANGED
    
    | @@ -1,26 +1,32 @@ | |
| 1 1 | 
             
            module Retest
         | 
| 2 2 | 
             
              class Command
         | 
| 3 3 | 
             
                class Rspec < Base
         | 
| 4 | 
            -
                  def to_s
         | 
| 5 | 
            -
                    if all
         | 
| 6 | 
            -
                      root_command
         | 
| 7 | 
            -
                    else
         | 
| 8 | 
            -
                      "#{root_command} <test>"
         | 
| 9 | 
            -
                    end
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
             | 
| 12 4 | 
             
                  def format_batch(*files)
         | 
| 13 5 | 
             
                    files.join(' ')
         | 
| 14 6 | 
             
                  end
         | 
| 15 7 |  | 
| 16 8 | 
             
                  private
         | 
| 17 9 |  | 
| 18 | 
            -
                  def  | 
| 19 | 
            -
                    if  | 
| 10 | 
            +
                  def all_command
         | 
| 11 | 
            +
                    return command if all
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                    command.gsub('<test>', '').strip
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def batched_command
         | 
| 17 | 
            +
                    return command unless all
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    "#{command} <test>"
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def default_command(all:)
         | 
| 23 | 
            +
                    command = if file_system&.exist? 'bin/rspec'
         | 
| 20 24 | 
             
                      'bin/rspec'
         | 
| 21 25 | 
             
                    else
         | 
| 22 26 | 
             
                      'bundle exec rspec'
         | 
| 23 27 | 
             
                    end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    all ? command : "#{command} <test>"
         | 
| 24 30 | 
             
                  end
         | 
| 25 31 | 
             
                end
         | 
| 26 32 | 
             
              end
         | 
    
        data/lib/retest/command/ruby.rb
    CHANGED
    
    | @@ -1,16 +1,26 @@ | |
| 1 1 | 
             
            module Retest
         | 
| 2 2 | 
             
              class Command
         | 
| 3 3 | 
             
                class Ruby < Base
         | 
| 4 | 
            -
                  def  | 
| 5 | 
            -
                     | 
| 4 | 
            +
                  def format_batch(*files)
         | 
| 5 | 
            +
                    files.size > 1 ? %Q{-e "#{files.map { |file| "require './#{file}';" }.join}"} : files.first
         | 
| 6 | 
            +
                  end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  private
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def default_command(all: false)
         | 
| 11 | 
            +
                    if file_system&.exist? 'Gemfile.lock'
         | 
| 6 12 | 
             
                      'bundle exec ruby <test>'
         | 
| 7 13 | 
             
                    else
         | 
| 8 14 | 
             
                      'ruby <test>'
         | 
| 9 15 | 
             
                    end
         | 
| 10 16 | 
             
                  end
         | 
| 11 17 |  | 
| 12 | 
            -
                  def  | 
| 13 | 
            -
                     | 
| 18 | 
            +
                  def all_command
         | 
| 19 | 
            +
                    raise AllTestsNotSupported, "All tests run not supported for Ruby command: '#{to_s}'"
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def batched_command
         | 
| 23 | 
            +
                    command
         | 
| 14 24 | 
             
                  end
         | 
| 15 25 | 
             
                end
         | 
| 16 26 | 
             
              end
         | 
    
        data/lib/retest/command.rb
    CHANGED
    
    | @@ -1,50 +1,46 @@ | |
| 1 1 | 
             
            require_relative 'command/base'
         | 
| 2 2 | 
             
            require_relative 'command/hardcoded'
         | 
| 3 | 
            +
            require_relative 'command/rspec'
         | 
| 3 4 | 
             
            require_relative 'command/rails'
         | 
| 4 5 | 
             
            require_relative 'command/rake'
         | 
| 5 | 
            -
            require_relative 'command/rspec'
         | 
| 6 6 | 
             
            require_relative 'command/ruby'
         | 
| 7 7 |  | 
| 8 8 | 
             
            module Retest
         | 
| 9 9 | 
             
              class Command
         | 
| 10 10 | 
             
                extend Forwardable
         | 
| 11 11 |  | 
| 12 | 
            -
                def self.for_options(options | 
| 13 | 
            -
                  new(options: options | 
| 12 | 
            +
                def self.for_options(options)
         | 
| 13 | 
            +
                  new(options: options).command
         | 
| 14 14 | 
             
                end
         | 
| 15 15 |  | 
| 16 | 
            -
                def_delegator :setup, :type
         | 
| 17 16 | 
             
                def_delegators :options, :params, :full_suite?, :auto?
         | 
| 18 17 |  | 
| 19 | 
            -
                attr_accessor :options, :setup
         | 
| 20 | 
            -
                def initialize(options: Options.new, setup: Setup.new | 
| 18 | 
            +
                attr_accessor :options, :setup, :setup_identified
         | 
| 19 | 
            +
                def initialize(options: Options.new, setup: Setup.new)
         | 
| 21 20 | 
             
                  @options = options
         | 
| 22 21 | 
             
                  @setup = setup
         | 
| 23 | 
            -
                  @ | 
| 22 | 
            +
                  @setup_identified = nil
         | 
| 24 23 | 
             
                end
         | 
| 25 24 |  | 
| 26 25 | 
             
                def command
         | 
| 27 | 
            -
                  options_command ||  | 
| 26 | 
            +
                  options_command || setup_command
         | 
| 28 27 | 
             
                end
         | 
| 29 28 |  | 
| 30 29 | 
             
                private
         | 
| 31 30 |  | 
| 32 31 | 
             
                def options_command
         | 
| 33 | 
            -
                   | 
| 34 | 
            -
                  elsif params[:rspec]   then rspec_command
         | 
| 35 | 
            -
                  elsif params[:rails]   then rails_command
         | 
| 36 | 
            -
                  elsif params[:ruby]    then ruby_command
         | 
| 37 | 
            -
                  elsif params[:rake]    then rake_command
         | 
| 38 | 
            -
                  end
         | 
| 39 | 
            -
                end
         | 
| 32 | 
            +
                  command_input = params[:command]
         | 
| 40 33 |  | 
| 41 | 
            -
                 | 
| 42 | 
            -
                   | 
| 43 | 
            -
                   | 
| 34 | 
            +
                  if    params[:rspec] then rspec_command(command: command_input)
         | 
| 35 | 
            +
                  elsif params[:rails] then rails_command(command: command_input)
         | 
| 36 | 
            +
                  elsif params[:ruby]  then ruby_command(command: command_input)
         | 
| 37 | 
            +
                  elsif params[:rake]  then rake_command(command: command_input)
         | 
| 38 | 
            +
                  elsif command_input  then hardcoded_command(command: command_input)
         | 
| 39 | 
            +
                  end
         | 
| 44 40 | 
             
                end
         | 
| 45 41 |  | 
| 46 42 | 
             
                def setup_command
         | 
| 47 | 
            -
                  case type
         | 
| 43 | 
            +
                  case setup.type
         | 
| 48 44 | 
             
                  when :rake  then rake_command
         | 
| 49 45 | 
             
                  when :rspec then rspec_command
         | 
| 50 46 | 
             
                  when :rails then rails_command
         | 
| @@ -53,28 +49,24 @@ module Retest | |
| 53 49 | 
             
                  end
         | 
| 54 50 | 
             
                end
         | 
| 55 51 |  | 
| 56 | 
            -
                def  | 
| 57 | 
            -
                  @stdout&.puts(message)
         | 
| 58 | 
            -
                end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                def hardcoded_command(command)
         | 
| 52 | 
            +
                def hardcoded_command(command:)
         | 
| 61 53 | 
             
                  Hardcoded.new(command: command)
         | 
| 62 54 | 
             
                end
         | 
| 63 55 |  | 
| 64 | 
            -
                def rspec_command
         | 
| 65 | 
            -
                  Rspec.new(all: full_suite | 
| 56 | 
            +
                def rspec_command(command: nil)
         | 
| 57 | 
            +
                  Rspec.new(all: full_suite?, command: command)
         | 
| 66 58 | 
             
                end
         | 
| 67 59 |  | 
| 68 | 
            -
                def rails_command
         | 
| 69 | 
            -
                  Rails.new(all: full_suite | 
| 60 | 
            +
                def rails_command(command: nil)
         | 
| 61 | 
            +
                  Rails.new(all: full_suite?, command: command)
         | 
| 70 62 | 
             
                end
         | 
| 71 63 |  | 
| 72 | 
            -
                def rake_command
         | 
| 73 | 
            -
                  Rake.new(all: full_suite | 
| 64 | 
            +
                def rake_command(command: nil)
         | 
| 65 | 
            +
                  Rake.new(all: full_suite?, command: command)
         | 
| 74 66 | 
             
                end
         | 
| 75 67 |  | 
| 76 | 
            -
                def ruby_command
         | 
| 77 | 
            -
                  Ruby.new(all: full_suite | 
| 68 | 
            +
                def ruby_command(command: nil)
         | 
| 69 | 
            +
                  Ruby.new(all: full_suite?, command: command)
         | 
| 78 70 | 
             
                end
         | 
| 79 71 | 
             
              end
         | 
| 80 72 | 
             
            end
         | 
    
        data/lib/retest/program.rb
    CHANGED
    
    | @@ -30,7 +30,6 @@ module Retest | |
| 30 30 | 
             
                    @stdout.puts <<~HINT
         | 
| 31 31 | 
             
                      Forced selection enabled.
         | 
| 32 32 | 
             
                      Reset to default settings by typing 'r' in the interactive console.
         | 
| 33 | 
            -
             | 
| 34 33 | 
             
                    HINT
         | 
| 35 34 |  | 
| 36 35 | 
             
                    runner.run(test_files: selected_test_files)
         | 
| @@ -48,17 +47,13 @@ module Retest | |
| 48 47 | 
             
                  raise "Git not installed" unless VersionControl::Git.installed?
         | 
| 49 48 |  | 
| 50 49 | 
             
                  test_files = repository.find_tests VersionControl::Git.diff_files(branch)
         | 
| 51 | 
            -
                   | 
| 50 | 
            +
                  runner.run(test_files: test_files)
         | 
| 52 51 | 
             
                end
         | 
| 53 52 |  | 
| 54 53 | 
             
                def run_all
         | 
| 55 54 | 
             
                  runner.run_all
         | 
| 56 55 | 
             
                end
         | 
| 57 56 |  | 
| 58 | 
            -
                def run_selected(test_files)
         | 
| 59 | 
            -
                  runner.run(test_files: test_files)
         | 
| 60 | 
            -
                end
         | 
| 61 | 
            -
             | 
| 62 57 | 
             
                def clear_terminal
         | 
| 63 58 | 
             
                  system('clear 2>/dev/null') || system('cls 2>/dev/null')
         | 
| 64 59 | 
             
                end
         | 
    
        data/lib/retest/runner.rb
    CHANGED
    
    | @@ -35,17 +35,20 @@ module Retest | |
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| 37 37 | 
             
                def run_all
         | 
| 38 | 
            -
                  self.last_command = command. | 
| 38 | 
            +
                  self.last_command = command.switch_to(:all).to_s
         | 
| 39 39 | 
             
                  run_last_command
         | 
| 40 | 
            +
                rescue Command::AllTestsNotSupported => e
         | 
| 41 | 
            +
                  log("Command::AllTestsNotSupported - #{e.message}")
         | 
| 40 42 | 
             
                end
         | 
| 41 43 |  | 
| 42 44 | 
             
                def format_instruction(changed_files: [], test_files: [])
         | 
| 43 45 | 
             
                  if changed_files.empty? && test_files.size >= 1
         | 
| 44 | 
            -
                     | 
| 45 | 
            -
             | 
| 46 | 
            -
                    log(" | 
| 46 | 
            +
                    new_command = command.switch_to(:batched)
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    log("\nTests selected:")
         | 
| 47 49 | 
             
                    test_files.each { |test_file| log("  - #{test_file}") }
         | 
| 48 | 
            -
             | 
| 50 | 
            +
             | 
| 51 | 
            +
                    return new_command.to_s.gsub('<test>', new_command.format_batch(*test_files))
         | 
| 49 52 | 
             
                  end
         | 
| 50 53 |  | 
| 51 54 | 
             
                  instruction = command.to_s
         | 
    
        data/lib/retest/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: retest
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.0 | 
| 4 | 
            +
              version: 2.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Alexandre Barret
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2025-01- | 
| 11 | 
            +
            date: 2025-01-27 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: string-similarity
         | 
| @@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 160 160 | 
             
                - !ruby/object:Gem::Version
         | 
| 161 161 | 
             
                  version: '0'
         | 
| 162 162 | 
             
            requirements: []
         | 
| 163 | 
            -
            rubygems_version: 3.1 | 
| 163 | 
            +
            rubygems_version: 3.0.3.1
         | 
| 164 164 | 
             
            signing_key:
         | 
| 165 165 | 
             
            specification_version: 4
         | 
| 166 166 | 
             
            summary: A simple command line tool to watch file change and run its matching spec.
         |