pork 1.4.2 → 1.4.3

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
  SHA1:
3
- metadata.gz: 1e2ed8b97411bd1270c6b8954b1cced0fdae7f9c
4
- data.tar.gz: b158b85c78742cd90db66e64ebc69b02de575d5f
3
+ metadata.gz: bdbd288e9e6c43e60dfb0d7fc15f456d557da42b
4
+ data.tar.gz: 1b391c3d7b4a8ec1aa4166e65f140830c38c7afb
5
5
  SHA512:
6
- metadata.gz: a9712415105e5c73abdab0be52c29c918252beb7605398607c7252a204a1d0af2ae4813d633467ab4da25aa7fc3bf848e968ff0184b7824d8fd1462ba73d080d
7
- data.tar.gz: 5c7851bd5850efb24f41bb996731044a5f834818e84fc02dd9d015d080baa4eac2b5a55b85e487694c2716eae1f6fd5bccde88d4bfb9904230d9a4c086452cb6
6
+ metadata.gz: ad7c493a34029247ceef94e09154710fee21e76aba5c2863dd4e734e3abeb173d671c8932575f91daa542b570bb7808666fe6df8d45114abb644a3edf1452e7d
7
+ data.tar.gz: e3d889709be117ba545c879299eb52b6ff66f9e8a68cf49594bf35a18af7b4b47a4ffdf9c438535f4156d3451ff115aef19b7d1f8a555b4020ef486e23968685
data/.travis.yml CHANGED
@@ -5,7 +5,7 @@ rvm:
5
5
  - 2.1
6
6
  - 2.2
7
7
  - rbx-2
8
- - jruby
8
+ - jruby-9.0.0.0
9
9
 
10
10
  install: 'bundle install --retry=3'
11
11
  script: 'ruby -r bundler/setup -S rake test'
data/CHANGES.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGES
2
2
 
3
+ ## Pork 1.4.3 -- 2015-10-08
4
+
5
+ ### Enhancement
6
+
7
+ * Introduced `Pork.protected_exceptions` to protect exceptions aren't
8
+ derived from `StandardError`. Check README for usage.
9
+
3
10
  ## Pork 1.4.2 -- 2015-09-23
4
11
 
5
12
  ### Bugs fixed
data/README.md CHANGED
@@ -863,6 +863,27 @@ and randomness.
863
863
  Otherwise, you don't have to care about this option. Just copy and
864
864
  paste the replicating command when one of your test cases failed.
865
865
 
866
+ ### Pork.protected_exceptions
867
+
868
+ By default, Pork only rescues exceptions derived from `StandardError`,
869
+ this is due to the fact that we don't want to interfere with some system
870
+ exception like signal handling and so on so forth. (e.g. `SignalException`,
871
+ `LoadError`, `SyntaxError`, etc).
872
+
873
+ However, some libraries do not raise exceptions derived from `StandardError`.
874
+ I would recommend fix them, but as a workaround, you could also tell Pork to
875
+ rescue those exceptions so that your test suites won't just stop there.
876
+
877
+ Let's take webmock as an example, we'll do this to avoid stopping the tests
878
+ whenever webmock complains:
879
+
880
+ ``` ruby
881
+ Pork.protected_exceptions << WebMock::NetConnectNotAllowedError
882
+ ```
883
+
884
+ This would effectively tell Pork to rescue it and treat it as a regular
885
+ test error instead of stopping the whole process.
886
+
866
887
  ### Pork.execute_mode
867
888
 
868
889
  By default, `Pork.execute_mode` is set to `:shuffled` which would execute
data/lib/pork.rb CHANGED
@@ -31,6 +31,10 @@ module Pork
31
31
  @report_extensions ||= []
32
32
  end
33
33
 
34
+ def self.protected_exceptions
35
+ stat.protected_exceptions
36
+ end
37
+
34
38
  def self.Rainbows!
35
39
  require 'pork/extra/rainbows'
36
40
  report_extensions << Rainbows
data/lib/pork/imp.rb CHANGED
@@ -60,7 +60,7 @@ module Pork
60
60
 
61
61
  def run_protected stat, desc, test, seed
62
62
  yield
63
- rescue Error, StandardError => e
63
+ rescue *stat.protected_exceptions => e
64
64
  case e
65
65
  when Skip
66
66
  stat.incr_skips
@@ -71,7 +71,7 @@ module Pork
71
71
  when Failure
72
72
  stat.add_failure(err)
73
73
  stat.reporter.case_failed
74
- when Error, StandardError
74
+ else
75
75
  stat.add_error(err)
76
76
  stat.reporter.case_errored
77
77
  end
@@ -10,7 +10,9 @@ module Pork
10
10
  def parallel stat=Stat.new, paths=all_paths
11
11
  paths.shuffle.each_slice(cores).map do |paths_slice|
12
12
  Thread.new do
13
- execute(:shuffled, Stat.new(stat.reporter), paths_slice)
13
+ execute(:shuffled,
14
+ Stat.new(stat.reporter, stat.protected_exceptions),
15
+ paths_slice)
14
16
  end
15
17
  end.map(&:value).inject(stat, &:merge)
16
18
  end
data/lib/pork/stat.rb CHANGED
@@ -3,13 +3,14 @@ require 'thread'
3
3
  require 'pork/report'
4
4
 
5
5
  module Pork
6
- Stat = Struct.new(:reporter, :start, :mutex,
6
+ Stat = Struct.new(:reporter, :protected_exceptions, :start, :mutex,
7
7
  :tests, :assertions, :skips, :failures, :errors,
8
8
  :exceptions)
9
9
 
10
10
  module Stat::Imp
11
11
  attr_accessor :stop
12
12
  def initialize rt=Pork.report_class.new,
13
+ protected_exceptions=[Pork::Error, StandardError],
13
14
  st=Time.now, mu=Mutex.new,
14
15
  t=0, a=0, s=0, f=0, e=0, x=[]
15
16
  super
@@ -49,8 +50,8 @@ module Pork
49
50
  end
50
51
 
51
52
  def merge stat
52
- self.class.new(reporter, start, mutex,
53
- *to_a.drop(3).zip(stat.to_a.drop(3)).map{ |(a, b)| a + b })
53
+ self.class.new(reporter, protected_exceptions, start, mutex,
54
+ *to_a.drop(4).zip(stat.to_a.drop(4)).map{ |(a, b)| a + b })
54
55
  end
55
56
  end
56
57
 
data/lib/pork/test.rb CHANGED
@@ -5,6 +5,9 @@ Pork.autorun
5
5
  Pork.show_source
6
6
  Pork.Rainbows! if rand(10) == 0
7
7
 
8
+ WebMockError = Class.new(Exception)
9
+ Pork.protected_exceptions << WebMockError
10
+
8
11
  Pork.singleton_class.send(:prepend, Module.new{
9
12
  def execute
10
13
  super
data/lib/pork/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Pork
3
- VERSION = '1.4.2'
3
+ VERSION = '1.4.3'
4
4
  end
data/pork.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: pork 1.4.2 ruby lib
2
+ # stub: pork 1.4.3 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "pork"
6
- s.version = "1.4.2"
6
+ s.version = "1.4.3"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["Lin Jen-Shin (godfat)"]
11
- s.date = "2015-09-23"
11
+ s.date = "2015-10-08"
12
12
  s.description = "Pork -- Simple and clean and modular testing library.\n\nInspired by [Bacon][].\n\n[Bacon]: https://github.com/chneukirchen/bacon"
13
13
  s.email = ["godfat (XD) godfat.org"]
14
14
  s.files = [
data/test/test_stat.rb CHANGED
@@ -21,9 +21,9 @@ describe Pork::Stat do
21
21
  end
22
22
 
23
23
  def run check=:expect_one_error
24
- @stat = @executor.execute(
25
- Pork.execute_mode,
26
- Pork::Stat.new(Pork.report_class.new(StringIO.new)))
24
+ stat = Pork::Stat.new(Pork.report_class.new(StringIO.new))
25
+ stat.protected_exceptions = pork_stat.protected_exceptions
26
+ @stat = @executor.execute(Pork.execute_mode, stat)
27
27
  send(check)
28
28
  end
29
29
 
@@ -41,6 +41,11 @@ describe Pork::Stat do
41
41
  expect(@stat.failures) .eq 1
42
42
  end
43
43
 
44
+ would 'rescue custom errors' do
45
+ @executor.would{ raise WebMockError }
46
+ run
47
+ end
48
+
44
49
  would 'always have backtrace' do
45
50
  @executor.would
46
51
  run
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pork
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source