Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Normalize line endings: auto-detect text vs binary, and force LF in the
# working tree. Spec fixtures and source files compare against "...\n", so
# Windows checkouts must not introduce CRLF.
* text=auto eol=lf
25 changes: 17 additions & 8 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
timeout-minutes: 20

env:
BUNDLE_WITHOUT: "benchmark"
Expand All @@ -13,6 +14,7 @@ jobs:
fail-fast: false

matrix:
os: [ubuntu-latest]
ruby-version:
- '3.1'
- '3.2'
Expand All @@ -22,11 +24,18 @@ jobs:
- jruby-9.4
- jruby-10.0
- truffleruby
include:
- os: macos-latest
ruby-version: ruby
- os: windows-latest
ruby-version: ruby

steps:
- uses: actions/checkout@v6

- run: rm Gemfile.lock
- name: Remove Gemfile.lock
run: rm Gemfile.lock
shell: bash

- uses: ruby/setup-ruby@v1.307.0
with:
Expand All @@ -36,11 +45,11 @@ jobs:

- name: Run tests
run: bundle exec rake test
if: "!contains(matrix.ruby-version, 'jruby') && matrix.ruby-version != 'truffleruby'"
if: "!contains(matrix.ruby-version, 'jruby') && matrix.ruby-version != 'truffleruby' && matrix.os != 'windows-latest'"

# Run only `rake spec` on truffleruby and jruby, because `rake` runs
# cucumber which requires headless Chrome via cuprite/ferrum — this is
# unreliable on alternative Ruby implementations.
- name: Run specs (alternative implementations)
# Run only `rake spec` on truffleruby, jruby, and Windows. `rake` runs
# cucumber which requires headless Chrome via cuprite/ferrum, which is
# unreliable on alternative Ruby implementations and on Windows runners.
- name: Run specs only
run: bundle exec rake spec
if: "contains(matrix.ruby-version, 'jruby') || matrix.ruby-version == 'truffleruby'"
if: "contains(matrix.ruby-version, 'jruby') || matrix.ruby-version == 'truffleruby' || matrix.os == 'windows-latest'"
21 changes: 14 additions & 7 deletions .github/workflows/unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ on:

jobs:
tests:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
timeout-minutes: 20
env:
BUNDLE_WITHOUT: "benchmark"
JRUBY_OPTS: "--debug"
strategy:
fail-fast: false

matrix:
os: [ubuntu-latest]
ruby-version:
- ruby-head
- jruby-head
- truffleruby-head
include:
- os: macos-latest
ruby-version: ruby-head
- os: windows-latest
ruby-version: ruby-head

steps:
- uses: actions/checkout@v6
Expand All @@ -29,11 +36,11 @@ jobs:

- name: Run tests
run: bundle exec rake test
if: "!contains(matrix.ruby-version, 'jruby') && matrix.ruby-version != 'truffleruby-head'"
if: "!contains(matrix.ruby-version, 'jruby') && matrix.ruby-version != 'truffleruby-head' && matrix.os != 'windows-latest'"

# Run only `rake spec` on truffleruby and jruby, because `rake` runs
# cucumber which requires headless Chrome via cuprite/ferrum — this is
# unreliable on alternative Ruby implementations.
- name: Run specs (alternative implementations)
# Run only `rake spec` on truffleruby, jruby, and Windows. `rake` runs
# cucumber which requires headless Chrome via cuprite/ferrum, which is
# unreliable on alternative Ruby implementations and on Windows runners.
- name: Run specs only
run: bundle exec rake spec
if: "contains(matrix.ruby-version, 'jruby') || matrix.ruby-version == 'truffleruby-head'"
if: "contains(matrix.ruby-version, 'jruby') || matrix.ruby-version == 'truffleruby-head' || matrix.os == 'windows-latest'"
5 changes: 4 additions & 1 deletion spec/filters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ def matches?(_source_file)
skip "requires the default configuration" if ENV["SIMPLECOV_NO_DEFAULTS"]

def a_file(path)
path = File.join(SimpleCov.root, path) unless path.start_with?("/")
# Treat both Unix-style `/foo` and Windows-style `C:/foo` as absolute.
# `File.absolute_path?` alone doesn't recognize `/foo` on Windows;
# `start_with?("/")` alone doesn't recognize drive-letter paths.
path = File.join(SimpleCov.root, path) unless path.start_with?("/") || File.absolute_path?(path)
SimpleCov::SourceFile.new(path, [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
end

Expand Down
11 changes: 8 additions & 3 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
# Dogfood: start Ruby's Coverage module *before* requiring simplecov so
# simplecov's own lib/ files get tracked. Set SIMPLECOV_NO_DOGFOOD=1 to
# skip — useful when running individual specs interactively or when a
# dependency's behaviour around Coverage is being investigated.
unless ENV["SIMPLECOV_NO_DOGFOOD"]
# dependency's behaviour around Coverage is being investigated. Skipped
# on Windows because the Unix-only specs we exclude there (cross-process
# flock, `SimpleCov.root("/")`) uniquely cover a handful of lib/ lines,
# so the 100% threshold can't be met from a Windows run alone.
DOGFOOD_DISABLED = ENV["SIMPLECOV_NO_DOGFOOD"] || Gem.win_platform?

unless DOGFOOD_DISABLED
require "coverage"
# Build the criteria hash by what the runtime actually supports — JRuby
# silently ignores `branches:`/`methods:` (with warnings); some engines
Expand Down Expand Up @@ -39,7 +44,7 @@

SimpleCov.coverage_dir("tmp/coverage")

unless ENV["SIMPLECOV_NO_DOGFOOD"]
unless DOGFOOD_DISABLED
# `start_tracking` (not `start`) handles bookkeeping (pid,
# process_start_time, fork hook) without auto-installing the at_exit
# formatter — the after(:suite) hook below drives the report
Expand Down
4 changes: 3 additions & 1 deletion spec/result_merger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@
end.not_to raise_error
end

it "blocks other processes" do
it "blocks other processes" do # rubocop:disable RSpec/ExampleLength
skip "POSIX shell redirection and cross-process flock semantics are Unix-only" if Gem.win_platform?

file = Tempfile.new("foo")

test_script = <<-CODE
Expand Down
5 changes: 3 additions & 2 deletions spec/return_codes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
end
end

let(:capture) { Open3.capture3(command) }
let(:capture) { Open3.capture3(env, command) }
let(:env) { {} }
let(:captured_stderr) { capture[1] }
let(:status) { capture[2] }

Expand Down Expand Up @@ -56,7 +57,7 @@ def stderr_without_report_summary(stderr)
end

context "when print_error_status is disabled" do
let(:command) { "PRINT_ERROR_STATUS=false #{super()}" }
let(:env) { super().merge("PRINT_ERROR_STATUS" => "false") }

it "has a non-zero exit status" do
expect(status.exitstatus).not_to be_zero
Expand Down
2 changes: 2 additions & 0 deletions spec/useless_results_remover_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

context "when SimpleCov.root is the filesystem root" do
around do |example|
skip "filesystem root semantics are Unix-only" if Gem.win_platform?

previous_root = SimpleCov.root
described_class.instance_variable_set(:@root_regx, nil)
SimpleCov.root("/")
Expand Down
Loading