pork 1.1.3 → 1.2.0

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: 67d12f898ed53bc341734b4a53f3571e158eed58
4
- data.tar.gz: 5930a1821b4ec2bd8bad6d0168baf26561a2edbb
3
+ metadata.gz: b274b6a156004d552304773fb69e973bfaf353d8
4
+ data.tar.gz: 82f04565402f03bd35384c40360d5620dc38459f
5
5
  SHA512:
6
- metadata.gz: 2839c6e48efb8957c9abb05e83f61f0458de4e85e0db11ad5d3b0854891eadcbdfe5b665dc60182b6bf1e5d47c09e670167b4d71d1fcb808977eabc4c63bef2f
7
- data.tar.gz: 0fc345ebec361a78a0ba7fba004194197a25f3508ce5d7f70b215a059990ef53581354dff2ce686c1c1c1b922a034bbf24160629e76a16dd514b9f7b20430a15
6
+ metadata.gz: 97dfb60738d88e33cee54ac7bd5a4795b4fa9c17faad1438f4a272e21105ceab1cfa26a945b041c86f45295a8fcf634d7c476d88c268c1811b4acd34165cd379
7
+ data.tar.gz: 67e6724a57b7d0fec805d1f89123c57f61810207f06301c9f5ae5c7d7f7d3173a463e073e8da5269ff2a8973222fe5cffb1e31ea8640f8ad0e58642536470367
data/CHANGES.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # CHANGES
2
2
 
3
+ ## Pork 1.2.0 -- 2015-03-17
4
+
5
+ ### Incompatible changes
6
+
7
+ * Mutant integration is removed for now. Please let me know if it could
8
+ be integrated without a problem.
9
+ * Default mode changed to `:shuffled`, and the original mode renamed to
10
+ `:sequential`.
11
+ * Running individual test changed from description to file:line_number.
12
+ Input from @mz026
13
+
14
+ ### Enhancement
15
+
16
+ * Paths in backtrace would no longer use `.` to indicate current directory.
17
+ Some editor such as Sublime didn't like it.
18
+
3
19
  ## Pork 1.1.3 -- 2015-02-04
4
20
 
5
21
  * Fixed exit status.
data/README.md CHANGED
@@ -784,23 +784,22 @@ Pork.autorun(true) # enable
784
784
 
785
785
  ### Pork.execute_mode
786
786
 
787
- By default, `Pork.execute_mode` is set to `:execute`, which would
788
- execute all tests in a sequential manner. The other options are:
787
+ By default, `Pork.execute_mode` is set to `:shuffled` which would execute
788
+ all tests in a random order. The other options are:
789
789
 
790
- * `:execute` (default)
791
- * `:shuffle`
790
+ * `:shuffled` (default)
791
+ * `:sequential`
792
792
  * `:parallel`
793
793
 
794
- With `:shuffle`, it would execute all tests in a random order. It would be
795
- slightly slower than `:execute`. With `:parallel`, it would run tests with
796
- 8 threads concurrently, and of course, the orders are all random as well.
797
- You'll need to make sure your tests are thread safe or random tests would
798
- fail with this mode.
794
+ With `:sequential`, it would execute all tests in a sequential manner.
795
+ With `:parallel`, it would run tests with 8 threads concurrently, and of
796
+ course, the orders are all random as well. You'll need to make sure your
797
+ tests are thread safe or random tests would fail with this mode.
799
798
 
800
799
  Pass the symbol to it to use the mode:
801
800
 
802
801
  ``` ruby
803
- Pork.execute_mode :shuffle
802
+ Pork.execute_mode :parallel
804
803
  ```
805
804
 
806
805
  On the other hand, you could also set `ENV['PORK_MODE']` for picking an
@@ -808,13 +807,13 @@ execution mode. This would be convenient if you just want to switch to a
808
807
  particular mode temporary via command line. For example:
809
808
 
810
809
  ``` shell
811
- env PORK_MODE=shuffle rake test
810
+ env PORK_MODE=parallel rake test
812
811
  ```
813
812
 
814
813
  Or:
815
814
 
816
815
  ``` shell
817
- env PORK_MODE=shuffle ruby -Ilib test/test_pork.rb
816
+ env PORK_MODE=parallel ruby -Ilib test/test_pork.rb
818
817
  ```
819
818
 
820
819
  ### Pork.inspect_failure_mode
data/TODO.md CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
- * remove sequential tests
3
2
  * introduce configs
