solargraph_test_coverage 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 586f281d9b8b4157c5601d0cd94dcb1908a1111c31d931cfc68f3b853822eb08
4
- data.tar.gz: 4b2f7f9d3cf128ca9e86c6f381a57ad53171bce4546ff343a2f43b45f55cb49d
3
+ metadata.gz: b7c7bd9d2a4a3b6184942c28ce619023f098a515ca356e8534788adb93f9cb96
4
+ data.tar.gz: 11850e7e7184658995b6e15479e8c3c87527f4b945c8b8bc9ab446242c5dba32
5
5
  SHA512:
6
- metadata.gz: 4b41851ceba11230c87053d32fd04a09fbc3bd727236e2a065a34e7f49e71c05cab2d2695fc8f1b0d7ff24a13942cacbc5d81a26fdd7a6c501e057c899d67aa5
7
- data.tar.gz: c9c530386fa430a5b0a5252aa1a0950cbd093e20f4983134643d8e2c86cdb5aa21ffa11e8afeca2ff2af7a31dbad0d5cbdd76f427990b5fb8e4e3d94edc2768c
6
+ metadata.gz: d4901017237a8e5cfc49e8a0228776c48929304ebb043bdd9c89500e56db2c4d7349b01838c911a3080900ca1d657b07f2d29a921d0cc39b2da96efe517d1443
7
+ data.tar.gz: c00ecc7e6c928c42a93abda3f976e3d0811934f21f21362a40711dbc449244a3e443d683a6c6204955ea3ec28989226f41d5b371344238594d78c86b3fb98987
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- solargraph_test_coverage (0.2.5)
4
+ solargraph_test_coverage (0.2.6)
5
5
  solargraph (~> 0.40, > 0.40)
6
6
 
7
7
  GEM
@@ -19,7 +19,7 @@ GEM
19
19
  kramdown (~> 2.0)
20
20
  nokogiri (1.12.4-x86_64-darwin)
21
21
  racc (~> 1.4)
22
- parallel (1.20.1)
22
+ parallel (1.21.0)
23
23
  parser (3.0.2.0)
24
24
  ast (~> 2.4.1)
25
25
  racc (1.5.2)
@@ -29,7 +29,7 @@ GEM
29
29
  reverse_markdown (2.0.0)
30
30
  nokogiri
31
31
  rexml (3.2.5)
32
- rubocop (1.20.0)
32
+ rubocop (1.21.0)
33
33
  parallel (~> 1.10)
34
34
  parser (>= 3.0.0.0)
35
35
  rainbow (>= 2.2.2, < 4.0)
@@ -5,25 +5,36 @@ module SolargraphTestCoverage
5
5
  # When called with a block, runs the content of said block in a new (forked) process
6
6
  # the return value of the process/block can be captured and used in parent process
7
7
  class ForkProcess
8
- # Executes block in forked process, and captures returned value of that block
9
- # Returns result of block
10
- #
11
- def self.run
12
- read, write = IO.pipe
8
+ def self.call(&block)
9
+ new.run(&block)
10
+ end
11
+
12
+ def initialize
13
+ @read, @write = IO.pipe
14
+ end
13
15
 
16
+ def run(&block)
14
17
  pid = fork do
15
- read.close
16
- result = yield
17
- Marshal.dump(result, write)
18
+ @read.close
19
+ Marshal.dump(run_block_with_timeout(&block), @write)
18
20
  exit!(0) # skips exit handlers.
19
21
  end
20
22
 
21
- write.close
22
- result = read.read
23
+ @write.close
24
+ result = @read.read
25
+
23
26
  Process.wait(pid)
24
- raise ChildFailedError if result.nil? || result.empty?
27
+ raise ChildFailedError if result.nil?
28
+
29
+ Marshal.load(result).tap { |r| raise ChildFailedError if r.nil? }
30
+ end
31
+
32
+ private
25
33
 
26
- Marshal.load(result)
34
+ def run_block_with_timeout(&block)
35
+ Timeout.timeout(30, &block)
36
+ rescue StandardError
37
+ nil
27
38
  end
28
39
  end
29
40
  end
@@ -24,7 +24,7 @@ module SolargraphTestCoverage
24
24
 
25
25
  # @return [Hash]
26
26
  def run_test(source)
27
- ForkProcess.run do
27
+ ForkProcess.call do
28
28
  Coverage.start(lines: true, branches: true)
29
29
  runner = TestRunner.with(test_file(source)).run!
30
30
  Coverage.result.fetch(source.location.filename, {}).merge({ test_status: runner.passed? })
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolargraphTestCoverage
4
- VERSION = '0.2.6'
4
+ VERSION = '0.2.7'
5
5
  end
@@ -10,6 +10,7 @@ require 'solargraph_test_coverage/test_coverage_reporter'
10
10
 
11
11
  require 'solargraph'
12
12
  require 'coverage'
13
+ require 'timeout'
13
14
 
14
15
  module SolargraphTestCoverage
15
16
  class ChildFailedError < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph_test_coverage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Kolkey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-15 00:00:00.000000000 Z
11
+ date: 2021-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solargraph