pork 1.0.3 → 1.0.4

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: 93ff53eb058bf9490356aab97ec7e4df4d381197
4
- data.tar.gz: c0c795be8a249d408bd5e0ae7d4b07aefa293386
3
+ metadata.gz: b3309a4342d94a048959287afbbc330bfbcffdd6
4
+ data.tar.gz: 90549fc74cc0d7ed04c47d09b7c011001acc5b01
5
5
  SHA512:
6
- metadata.gz: 30626f3c05d102b2aa1156c75819545c430d0e06c64e8bb9a564aa41c01bbfa88b08355b089b232b31325f448345b77f5221da9ccb13c71d97f3bcf9d1992353
7
- data.tar.gz: 3dd03c8d7bf872dc3a7374715a0a812d0031f825148cdeeaa7f6893a9da3f9b1e029c4001ddfb27a3fe35bfc126c983dcafe4c4343ceebc2af49eafde05f0083
6
+ metadata.gz: 7c2c045065fec739b79b34e07f47eb0826123226d08e5b7b5845f9a490be0dfdeaa450468a0c268ed6bce38353e288d30993efcfba58f94b13a98d4d338e325d
7
+ data.tar.gz: 5c9d5b7aaa8125292a92183cf524d44dc6328f3f44c23f9991273163fdf178fadf62a626d213c587f0bb30b38977814fa9beb711f83d88f62247e98353b863dc
data/CHANGES.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGES
2
2
 
3
+ ## Pork 1.0.4 -- 2014-12-29
4
+
5
+ * Make backtrace easier to read by using `.` and `~`.
6
+ * Fix parallels mode to detect missing assertions properly.
7
+ * Slightly changed `Pork::Stat`. A kinda incompatible change,
8
+ but using `Pork::Stat` should be considered private.
9
+
3
10
  ## Pork 1.0.3 -- 2014-12-26
4
11
 
5
12
  * Fix `Kernel#should` compatibility for JRuby 1.7.18- and Ruby 2.2.0 by
@@ -6,9 +6,12 @@ module Pork
6
6
  module Parallel
7
7
  def parallel cores=8, stat=Stat.new
8
8
  all_tests.keys.shuffle.each_slice(cores).map do |names|
9
- Thread.new{ names.each{ |n| isolate(n, stat) } }
10
- end.each(&:join)
11
- stat
9
+ Thread.new do
10
+ s = Stat.new
11
+ names.each{ |n| isolate(n, s) }
12
+ s
13
+ end
14
+ end.map(&:value).inject(stat, &:merge)
12
15
  end
13
16
  end
14
17
 
data/lib/pork/stat.rb CHANGED
@@ -2,18 +2,17 @@
2
2
  require 'thread'
3
3
 
4
4
  module Pork
5
- class Stat < Struct.new(:tests, :assertions, :skips,
6
- :failures, :errors, :start, :io)
7
- def initialize io=$stdout
8
- @mutex = Mutex.new
9
- super(0, 0, 0, [], [], Time.now, io)
5
+ class Stat < Struct.new(:io, :start, :mutex,
6
+ :tests, :assertions, :skips, :failures, :errors)
7
+ def initialize io=$stdout, st=Time.now, mu=Mutex.new,
8
+ t=0, a=0, s=0, f=[], e=[]
9
+ super
10
10
  end
11
-
12
- def incr_assertions; @mutex.synchronize{ self.assertions += 1 }; end
13
- def incr_tests ; @mutex.synchronize{ self.tests += 1 }; end
14
- def incr_skips ; @mutex.synchronize{ self.skips += 1 }; end
15
- def add_failure *e ; @mutex.synchronize{ failures << e }; end
16
- def add_error *e ; @mutex.synchronize{ errors << e }; end
11
+ def incr_assertions; mutex.synchronize{ self.assertions += 1 }; end
12
+ def incr_tests ; mutex.synchronize{ self.tests += 1 }; end
13
+ def incr_skips ; mutex.synchronize{ self.skips += 1 }; end
14
+ def add_failure *e ; mutex.synchronize{ failures << e }; end
15
+ def add_error *e ; mutex.synchronize{ errors << e }; end
17
16
  def passed?; failures.size + errors.size == 0 ; end
18
17
  def numbers; [tests, assertions, failures.size, errors.size, skips]; end
19
18
  def report
@@ -25,14 +24,30 @@ module Pork
25
24
  io.printf("%d tests, %d assertions, %d failures, %d errors, %d skips\n",
26
25
  *numbers)
27
26
  end
27
+ def merge stat
28
+ self.class.new(io, start, nil,
29
+ *to_a.drop(3).zip(stat.to_a.drop(3)).map{ |(a, b)| a + b })
30
+ end
28
31
 
29
32
  private
30
33
  def backtrace e
31
34
  if $VERBOSE
32
35
  e.backtrace
33
36
  else
34
- e.backtrace.reject{ |line| line =~ %r{/pork(/\w+)?\.rb:\d+} }
37
+ strip(e.backtrace.reject{ |line| line =~ %r{/pork(/\w+)?\.rb:\d+} })
35
38
  end.join("\n ")
36
39
  end
40
+
41
+ def strip backtrace
42
+ strip_home(strip_cwd(backtrace))
43
+ end
44
+
45
+ def strip_home backtrace
46
+ backtrace.map{ |path| path.sub(ENV['HOME'], '~') }
47
+ end
48
+
49
+ def strip_cwd backtrace
50
+ backtrace.map{ |path| path.sub(Dir.pwd, '.') }
51
+ end
37
52
  end
38
53
  end
data/lib/pork/test.rb CHANGED
@@ -6,7 +6,7 @@ copy do
6
6
  before do
7
7
  Muack::API.stub(Pork::Executor.all_tests).keys.peek_return do |names|
8
8
  names.reject do |n|
9
- n =~ /^Pork::(Isolate|Shuffle|Parallel|Should) /
9
+ n =~ /^Pork::(Isolate|Shuffle|Parallel) /
10
10
  end
11
11
  end
12
12
  end
data/lib/pork/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Pork
3
- VERSION = '1.0.3'
3
+ VERSION = '1.0.4'
4
4
  end
data/pork.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: pork 1.0.3 ruby lib
2
+ # stub: pork 1.0.4 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "pork"
6
- s.version = "1.0.3"
6
+ s.version = "1.0.4"
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 = "2014-12-26"
11
+ s.date = "2014-12-29"
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 = [
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.0.3
4
+ version: 1.0.4
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: 2014-12-26 00:00:00.000000000 Z
11
+ date: 2014-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: muack