4
3
  * plugin: color/reverse backtrace, replicating command, inspect mode
4
+ * executable
5
+ * if it's executing from a copy block, run all pasted blocks
data/lib/pork.rb CHANGED
@@ -12,9 +12,9 @@ module Pork
12
12
  def would desc=:default, &test ; Executor.would( desc, &test ); end
13
13
  end
14
14
 
15
- # default to :execute while eliminating warnings for uninitialized ivar
15
+ # default to :shuffled while eliminating warnings for uninitialized ivar
16
16
  def self.execute_mode execute=nil
17
- @execute = execute || @execute ||= :execute
17
+ @execute = execute || @execute ||= :shuffled
18
18
  end
19
19
 
20
20
  def self.Rainbows!
@@ -43,21 +43,18 @@ module Pork
43
43
  end
44
44
 
45
45
  def self.run
46
+ Random.srand(ENV['PORK_SEED'].to_i) if ENV['PORK_SEED']
47
+ seed
46
48
  if ENV['PORK_TEST']
47
- require 'pork/isolate'
48
- if paths = Executor.all_tests[ENV['PORK_TEST']]
49
- case execute_mode
50
- when :execute
51
- paths.each{ |p| Executor.isolate(p, stat) }
52
- else
53
- @stat = Executor.public_send(execute_mode, stat, paths)
54
- end
49
+ require 'pork/mode/shuffled'
50
+ if paths = Executor[ENV['PORK_TEST']]
51
+ @stat = Executor.execute(Pork.execute_mode, stat, paths)
55
52
  else
56
53
  puts "Cannot find test: #{ENV['PORK_TEST']}"
57
54
  exit 254
58
55
  end
59
56
  else
60
- @stat = Executor.public_send(execute_mode, stat)
57
+ @stat = Executor.execute(Pork.execute_mode, stat)
61
58
  end
62
59
  end
63
60
 
@@ -65,10 +62,7 @@ module Pork
65
62
  @auto = auto
66
63
  @autorun ||= at_exit do
67
64
  next unless @auto
68
- Random.srand(ENV['PORK_SEED'].to_i) if ENV['PORK_SEED']
69
- execute_mode(ENV['PORK_MODE'].to_sym) if ENV['PORK_MODE']
70
- require "pork/mode/#{execute_mode}" if execute_mode != :execute
71
- seed
65
+ execute_mode(ENV['PORK_MODE'])
72
66
  trap
73
67
  run
74
68
  stat.report
data/lib/pork/auto.rb CHANGED
@@ -1,6 +1,5 @@
1
1
 
2
2
  require 'pork'
3
- require 'pork/should'
4
3
  require 'pork/more'
5
4
  extend Pork::API
6
5
  Pork.autorun
data/lib/pork/imp.rb CHANGED
@@ -28,13 +28,13 @@ module Pork
28
28
  @tests << [:would, desc, test]
29
29
  end
30
30
 
31
- def execute stat=Stat.new
32
- if block_given?
33
- yield(stat) # XXX: see Isolate#isolate
34
- else
35
- execute_with_parent(stat)
31
+ def execute mode, *args
32
+ require "pork/mode/#{mode}"
33
+ if args.size == 1 || mode.to_s != 'sequential'
34
+ send(mode, *args)
35
+ else # cannot run sequential tests for specific paths
36
+ shuffled(*args)
36
37
  end
37
- stat
38
38
  end
39
39
 
40
40
  private
@@ -46,7 +46,7 @@ module Pork
46
46
  def run desc, test, stat, env
47
47
  assertions = stat.assertions
48
48
  context = new(stat)
49
- run_protected(desc, stat) do
49
+ run_protected(desc, stat, test) do
50
50
  env.run_before(context)
51
51
  context.instance_eval(&test)
52
52
  if assertions == stat.assertions
@@ -56,42 +56,30 @@ module Pork
56
56
  end
57
57
  ensure
58
58
  stat.incr_tests
59
- run_protected(desc, stat){ env.run_after(context) }
59
+ run_protected(desc, stat, test){ env.run_after(context) }
60
60
  end
61
61
 
62
- def run_protected desc, stat
62
+ def run_protected desc, stat, test
63
63
  yield
64
64
  rescue Error, StandardError => e
65
65
  case e
66
66
  when Skip
67
67
  stat.incr_skips
68
68
  stat.case_skip
