Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplecov-0.8.1 with lockfile causes hangs on Windows #258

Closed
holtrop opened this issue Nov 14, 2013 · 9 comments
Closed

simplecov-0.8.1 with lockfile causes hangs on Windows #258

holtrop opened this issue Nov 14, 2013 · 9 comments
Labels

Comments

@holtrop
Copy link

holtrop commented Nov 14, 2013

We recently tried to upgrade to simplecov-0.8.1 and discovered that our builds began hanging for 1 hour and finally ended with messages like the following:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:250:in `unlink': Permission denied - D:/BuildAgent/work/2db3d5008923a037/artifacts/coverage/.resultset.json.lockfile (Errno::EACCES)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:250:in `rescue in block (3 levels) in lock'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:211:in `block (3 levels) in lock'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:206:in `block (2 levels) in lock'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:430:in `block in create_tmplock'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:488:in `create'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:422:in `create_tmplock'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:204:in `block in lock'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:517:in `block (2 levels) in attempt'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:517:in `catch'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:517:in `block in attempt'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:517:in `loop'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:517:in `attempt'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/lockfile-2.1.0/lib/lockfile.rb:201:in `lock'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/simplecov-0.8.1/lib/simplecov.rb:52:in `result'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/simplecov-0.8.1/lib/simplecov/configuration.rb:139:in `block in at_exit'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/simplecov-0.8.1/lib/simplecov/defaults.rb:54:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/simplecov-0.8.1/lib/simplecov/defaults.rb:54:in `block in <top (required)>'
C:/Ruby193/bin/ruby.exe -S rspec <spec-file-list> --color --format n --format h -o artifacts/spec_results.html failed

I'm not sure if this is just a lockfile problem, or if simplecov or lockfile have been tested to work on Windows or not.

@colszowka
Copy link
Collaborator

Ugh, how annoying. Though I do not use Windows, if simplecov fails there this is a bug. I am not too happy with the Lockfile gem dependency, since the gem has not seen updates in a long time and yields a lot of ruby warnings when the warnings level is set higher than the default.

If you have a couple minutes, could you maybe try to manipulate your local simplecov installation with the lock implementation as seen in #233? From your project, bundle show simplecov should give you the install path, then you can simply hack that bit of result_merger.rb as shown in the PR. You'll also need to remove the Lockfile stuff from here: https://github.com/colszowka/simplecov/blob/master/lib/simplecov.rb#L50-L55

It would be super-useful to know if that implementation works on Windows. That, and JRuby are the main reasons that get me suspicious this approach wouldn't work.

@holtrop
Copy link
Author

holtrop commented Nov 14, 2013

I'm willing to try out a patch, but I'm not sure how to modify simplecov as you're describing. I don't see any changes to result_merger.rb in #233.

@colszowka
Copy link
Collaborator

I'm stupid - I meant to link #223, sorry for the confusion :(

@holtrop
Copy link
Author

holtrop commented Nov 14, 2013

I believe this patch is what you were describing. With it in place (on top of simplecov-0.8.1) my project runs specs just fine without hanging.

diff -rupN a/lib/simplecov/result_merger.rb b/lib/simplecov/result_merger.rb
--- a/lib/simplecov/result_merger.rb    2013-11-13 12:21:04.000000000 -0500
+++ b/lib/simplecov/result_merger.rb    2013-11-14 11:28:53.000000000 -0500
@@ -13,7 +13,11 @@ module SimpleCov::ResultMerger
     # Loads the cached resultset from YAML and returns it as a Hash
     def resultset
       if stored_data
-        SimpleCov::JSON.parse(stored_data)
+        begin
+          SimpleCov::JSON.parse(stored_data)
+        rescue
+          {}
+        end
       else
         {}
       end
@@ -66,6 +70,7 @@ module SimpleCov::ResultMerger
       command_name, data = result.to_hash.first
       new_set[command_name] = data
       File.open(resultset_path, "w+") do |f|
+        f.flock(File::LOCK_EX)
         f.puts SimpleCov::JSON.dump(new_set)
       end
       true
diff -rupN a/lib/simplecov.rb b/lib/simplecov.rb
--- a/lib/simplecov.rb  2013-11-13 12:21:04.000000000 -0500
+++ b/lib/simplecov.rb  2013-11-14 11:29:54.000000000 -0500
@@ -47,12 +47,12 @@ module SimpleCov
       # If we're using merging of results, store the current result
       # first, then merge the results and return those
       if use_merging
