diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6415277 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + pull_request: + +jobs: + test: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + ruby-version: + - '3.0' + - '3.1' + - '3.2' + - '3.3' + - '3.4' + + steps: + - uses: actions/checkout@v6 + - run: ./bin/setup-deps + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - run: bundle exec rake spec diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 189eb00..0000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -language: ruby -rvm: - - 2.3.4 - - 2.4.1 -sudo: false -cache: bundler - diff --git a/Gemfile b/Gemfile index 74dbfa4..cc0e68d 100644 --- a/Gemfile +++ b/Gemfile @@ -14,10 +14,8 @@ end group :test do gem 'rspec', ">=3.0" - gem 'wrong', path: "../wrong" - gem 'files', path: "../files" - # gem 'wrong', github: "alexch/wrong" - # gem 'files', github: "alexch/files" + gem 'wrong', path: "tmp/wrong" + gem 'files', path: "tmp/files" end gem 'wdm', '>= 0.1.0' if Gem.win_platform? diff --git a/bin/rerun b/bin/rerun index bd59059..0f77fb1 100755 --- a/bin/rerun +++ b/bin/rerun @@ -15,4 +15,8 @@ end exit if options.nil? or options[:cmd].nil? or options[:cmd].empty? -Rerun::Runner.keep_running(options[:cmd], options) +begin + Rerun::Runner.keep_running(options[:cmd], options) +rescue Rerun::ExitException + exit 0 +end diff --git a/bin/setup-deps b/bin/setup-deps new file mode 100755 index 0000000..0b759a3 --- /dev/null +++ b/bin/setup-deps @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +cd "$(dirname "$0")/.." + +mkdir -p tmp + +echo "at=info msg=\"checking out test dependencies\"" + +if [ -d "tmp/wrong" ]; then + echo "at=info msg=\"wrong already exists, pulling latest\"" + git -C tmp/wrong pull +else + echo "at=info msg=\"cloning wrong\"" + git clone https://github.com/alexch/wrong.git tmp/wrong + rm -f tmp/wrong/wrong-java.gemspec +fi + +if [ -d "tmp/files" ]; then + echo "at=info msg=\"files already exists, pulling latest\"" + git -C tmp/files pull +else + echo "at=info msg=\"cloning files\"" + git clone https://github.com/alexch/files.git tmp/files +fi + +echo "at=info msg=\"dependencies ready\"" diff --git a/geminstaller.yml b/geminstaller.yml deleted file mode 100644 index 4e8a211..0000000 --- a/geminstaller.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -gems: -- name: rspec - version: '>= 1.2.6' diff --git a/lib/rerun.rb b/lib/rerun.rb index 31eecfe..ae76aed 100644 --- a/lib/rerun.rb +++ b/lib/rerun.rb @@ -10,6 +10,8 @@ require "rerun/glob" module Rerun - + # Raised when the runner wants to exit cleanly. + # This allows tests to catch the exit instead of terminating the process. + class ExitException < StandardError; end end diff --git a/lib/rerun/runner.rb b/lib/rerun/runner.rb index 581d00c..342b4a5 100644 --- a/lib/rerun/runner.rb +++ b/lib/rerun/runner.rb @@ -160,7 +160,7 @@ def start say "Rerun (#{$PID}) running #{app_name} (#{@pid})" rescue => e puts "#{e.class}: #{e.message}" - exit + raise ExitException end status_thread = Process.detach(@pid) # so if the child exits, it dies @@ -235,7 +235,7 @@ def change_message(changes) def die #stop_keypress_thread # don't do this since we're probably *in* the keypress thread stop # stop the child process if it exists - exit 0 # todo: status code param + raise ExitException # todo: status code param end def join