69
- when Failure
70
- stat.add_failure(e, description_for("would #{desc}"))
71
- stat.case_failed
72
- when Error, StandardError
73
- stat.add_error( e, description_for("would #{desc}"))
74
- stat.case_errored
75
- end
76
- end
77
-
78
- protected
79
- def execute_with_parent stat, super_env=nil
80
- env = Env.new(super_env)
81
- @tests.each do |(type, arg, test)|
82
- case type
83
- when :before
84
- env.before << arg
85
- when :after
86
- env.after << arg
87
- when :describe
88
- arg.execute_with_parent(stat, env)
89
- when :would
90
- run(arg, test, stat, env)
69
+ else
70
+ err = [e, description_for("would #{desc}"), test.source_location]
71
+ case e
72
+ when Failure
73
+ stat.add_failure(err)
74
+ stat.case_failed
75
+ when Error, StandardError
76
+ stat.add_error(err)
77
+ stat.case_errored
91
78
  end
92
79
  end
93
80
  end
94
81
 
82
+ protected
95
83
  def search_stash desc
96
84
  @stash[desc] or @super_executor && @super_executor.search_stash(desc)
97
85
  end
@@ -1,6 +1,5 @@
1
1
 
2
- require 'pork'
3
- require 'pork/isolate'
2
+ require 'pork/mode/shuffled'
4
3
 
5
4
  module Pork
6
5
  module Parallel
@@ -8,12 +7,10 @@ module Pork
8
7
  8
9
8
  end
10
9
 
11
- def parallel stat=Stat.new, paths=all_tests.values.flatten(1)
10
+ def parallel stat=Stat.new, paths=all_paths
12
11
  paths.shuffle.each_slice(cores).map do |paths_slice|
13
12
  Thread.new do
14
- s = Stat.new
15
- paths_slice.each{ |p| isolate(p, s) }
16
- s
13
+ execute(:shuffled, Stat.new, paths_slice)
17
14
  end
18
15
  end.map(&:value).inject(stat, &:merge)
19
16
  end
@@ -0,0 +1,26 @@
1
+
2
+ require 'pork'
3
+
4
+ module Pork
5
+ module Sequential
6
+ def sequential stat=Stat.new, super_env=nil
7
+ env = Env.new(super_env)
8
+ @tests.each do |(type, arg, test)|
9
+ case type
10
+ when :before
11
+ env.before << arg
12
+ when :after
13
+ env.after << arg
14
+ when :describe
15
+ arg.sequential(stat, env)
16
+ when :would
17
+ run(arg, test, stat, env)
18
+ end
19
+ end
20
+
21
+ stat
22
+ end
23
+ end
24
+
25
+ Executor.extend(Sequential)
26
+ end
@@ -1,38 +1,30 @@
1
1
 
2
2
  require 'pork'
3
- require 'pork/executor'
4
3
 
5
4
  module Pork
6
- module Isolate
5
+ module Shuffled
7
6
  def all_tests
8
7
  @all_tests ||= build_all_tests
9
8
  end
10
9
 
11
- def isolate path, stat=Stat.new
12
- # XXX: 91152211182a086de20e3e84c96b6befca655975
13
- # Executor.execute is a no-op when Should is not loaded,
14
- # but if it's loaded, it's essential to call Should#execute to
15
- # setup the stat in thread group. Try to come up a better way!
16
- execute(stat) do |s|
17
- execute_with_isolation(path, s)
18
- end
10
+ def all_paths
11
+ all_tests.values.flat_map(&:values).flatten(1)
19
12
  end
20
13
 
21
- protected
22
- def build_all_tests result={}, path=[]
23
- @tests.each_with_index.inject(result) do |r, ((type, arg, _), index)|
24
- current = path + [index]
25
- case type
26
- when :describe
27
- arg.build_all_tests(r, current)
28
- when :would
29
- (r[description_for("would #{arg}")] ||= []) << current
30
- end
31
- r
32
- end
14
+ def [] source_location
15
+ file_str, line_str = source_location.split(':')
16
+ file, line = File.expand_path(file_str), line_str.to_i
17
+ return unless tests = all_tests[file]
18
+ _, paths = tests.reverse_each.find{ |(l, _)| l <= line }
19
+ paths
20
+ end
21
+
22
+ def shuffled stat=Stat.new, paths=all_paths
23
+ paths.shuffle.inject(stat, &method(:isolate))
33
24
  end