-        lockfile = ::Lockfile.new ResultMerger.resultset_path + '.lockfile'
+#        lockfile = ::Lockfile.new ResultMerger.resultset_path + '.lockfile'

-        lockfile.lock do
+#        lockfile.lock do
           SimpleCov::ResultMerger.store_result(@result) if @result
           return SimpleCov::ResultMerger.merged_result
-        end
+#        end
       else
         return @result if defined? @result
       end

FraBle pushed a commit to openHPI/hpi-connect-portal that referenced this issue Nov 15, 2013
@jmcaffee
Copy link

I'm seeing the same issue and this fixes it as well.

Windows 7 x64 running in mSysGit bash shell.
ruby 1.9.3p392 (2013-02-22) [i386-mingw32]
simplecov (0.8.1)
rspec (2.14.1)

@jmthomas
Copy link

+1. Exact same configuration as @jmcaffee. Without this fix the Windows gem is hard broken.

@phs
Copy link

phs commented Nov 20, 2013

Tangentially related, I encounter a similar problem using vagrant, specifically on virtual box (ubuntu guest) with the synced folders feature. It apparently also does not look enough like a real filesystem for the lock file to work: instead it silently blocks forever on acquisition.

I personally don't need the merging feature and so I just disabled it with use_merging false, which works around the problem. However it would've been nice if at least there was some sort of timeout on the acquisition that could have printed a helpful warning.

@colszowka
Copy link
Collaborator

Just shipped 0.8.2 with this fix to Rubygems.org. Please let me know if this fixes things for you!

@holtrop
Copy link
Author

holtrop commented Nov 20, 2013

I've upgraded to 0.8.2 and it does work properly.

FraBle pushed a commit to openHPI/hpi-connect-portal that referenced this issue Nov 22, 2013
(Current Status: Test Coverage 84,99%)
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Mar 15, 2014
v0.8.2, 2013-11-20 ([changes](simplecov-ruby/simplecov@v0.8.1...v0.8.2))
=====================

