From 082216303900ab26971faf6ff82e6531127f1992 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 4 Jan 2024 08:09:38 +1300 Subject: [PATCH] Don't use `test-queue` to run tests on JRuby or Windows because they don't support `fork` --- .github/workflows/test.yml | 2 -- Rakefile | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ac40b26..62c95cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,8 +50,6 @@ jobs: bundler-cache: true - name: test run: bundle exec rake test - env: - ERROR_ON_TEST_FAILURE: "false" - name: internal_investigation run: bundle exec rake internal_investigation diff --git a/Rakefile b/Rakefile index c09b8e2..e85f4a3 100644 --- a/Rakefile +++ b/Rakefile @@ -19,11 +19,20 @@ require 'rubocop/rake_task' require 'rake/testtask' require_relative 'lib/rubocop/cop/generator' -desc 'Run tests' -task :test do - error_on_failure = ENV.fetch('ERROR_ON_TEST_FAILURE', 'true') != 'false' +# JRuby and Windows don't support fork, so we can't use minitest-queue. +if RUBY_ENGINE == 'jruby' || RuboCop::Platform.windows? + Rake::TestTask.new do |t| + t.libs << 'test' + t.libs << 'lib' + t.test_files = FileList['test/**/*_test.rb'] + end +else + desc 'Run tests' + task :test do + error_on_failure = ENV.fetch('ERROR_ON_TEST_FAILURE', 'true') != 'false' - system("bundle exec minitest-queue #{Dir.glob('test/**/*_test.rb').shelljoin}", exception: error_on_failure) + system("bundle exec minitest-queue #{Dir.glob('test/**/*_test.rb').shelljoin}", exception: error_on_failure) + end end desc 'Run RuboCop over itself'