34
25
 
35
- def execute_with_isolation path, stat, super_env=nil
26
+ protected
27
+ def isolate stat, path, super_env=nil
36
28
  env = Env.new(super_env)
37
29
  idx = path.first
38
30
 
@@ -49,10 +41,26 @@ module Pork
49
41
  _, desc, test = @tests[idx]
50
42
  run(desc, test, stat, env)
51
43
  else
52
- @tests[idx][1].execute_with_isolation(path.drop(1), stat, env)
44
+ @tests[idx][1].isolate(stat, path.drop(1), env)
45
+ end
46
+
47
+ stat
48
+ end
49
+
50
+ def build_all_tests result={}, path=[]
51
+ @tests.each_with_index.inject(result) do |r, ((type, arg, test), index)|
52
+ current = path + [index]
53
+ case type
54
+ when :describe
55
+ arg.build_all_tests(r, current)
56
+ when :would
57
+ loc = test.source_location
58
+ ((r[loc.first] ||= {})[loc.last] ||= []) << current
59
+ end
60
+ r
53
61
  end
54
62
  end
55
63
  end
56
64
 
57
- Executor.extend(Isolate)
65
+ Executor.extend(Shuffled)
58
66
  end
data/lib/pork/more.rb CHANGED
@@ -1,8 +1,4 @@
1
1
 
2
- require 'pork/stat'
3
-
4
2
  require 'pork/more/bottomup_backtrace'
5
3
  require 'pork/more/color'
6
-
7
- Pork::Stat.__send__(:include, Pork::BottomupBacktrace)
8
- Pork::Stat.__send__(:include, Pork::Color)
4
+ require 'pork/more/should'
@@ -1,4 +1,6 @@
1
1
 
2
+ require 'pork/stat'
3
+
2
4
  module Pork
3
5
  module BottomupBacktrace
4
6
  private
@@ -6,4 +8,6 @@ module Pork
6
8
  super.reverse
7
9
  end
8
10
  end
11
+
12
+ Pork::Stat.__send__(:include, Pork::BottomupBacktrace)
9
13
  end
@@ -1,4 +1,6 @@
1
1
 
2
+ require 'pork/stat'
3
+
2
4
  module Pork
3
5
  module Color
4
6
  def case_skip msg='s'; super(yellow {msg}); end
@@ -56,4 +58,6 @@ module Pork
56
58
  "\e[#{rgb}m#{yield}\e[0m"
57
59
  end
58
60
  end
61
+
62
+ Pork::Stat.__send__(:include, Pork::Color)
59
63
  end
@@ -10,12 +10,12 @@ end
10
10
 
11
11
  module Pork
12
12
  module Should
13
- def execute stat=Stat.new
13
+ def execute mode, stat=Stat.new, *args
14
14
  thread = Thread.current
15
15
  original_group, group = thread.group, ThreadGroup.new
16
16
  group.add(thread)
17
17
  thread[:pork_stat] = stat
18
- super
18
+ super(mode, stat, *args)
19
19
  ensure
20
20
  original_group.add(thread)
21
21
  end
data/lib/pork/stat.rb CHANGED
@@ -14,13 +14,13 @@ module Pork
14
14
  def incr_assertions; mutex.synchronize{ self.assertions += 1 }; end
15
15
  def incr_tests ; mutex.synchronize{ self.tests += 1 }; end
16
16
  def incr_skips ; mutex.synchronize{ self.skips += 1 }; end
17
- def add_failure *err
17
+ def add_failure err
18
18
  mutex.synchronize do
19
19
  self.failures += 1
20
20
  exceptions << err
21
21
  end
22
22
  end
23
- def add_error *err
23
+ def add_error err
24
24
  mutex.synchronize do
25
25
  self.errors += 1
26
26
  exceptions << err
@@ -41,26 +41,26 @@ module Pork
41
41
  *numbers)
42
42
  end
43
43
  def merge stat