## Bugfixes

  * Replaced the locking behaviour [via lockfile gem](simplecov-ruby/simplecov#185) with
    plain Ruby explicit file locking when merging results. This should make simplecov merging to behave well
    on Windows again.
    See [#258](simplecov-ruby/simplecov#258) and
    [#223](simplecov-ruby/simplecov#223) (thanks to @tomykaira)

v0.8.1, 2013-11-10 ([changes](simplecov-ruby/simplecov@v0.8.0...v0.8.1))
=====================

## Bugfixes

  * Fixed a regression introduced in 0.8.0 - the Forwardable STDLIB module is now required explicitly.
    See [#256](simplecov-ruby/simplecov#256) (thanks to @kylev)

v0.8.0, 2013-11-10 ([changes](simplecov-ruby/simplecov@v0.7.1...v0.8.0))
=====================

**Note: Yanked the same day because of the regression that 0.8.1 fixes, see above**

## TL;DR

It's been way too long since the last official release 0.7.1, but this was partly due to it proving itself
quite stable in most circumstances. This release brings various further stability improvements to result set merging
(especially when working with parallel_tests), the configuration, source file encodings, and command name guessing.

The 0.8 line is the last one to cooperate with Ruby < 1.9. Starting with 0.9, SimpleCov will assume to be running in
Ruby 1.9+, and will not try to detect or bail silently on older Ruby versions. An appropriate deprecation warning
has been added.

## Features

  * Configuration blocks now have access to variables and methods outside of the block's scope.
    See [#238](simplecov-ruby/simplecov#238) (thanks to @ms-tg)
  * You can now have a global `~/.simplecov` configuration file.
    See [#195](simplecov-ruby/simplecov#195) (thanks to @spagalloco)
  * simplecov-html now uses the MIT-licensed colorbox plugin. Some adjustments when viewing source files,
    including retaining the currently open file on refresh have been added.
    See [simplecov-html #15](simplecov-ruby/simplecov-html#15) (thanks to @chetan)
  * Adds support for Rails 4 command guessing, removes default group `vendor/plugins`.
    See [#181](simplecov-ruby/simplecov#181) and
    [#203](simplecov-ruby/simplecov#203) (thanks to @semanticart and @phallstrom)
  * You can now load simplecov without the default settings by doing `require 'simplecov/no_defaults'`
    or setting `ENV['SIMPLECOV_NO_DEFAULTS']`. Check `simplecov/defaults` to see what preconfigurations are getting
    dropped by using this. See [#209](simplecov-ruby/simplecov#209) (thanks to @ileitch)
  * The result set merging now uses the `lockfile` gem to avoid race conditions.
    See [#185](simplecov-ruby/simplecov#185) (thanks to @jshraibman-mdsol).
  * Automatically detect the usage of parallel_tests and adjust the command name with the test env number accordingly,
    See [#64](simplecov-ruby/simplecov#64) and
    [#185](simplecov-ruby/simplecov#185) (thanks to @jshraibman-mdsol).

## Enhancements

  * Rename adapters to "profiles" given that they are bundles of settings. The old adapter methods are
    deprecated, but remain available for now.
    See [#207](simplecov-ruby/simplecov#207) (thanks to @mikerobe)
  * Tweaks to the automatic test suite naming. In particular, `rspec/features` should now
    be correctly attributed to RSpec, not Cucumber.
    See [#212](simplecov-ruby/simplecov#212) (thanks to @ersatzryan and @betelgeuse)
  * MiniTest should now be identified correctly by the command name guesser.
    See [#244](simplecov-ruby/simplecov#244) (thanks to @envygeeks)
  * Makes SimpleCov resilient to inclusion of mathn library.
    See [#175](simplecov-ruby/simplecov#175) and
    [#140](simplecov-ruby/simplecov#140) (thanks to @scotje)
  * Allow coverage_dir to be an absolute path.
  * See [#190](simplecov-ruby/simplecov#190) (thanks to @jshraibman-mdsol)
  * The internal cucumber test suite now uses Capybara 2.
    See [#206](simplecov-ruby/simplecov#206) (thanks to @infertux)
  * Work-arounds for the Coverage library shipped in JRuby 1.6 to behave in line with MRI.
    See [#174](simplecov-ruby/simplecov#174) (thanks to @grddev)
  * Fix warning: instance variable @exit_status not initialized.
    See [#242](simplecov-ruby/simplecov#242) and
    [#213](simplecov-ruby/simplecov#213) (thanks to @sferik and @infertux)

## Bugfixes

  * Correct result calculations for people using :nocov: tags.
    See [#215](simplecov-ruby/simplecov#215) (thanks to @aokolish)
  * Average hits per line for groups of files is now computed correctly.
    See [#192](http://github.com/colszowka/simplecov/pull/192) and
    [#179](http://github.com/colszowka/simplecov/issues/179) (thanks to @Graysonwright)
  * Compatability with BINARY internal encoding.
    See [#194](simplecov-ruby/simplecov#194) and
    [#127](simplecov-ruby/simplecov#127) (thanks to @justfalter)
  * Special characters in `SimpleCov.root` are now correctly escaped before being used as a RegExp.
    See [#204](simplecov-ruby/simplecov#204) and
    [#237](simplecov-ruby/simplecov#237) (thanks to @rli9)
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Mar 17, 2014
v0.8.2, 2013-11-20 ([changes](simplecov-ruby/simplecov@v0.8.1...v0.8.2))
=====================

## Bugfixes

  * Replaced the locking behaviour [via lockfile gem](simplecov-ruby/simplecov#185) with
    plain Ruby explicit file locking when merging results. This should make simplecov merging to behave well
    on Windows again.
    See [#258](simplecov-ruby/simplecov#258) and
    [#223](simplecov-ruby/simplecov#223) (thanks to @tomykaira)

v0.8.1, 2013-11-10 ([changes](simplecov-ruby/simplecov@v0.8.0...v0.8.1))
=====================

## Bugfixes

  * Fixed a regression introduced in 0.8.0 - the Forwardable STDLIB module is now required explicitly.
    See [#256](simplecov-ruby/simplecov#256) (thanks to @kylev)

v0.8.0, 2013-11-10 ([changes](simplecov-ruby/simplecov@v0.7.1...v0.8.0))
=====================

**Note: Yanked the same day because of the regression that 0.8.1 fixes, see above**

## TL;DR

It's been way too long since the last official release 0.7.1, but this was partly due to it proving itself
quite stable in most circumstances. This release brings various further stability improvements to result set merging
(especially when working with parallel_tests), the configuration, source file encodings, and command name guessing.

The 0.8 line is the last one to cooperate with Ruby < 1.9. Starting with 0.9, SimpleCov will assume to be running in
Ruby 1.9+, and will not try to detect or bail silently on older Ruby versions. An appropriate deprecation warning
has been added.

## Features

  * Configuration blocks now have access to variables and methods outside of the block's scope.
    See [#238](simplecov-ruby/simplecov#238) (thanks to @ms-tg)
  * You can now have a global `~/.simplecov` configuration file.
    See [#195](simplecov-ruby/simplecov#195) (thanks to @spagalloco)
  * simplecov-html now uses the MIT-licensed colorbox plugin. Some adjustments when viewing source files,
    including retaining the currently open file on refresh have been added.
    See [simplecov-html #15](simplecov-ruby/simplecov-html#15) (thanks to @chetan)
  * Adds support for Rails 4 command guessing, removes default group `vendor/plugins`.
    See [#181](simplecov-ruby/simplecov#181) and
    [#203](simplecov-ruby/simplecov#203) (thanks to @semanticart and @phallstrom)
  * You can now load simplecov without the default settings by doing `require 'simplecov/no_defaults'`
    or setting `ENV['SIMPLECOV_NO_DEFAULTS']`. Check `simplecov/defaults` to see what preconfigurations are getting
    dropped by using this. See [#209](simplecov-ruby/simplecov#209) (thanks to @ileitch)
  * The result set merging now uses the `lockfile` gem to avoid race conditions.
    See [#185](simplecov-ruby/simplecov#185) (thanks to @jshraibman-mdsol).
  * Automatically detect the usage of parallel_tests and adjust the command name with the test env number accordingly,
    See [#64](simplecov-ruby/simplecov#64) and
    [#185](simplecov-ruby/simplecov#185) (thanks to @jshraibman-mdsol).

## Enhancements

  * Rename adapters to "profiles" given that they are bundles of settings. The old adapter methods are
    deprecated, but remain available for now.
    See [#207](simplecov-ruby/simplecov#207) (thanks to @mikerobe)
  * Tweaks to the automatic test suite naming. In particular, `rspec/features` should now
    be correctly attributed to RSpec, not Cucumber.
    See [#212](simplecov-ruby/simplecov#212) (thanks to @ersatzryan and @betelgeuse)
  * MiniTest should now be identified correctly by the command name guesser.
    See [#244](simplecov-ruby/simplecov#244) (thanks to @envygeeks)
  * Makes SimpleCov resilient to inclusion of mathn library.
    See [#175](simplecov-ruby/simplecov#175) and
    [#140](simplecov-ruby/simplecov#140) (thanks to @scotje)
  * Allow coverage_dir to be an absolute path.
  * See [#190](simplecov-ruby/simplecov#190) (thanks to @jshraibman-mdsol)
  * The internal cucumber test suite now uses Capybara 2.
    See [#206](simplecov-ruby/simplecov#206) (thanks to @infertux)
  * Work-arounds for the Coverage library shipped in JRuby 1.6 to behave in line with MRI.
    See [#174](simplecov-ruby/simplecov#174) (thanks to @grddev)
  * Fix warning: instance variable @exit_status not initialized.
    See [#242](simplecov-ruby/simplecov#242) and
    [#213](simplecov-ruby/simplecov#213) (thanks to @sferik and @infertux)

## Bugfixes

  * Correct result calculations for people using :nocov: tags.
    See [#215](simplecov-ruby/simplecov#215) (thanks to @aokolish)
  * Average hits per line for groups of files is now computed correctly.
    See [#192](http://github.com/colszowka/simplecov/pull/192) and
    [#179](http://github.com/colszowka/simplecov/issues/179) (thanks to @Graysonwright)
  * Compatability with BINARY internal encoding.
    See [#194](simplecov-ruby/simplecov#194) and
    [#127](simplecov-ruby/simplecov#127) (thanks to @justfalter)
  * Special characters in `SimpleCov.root` are now correctly escaped before being used as a RegExp.
    See [#204](simplecov-ruby/simplecov#204) and
    [#237](simplecov-ruby/simplecov#237) (thanks to @rli9)
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Oct 11, 2014
v0.8.2, 2013-11-20 ([changes](simplecov-ruby/simplecov@v0.8.1...v0.8.2))
=====================

## Bugfixes

  * Replaced the locking behaviour [via lockfile gem](simplecov-ruby/simplecov#185) with
    plain Ruby explicit file locking when merging results. This should make simplecov merging to behave well
    on Windows again.
    See [#258](simplecov-ruby/simplecov#258) and
    [#223](simplecov-ruby/simplecov#223) (thanks to @tomykaira)

v0.8.1, 2013-11-10 ([changes](simplecov-ruby/simplecov@v0.8.0...v0.8.1))
=====================

## Bugfixes

  * Fixed a regression introduced in 0.8.0 - the Forwardable STDLIB module is now required explicitly.
    See [#256](simplecov-ruby/simplecov#256) (thanks to @kylev)

v0.8.0, 2013-11-10 ([changes](simplecov-ruby/simplecov@v0.7.1...v0.8.0))
=====================

**Note: Yanked the same day because of the regression that 0.8.1 fixes, see above**

## TL;DR

It's been way too long since the last official release 0.7.1, but this was partly due to it proving itself
quite stable in most circumstances. This release brings various further stability improvements to result set merging
(especially when working with parallel_tests), the configuration, source file encodings, and command name guessing.

The 0.8 line is the last one to cooperate with Ruby < 1.9. Starting with 0.9, SimpleCov will assume to be running in
Ruby 1.9+, and will not try to detect or bail silently on older Ruby versions. An appropriate deprecation warning
has been added.

## Features

  * Configuration blocks now have access to variables and methods outside of the block's scope.
    See [#238](simplecov-ruby/simplecov#238) (thanks to @ms-tg)
  * You can now have a global `~/.simplecov` configuration file.
    See [#195](simplecov-ruby/simplecov#195) (thanks to @spagalloco)
  * simplecov-html now uses the MIT-licensed colorbox plugin. Some adjustments when viewing source files,
    including retaining the currently open file on refresh have been added.
    See [simplecov-html #15](simplecov-ruby/simplecov-html#15) (thanks to @chetan)
  * Adds support for Rails 4 command guessing, removes default group `vendor/plugins`.
    See [#181](simplecov-ruby/simplecov#181) and
    [#203](simplecov-ruby/simplecov#203) (thanks to @semanticart and @phallstrom)
  * You can now load simplecov without the default settings by doing `require 'simplecov/no_defaults'`
    or setting `ENV['SIMPLECOV_NO_DEFAULTS']`. Check `simplecov/defaults` to see what preconfigurations are getting
    dropped by using this. See [#209](simplecov-ruby/simplecov#209) (thanks to @ileitch)
  * The result set merging now uses the `lockfile` gem to avoid race conditions.
    See [#185](simplecov-ruby/simplecov#185) (thanks to @jshraibman-mdsol).
  * Automatically detect the usage of parallel_tests and adjust the command name with the test env number accordingly,
    See [#64](simplecov-ruby/simplecov#64) and
    [#185](simplecov-ruby/simplecov#185) (thanks to @jshraibman-mdsol).

## Enhancements

  * Rename adapters to "profiles" given that they are bundles of settings. The old adapter methods are
    deprecated, but remain available for now.
    See [#207](simplecov-ruby/simplecov#207) (thanks to @mikerobe)
  * Tweaks to the automatic test suite naming. In particular, `rspec/features` should now
    be correctly attributed to RSpec, not Cucumber.
    See [#212](simplecov-ruby/simplecov#212) (thanks to @ersatzryan and @betelgeuse)
  * MiniTest should now be identified correctly by the command name guesser.
    See [#244](simplecov-ruby/simplecov#244) (thanks to @envygeeks)
  * Makes SimpleCov resilient to inclusion of mathn library.
    See [#175](simplecov-ruby/simplecov#175) and
    [#140](simplecov-ruby/simplecov#140) (thanks to @scotje)
  * Allow coverage_dir to be an absolute path.
  * See [#190](simplecov-ruby/simplecov#190) (thanks to @jshraibman-mdsol)
  * The internal cucumber test suite now uses Capybara 2.
    See [#206](simplecov-ruby/simplecov#206) (thanks to @infertux)
  * Work-arounds for the Coverage library shipped in JRuby 1.6 to behave in line with MRI.
    See [#174](simplecov-ruby/simplecov#174) (thanks to @grddev)
  * Fix warning: instance variable @exit_status not initialized.
    See [#242](simplecov-ruby/simplecov#242) and
    [#213](simplecov-ruby/simplecov#213) (thanks to @sferik and @infertux)

## Bugfixes

  * Correct result calculations for people using :nocov: tags.
    See [#215](simplecov-ruby/simplecov#215) (thanks to @aokolish)
  * Average hits per line for groups of files is now computed correctly.
    See [#192](http://github.com/colszowka/simplecov/pull/192) and
    [#179](http://github.com/colszowka/simplecov/issues/179) (thanks to @Graysonwright)
  * Compatability with BINARY internal encoding.
    See [#194](simplecov-ruby/simplecov#194) and
    [#127](simplecov-ruby/simplecov#127) (thanks to @justfalter)
  * Special characters in `SimpleCov.root` are now correctly escaped before being used as a RegExp.
    See [#204](simplecov-ruby/simplecov#204) and
    [#237](simplecov-ruby/simplecov#237) (thanks to @rli9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants