pork 1.5.0 → 2.1.0
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 +5 -5
- data/.gitlab-ci.yml +40 -0
- data/.gitmodules +1 -1
- data/CHANGES.md +41 -0
- data/Gemfile +0 -4
- data/README.md +63 -18
- data/Rakefile +5 -4
- data/TODO.md +0 -2
- data/lib/pork/api.rb +35 -0
- data/lib/pork/env.rb +1 -1
- data/lib/pork/executor.rb +24 -10
- data/lib/pork/extra/show_source.rb +21 -2
- data/lib/pork/isolator.rb +145 -0
- data/lib/pork/mode/parallel.rb +6 -7
- data/lib/pork/mode/sequential.rb +5 -5
- data/lib/pork/mode/shuffled.rb +5 -5
- data/lib/pork/more/bottomup_backtrace.rb +0 -2
- data/lib/pork/more/color.rb +0 -2
- data/lib/pork/more/should.rb +9 -9
- data/lib/pork/report/description.rb +7 -7
- data/lib/pork/report/progressbar.rb +1 -2
- data/lib/pork/report.rb +17 -13
- data/lib/pork/runner.rb +54 -0
- data/lib/pork/stat.rb +1 -1
- data/lib/pork/suite.rb +74 -0
- data/lib/pork/version.rb +1 -1
- data/lib/pork.rb +10 -18
- data/pork.gemspec +23 -23
- data/task/README.md +8 -8
- data/task/gemgem.rb +32 -8
- data/test/test_around.rb +64 -0
- data/test/test_bacon.rb +7 -6
- data/test/test_isolator.rb +29 -0
- data/test/test_meta.rb +40 -0
- data/test/test_nested.rb +24 -1
- data/test/test_pork_test.rb +29 -26
- data/test/test_readme.rb +6 -2
- data/test/test_stat.rb +19 -17
- data/test/test_suite.rb +10 -0
- metadata +20 -11
- data/.travis.yml +0 -15
- data/lib/pork/imp.rb +0 -88
- data/lib/pork/isolate.rb +0 -98
data/lib/pork/isolate.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
|
2
|
-
module Pork
|
3
|
-
module Isolate
|
4
|
-
def all_tests
|
5
|
-
@all_tests ||= build_all_tests
|
6
|
-
end
|
7
|
-
|
8
|
-
def all_paths
|
9
|
-
(all_tests[:files] || {}).values.flat_map(&:values).flatten(1).uniq
|
10
|
-
end
|
11
|
-
|
12
|
-
def [] index
|
13
|
-
by_groups(index) || by_source(index)
|
14
|
-
end
|
15
|
-
|
16
|
-
def by_groups groups
|
17
|
-
return unless tests = all_tests[:groups]
|
18
|
-
paths = groups.split(',').flat_map do |g|
|
19
|
-
tests[g.strip] || []
|
20
|
-
end.uniq
|
21
|
-
paths unless paths.empty?
|
22
|
-
end
|
23
|
-
|
24
|
-
def by_source source
|
25
|
-
return unless tests = all_tests[:files]
|
26
|
-
file_str, line_str = source.split(':')
|
27
|
-
file, line = File.expand_path(file_str), line_str.to_i
|
28
|
-
return unless cases = tests[file]
|
29
|
-
if line.zero?
|
30
|
-
cases.values.flatten(1).uniq
|
31
|
-
else
|
32
|
-
_, paths = cases.reverse_each.find{ |(l, _)| l <= line }
|
33
|
-
paths
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
def isolate stat, path, super_env=nil
|
39
|
-
env = Env.new(super_env)
|
40
|
-
idx = path.first
|
41
|
-
|
42
|
-
@tests.first(idx).each do |(type, arg, _)|
|
43
|
-
case type
|
44
|
-
when :before
|
45
|
-
env.before << arg
|
46
|
-
when :after
|
47
|
-
env.after << arg
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
if path.size == 1
|
52
|
-
_, desc, test = @tests[idx]
|
53
|
-
run(stat, desc, test, env)
|
54
|
-
else
|
55
|
-
@tests[idx][1].isolate(stat, path.drop(1), env)
|
56
|
-
end
|
57
|
-
|
58
|
-
stat
|
59
|
-
end
|
60
|
-
|
61
|
-
def build_all_tests result={}, path=[]
|
62
|
-
@tests.each_with_index.inject(result) do |r,
|
63
|
-
((type, imp, test, opts),
|
64
|
-
index)|
|
65
|
-
current = path + [index]
|
66
|
-
|
67
|
-
case type
|
68
|
-
when :describe
|
69
|
-
imp.build_all_tests(r, current) do |nested|
|
70
|
-
store_path(r, nested, test, opts[:groups])
|
71
|
-
end
|
72
|
-
when :would
|
73
|
-
yield(current) if block_given?
|
74
|
-
store_path(r, current, test, opts[:groups])
|
75
|
-
end
|
76
|
-
|
77
|
-
r
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def store_path tests, path, test, groups
|
82
|
-
store_for_groups(tests, path, groups) if groups
|
83
|
-
store_for_source(tests, path, *test.source_location)
|
84
|
-
end
|
85
|
-
|
86
|
-
def store_for_groups tests, path, groups
|
87
|
-
r = tests[:groups] ||= {}
|
88
|
-
groups.each do |g|
|
89
|
-
(r[g.to_s] ||= []) << path
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def store_for_source tests, path, file, line
|
94
|
-
r = tests[:files] ||= {}
|
95
|
-
((r[File.expand_path(file)] ||= {})[line] ||= []) << path
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|