44
- self.class.new(io, start, nil,
44
+ self.class.new(io, start, mutex,
45
45
  *to_a.drop(3).zip(stat.to_a.drop(3)).map{ |(a, b)| a + b })
46
46
  end
47
47
 
48
48
  private
49
49
  def report_exceptions
50
- exceptions.reverse.map do |(err, msg)|
51
- "\n #{show_command(msg)}" \
50
+ exceptions.reverse_each.map do |(err, msg, source_location)|
51
+ "\n #{show_command(source_location)}" \
52
52
  "\n #{show_backtrace(err)}" \
53
53
  "\n#{message(msg)}" \
54
54
  "\n#{show_exception(err)}"
55
55
  end
56
56
  end
57
57
 
58
- def show_command name
59
- "Replicate this test with:\n#{command(name)}"
58
+ def show_command source_location
59
+ "Replicate this test with:\n#{command(source_location)}"
60
60
  end
61
61
 
62
- def command name
63
- "#{env(name)} #{Gem.ruby} -S #{$0} #{ARGV.join(' ')}"
62
+ def command source_location
63
+ "#{env(source_location)} #{Gem.ruby} -S #{$0} #{ARGV.join(' ')}"
64
64
  end
65
65
 
66
66
  def show_backtrace err
@@ -92,15 +92,16 @@ module Pork
92
92
  end
93
93
 
94
94
  def strip_cwd bt
95
- bt.map{ |path| path.sub(Dir.pwd, '.') }
95
+ bt.map{ |path| path.sub("#{Dir.pwd}/", '') }
96
96
  end
97
97
 
98
- def env name
99
- "env #{pork(name)} #{pork_mode} #{pork_seed}"
98
+ def env source_location
99
+ "env #{pork(source_location)} #{pork_mode} #{pork_seed}"
100
100
  end
101
101
 
102
- def pork name
103
- "PORK_TEST='#{name.gsub("'", "\\\\'")}'"
102
+ def pork source_location
103
+ file, line = source_location
104
+ "PORK_TEST='#{strip([file]).join}:#{line}'"
104
105
  end
105
106
 
106
107
  def pork_mode
data/lib/pork/test.rb CHANGED
@@ -1,17 +1,18 @@
1
1
 
2
2
  require 'pork/auto'
3
- require 'muack'
4
3
 
5
- copy do
6
- before do
7
- Muack::API.stub(Pork::Executor).all_tests.peek_return do |tests|
8
- tests.reject do |name, _|
9
- name =~ /^Pork::(Isolate|Shuffle|Parallel): /
10
- end
11
- end
12
- end
4
+ Pork.autorun(false)
13
5
 
14
- after do
15
- Muack.reset
6
+ at_exit do
7
+ Pork.module_eval do
8
+ execute_mode(ENV['PORK_MODE'])
9
+ trap
10
+ run
11
+ %w[sequential shuffled parallel].each do |mode|
12
+ execute_mode(mode)
13
+ run
14
+ end
15
+ stat.report
16
+ exit stat.failures + stat.errors + ($! && 1).to_i
16
17
  end
17
18
  end
data/lib/pork/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Pork
3
- VERSION = '1.1.3'
3
+ VERSION = '1.2.0'
4
4
  end
data/pork.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: pork 1.1.3 ruby lib
2
+ # stub: pork 1.2.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "pork"
6
- s.version = "1.1.3"
6
+ s.version = "1.2.0"
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-02-04"
11
+ s.date = "2015-03-17"
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 = [
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
21
21
  "README.md",
22
22
  "Rakefile",
23
23
  "TODO.md",
24
- "lib/mutant/integration/pork.rb",
25
24
  "lib/pork.rb",
26
25
  "lib/pork/auto.rb",
27
26
  "lib/pork/context.rb",
@@ -32,13 +31,13 @@ Gem::Specification.new do |s|
32
31
  "lib/pork/extra/rainbows.rb",
33
32
  "lib/pork/imp.rb",
34
33
  "lib/pork/inspect.rb",
35
- "lib/pork/isolate.rb",
36
34
  "lib/pork/mode/parallel.rb",
37
- "lib/pork/mode/shuffle.rb",
35
+ "lib/pork/mode/sequential.rb",
36
+ "lib/pork/mode/shuffled.rb",
38
37
  "lib/pork/more.rb",
39
38
  "lib/pork/more/bottomup_backtrace.rb",
40
39
  "lib/pork/more/color.rb",
41
- "lib/pork/should.rb",
40
+ "lib/pork/more/should.rb",
42
41
  "lib/pork/stat.rb",
43
42
  "lib/pork/test.rb",
44
43
  "lib/pork/version.rb",
@@ -47,25 +46,19 @@ Gem::Specification.new do |s|
47
46
  "task/gemgem.rb",
48
47
  "test/test_bacon.rb",
49
48
  "test/test_inspect.rb",
50
- "test/test_isolate.rb",
51
49
  "test/test_nested.rb",
52
- "test/test_parallel.rb",
53
50
  "test/test_readme.rb",
54
- "test/test_should.rb",
55
- "test/test_shuffle.rb"]
51
+ "test/test_should.rb"]
56
52
  s.homepage = "https://github.com/godfat/pork"
