Skip to content

simplecov.rb - fix Process monkey patch for fork when unsupported - #932

Merged
PragTob merged 1 commit into
simplecov-ruby:mainfrom
MSP-Greg:fix-fork-monkey-patch
Oct 4, 2020
Merged

PragTob merged 1 commit into
simplecov-ruby:mainfrom
MSP-Greg:fix-fork-monkey-patch

Conversation

@MSP-Greg

@MSP-Greg MSP-Greg commented Oct 3, 2020

Copy link
Copy Markdown
Contributor

Monkey patching Process.fork causes issues with applications that make use of fork but also run on Ruby builds without fork (like Windows & JRuby).

Fix so ./simplecov/process.rb is only required if the platform supports Process.fork.

@PragTob PragTob left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much and sorry for the oversight!

I'll merge so it can go into the next release, however if you could post what the problem is that occurs I'd be happy. We're running tests on JRuby and they didn't fail so it must be a gap in our tests that'd like to fill and fix.

WhatsApp Image 2020-07-11 at 23 18 00

@PragTob
PragTob merged commit dd35066 into simplecov-ruby:main Oct 4, 2020
@MSP-Greg

MSP-Greg commented Oct 4, 2020

Copy link
Copy Markdown
Contributor Author

you could post what the problem is that occurs

Sorry. I was/am working on coverage for an app that runs on Ubuntu/macOS/Windows both MRI & JRuby. It uses fork, and the test suite has tests for that.

Rather than using platform/OS conditionals, we've always preferred using ::Process.respond_to? :fork, as it's clear what the intent is. When we load simplecov, it patches Process, regardless of whether Ruby supports it.

First time I ran coverage, was a little surprised to see the fork tests running on JRuby & Windows...

JFYI, the app (Puma) has parallel tests, tests starting Puma via IO.popen, and the popen processes are running fork. Not sure if it's running correctly yet. There's coverage for the popen processes, but not sure about the forks.

I did need to prepend into SimpleCov::Result#format! to shut off the output, as sometimes we're testing the io returned by IO.popen. I think that made sense...

Also, re CI, stable.yml could easily add a Windows job, and since ruby/setup-ruby@v1 now has ruby head builds on all platforms, unstable.yml could use those. Several repos test against those head builds, some not even using allow-failure...

@MSP-Greg
MSP-Greg deleted the fix-fork-monkey-patch branch October 4, 2020 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants