pork 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGES.md +7 -0
- data/README.md +21 -0
- data/lib/pork.rb +4 -0
- data/lib/pork/imp.rb +2 -2
- data/lib/pork/mode/parallel.rb +3 -1
- data/lib/pork/stat.rb +4 -3
- data/lib/pork/test.rb +3 -0
- data/lib/pork/version.rb +1 -1
- data/pork.gemspec +3 -3
- data/test/test_stat.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdbd288e9e6c43e60dfb0d7fc15f456d557da42b
|
4
|
+
data.tar.gz: 1b391c3d7b4a8ec1aa4166e65f140830c38c7afb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad7c493a34029247ceef94e09154710fee21e76aba5c2863dd4e734e3abeb173d671c8932575f91daa542b570bb7808666fe6df8d45114abb644a3edf1452e7d
|
7
|
+
data.tar.gz: e3d889709be117ba545c879299eb52b6ff66f9e8a68cf49594bf35a18af7b4b47a4ffdf9c438535f4156d3451ff115aef19b7d1f8a555b4020ef486e23968685
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
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
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
|
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
|
-
|
74
|
+
else
|
75
75
|
stat.add_error(err)
|
76
76
|
stat.reporter.case_errored
|
77
77
|
end
|
data/lib/pork/mode/parallel.rb
CHANGED
@@ -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,
|
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(
|
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
data/lib/pork/version.rb
CHANGED
data/pork.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: pork 1.4.
|
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.
|
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-
|
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
|
-
|
25
|
-
|
26
|
-
|
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.
|
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-
|
11
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|