57
53
  s.licenses = ["Apache License 2.0"]
58
- s.rubygems_version = "2.4.5"
54
+ s.rubygems_version = "2.4.6"
59
55
  s.summary = "Pork -- Simple and clean and modular testing library."
60
56
  s.test_files = [
61
57
  "test/test_bacon.rb",
62
58
  "test/test_inspect.rb",
63
- "test/test_isolate.rb",
64
59
  "test/test_nested.rb",
65
- "test/test_parallel.rb",
66
60
  "test/test_readme.rb",
67
- "test/test_should.rb",
68
- "test/test_shuffle.rb"]
61
+ "test/test_should.rb"]
69
62
 
70
63
  if s.respond_to? :specification_version then
71
64
  s.specification_version = 4
data/task/gemgem.rb CHANGED
@@ -100,9 +100,12 @@ module Gemgem
100
100
  if ENV['COV'] || ENV['CI']
101
101
  require 'simplecov'
102
102
  if ENV['CI']
103
- require 'coveralls'
104
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
105
- SimpleCov.command_name('pork')
103
+ begin
104
+ require 'coveralls'
105
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
106
+ rescue LoadError => e
107
+ puts "Cannot load coveralls, skip: #{e}"
108
+ end
106
109
  end
107
110
  SimpleCov.start do
108
111
  add_filter('test/')
data/test/test_bacon.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- require 'pork/auto'
2
+ require 'pork/test'
3
3
 
4
4
  describe Pork do
5
5
  # Hooray for meta-testing.
data/test/test_inspect.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- require 'pork/auto'
2
+ require 'pork/test'
3
3
 
4
4
  describe Pork::Inspect do
5
5
  would 'hash' do
data/test/test_nested.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- require 'pork/auto'
2
+ require 'pork/test'
3
3
 
4
4
  describe 'A' do
5
5
  include Module.new{
data/test/test_readme.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- require 'pork/auto'
2
+ require 'pork/test'
3
3
  require 'uri'
4
4
 
5
5
  describe 'README.md' do
data/test/test_should.rb CHANGED
@@ -1,6 +1,5 @@
1
1
 
2
- require 'pork/auto'
3
- require 'pork/should'
2
+ require 'pork/test'
4
3
 
5
4
  describe Pork::Should do
6
5
  def check_group_list level=9
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.1.3
4
+ version: 1.2.0
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-02-04 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: muack
@@ -45,7 +45,6 @@ files:
45
45
  - README.md
46
46
  - Rakefile
47
47
  - TODO.md
48
- - lib/mutant/integration/pork.rb
49
48
  - lib/pork.rb
50
49
  - lib/pork/auto.rb
51
50
  - lib/pork/context.rb
@@ -56,13 +55,13 @@ files:
56
55
  - lib/pork/extra/rainbows.rb
57
56
  - lib/pork/imp.rb
58
57
  - lib/pork/inspect.rb
59
- - lib/pork/isolate.rb
60
58
  - lib/pork/mode/parallel.rb
61
- - lib/pork/mode/shuffle.rb
59
+ - lib/pork/mode/sequential.rb
60
+ - lib/pork/mode/shuffled.rb
62
61
  - lib/pork/more.rb
63
62
  - lib/pork/more/bottomup_backtrace.rb
64
63
  - lib/pork/more/color.rb
65
- - lib/pork/should.rb
64
+ - lib/pork/more/should.rb
66
65
  - lib/pork/stat.rb
67
66
  - lib/pork/test.rb
68
67
  - lib/pork/version.rb
@@ -71,12 +70,9 @@ files:
71
70
  - task/gemgem.rb
72
71
  - test/test_bacon.rb
73
72
  - test/test_inspect.rb
74
- - test/test_isolate.rb
75
73
  - test/test_nested.rb
76
- - test/test_parallel.rb
77
74
  - test/test_readme.rb
78
75
  - test/test_should.rb
79
- - test/test_shuffle.rb
80
76
  homepage: https://github.com/godfat/pork
81
77
  licenses:
82
78
  - Apache License 2.0
@@ -97,16 +93,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
93
  version: '0'
98
94
  requirements: []
99
95
  rubyforge_project:
100
- rubygems_version: 2.4.5
96
+ rubygems_version: 2.4.6
101
97
  signing_key:
102
98
  specification_version: 4
103
99
  summary: Pork -- Simple and clean and modular testing library.
104
100
  test_files:
105
101
  - test/test_bacon.rb
106
102
  - test/test_inspect.rb
107
- - test/test_isolate.rb
108
103
  - test/test_nested.rb
109
- - test/test_parallel.rb
110
104
  - test/test_readme.rb
111
105
  - test/test_should.rb
112
- - test/test_shuffle.rb
@@ -1,76 +0,0 @@
1
-
2
- require 'pork'
3
- require 'pork/isolate'
4
- require 'stringio'
5
-
6
- module Mutant
7
- class Integration
8
- class Pork < self
9
- register 'pork'
10
-
11
- # Return integration compatible to currently loaded pork
12
- #
13
- # @return [Integration]
14
- #
15
- # @api private
16
- #
17
- def self.build
18
- new
19
- end
20
-
21
- # Setup pork integration
22
- #
23
- # @return [self]
24
- #
25
- # @api private
26
- #
27
- def setup
28
- Dir['test/**/test_*.rb'].each do |path|
29
- require "./#{path}"
30
- end
31
- ::Pork.autorun(false)
32
- self
33
- end
34
- memoize :setup
35
-
36
- # Return report for test
37
- #
38
- # @param [Pork::Test] test
39
- #
40
- # @return [Test::Result]
41
- #
42
- # @api private
43
- #
44
- # rubocop:disable MethodLength
45
- #
46
- def run(test)
47
- stat = ::Pork::Executor.isolate(test.expression.syntax,
48
- ::Pork::Stat.new(StringIO.new))
49
-
50
- Result::Test.new(
51
- test: nil,
52
- mutation: nil,
53
- output: stat.io.string,
54
- runtime: Time.now - stat.start,
55
- passed: stat.passed?
56
- )
57
- end
58
-
59
- # Return all available tests
60
- #
61
- # @return [Enumerable<Test>]
62
- #
63
- # @api private
64
- #
65
- def all_tests
66
- ::Pork::Executor.all_tests.keys.inject([]) do |tests, description|
67
- expression = Expression.try_parse(description) or next tests
68
- tests << Test.new(self, expression)
69
- end
70
- end
71
- memoize :all_tests
72
-
73
- end # Pork
74
-
75
- end # Integration
76
- end # Mutant
@@ -1,16 +0,0 @@
1
-
2
- require 'pork'
3
- require 'pork/isolate'
4
-
5
- module Pork
6
- module Shuffle
7
- def shuffle stat=Stat.new, paths=all_tests.values.flatten(1)
8
- paths.shuffle.each do |p|
9
- isolate(p, stat)
10
- end
11
- stat
12
- end
13
- end
14
-
15
- Executor.extend(Shuffle)
16
- end
data/test/test_isolate.rb DELETED
@@ -1,15 +0,0 @@
1
-
2
- require 'pork/auto'
3
- require 'pork/isolate'
4
-
5
- describe Pork::Isolate do
6
- would '#isolate' do
7
- Pork::Executor.all_tests.each do |name, paths|
8
- next ok if name.start_with?('Pork::Isolate: would #isolate')
9
- paths.each do |p|
10
- stat = Pork::Executor.isolate(p, pork_stat)
11
- expect(stat.passed?, stat.inspect).eq true
12
- end
13
- end
14
- end
15
- end
@@ -1,12 +0,0 @@
1
-
2
- require 'pork/test'
3
- require 'pork/mode/parallel'
4
-
5
- describe Pork::Parallel do
6
- paste
7
-
8
- would '#parallel' do
9
- stat = Pork::Executor.parallel(pork_stat)
10
- expect(stat.passed?, stat.inspect).eq true
11
- end
12
- end
data/test/test_shuffle.rb DELETED
@@ -1,12 +0,0 @@
1
-
2
- require 'pork/test'
3
- require 'pork/mode/shuffle'
4
-
5
- describe Pork::Shuffle do
6
- paste
7
-
8
- would '#shuffle' do
9
- stat = Pork::Executor.shuffle(pork_stat)
10
- expect(stat.passed?, stat.inspect).eq true
11
- end
12
- end