pry-test 0.6.0 → 0.6.1
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/bin/pry-test +6 -2
- data/lib/pry-test/formatters/default_async_formatter.rb +1 -1
- data/lib/pry-test/runner.rb +58 -39
- data/lib/pry-test/test.rb +0 -6
- data/lib/pry-test/test_wrapper.rb +3 -18
- data/lib/pry-test/version.rb +1 -1
- data/test/test_test.rb +0 -11
- data/test/test_wrapper_test.rb +0 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6be3ce3aa63e94c3beabb6d47c14c802e069fb7
|
4
|
+
data.tar.gz: 613bd4bc5764a6e2ba508e23d899e39f0549bbe7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ad0f9396749efb2f64d69cb113bd7e6da860b245cb3491b56a9f15222784a80c762dfe7759e6b56ecc102af027f1f05a27464636432a136952ce8db301c1f0e
|
7
|
+
data.tar.gz: d51093a0c22db3918871bbe720a9fc68208c6251aa9bf910b11602244019a77cdbf8ad556719048623c05b845de60821b2915e4620c5a9d58babffb91e10ae49
|
data/bin/pry-test
CHANGED
@@ -86,13 +86,17 @@ include PryTest::Color
|
|
86
86
|
|
87
87
|
options[:disable_pry] = true if options[:async]
|
88
88
|
if options[:disable_pry]
|
89
|
-
puts "
|
89
|
+
puts "Disabling pry #{options.inspect}"
|
90
90
|
exit runner(options).run
|
91
91
|
else
|
92
92
|
require "pry"
|
93
93
|
require "pry-stack_explorer"
|
94
94
|
require "pry-byebug"
|
95
95
|
require "pry-rescue"
|
96
|
-
|
96
|
+
|
97
|
+
Pry.config.hooks.add_hook :before_session, :print_instructions do |_, _, _pry_|
|
98
|
+
PryStackExplorer.frame_manager(_pry_).change_frame_to 1
|
99
|
+
end
|
100
|
+
|
97
101
|
exit Pry.rescue { runner(options).run }
|
98
102
|
end
|
data/lib/pry-test/runner.rb
CHANGED
@@ -13,64 +13,83 @@ module PryTest
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
attr_reader :formatter, :options, :
|
16
|
+
attr_reader :formatter, :options, :duration, :passed, :failed
|
17
17
|
|
18
18
|
def initialize(formatter, options={})
|
19
19
|
@formatter = formatter
|
20
20
|
@options = options
|
21
|
-
reset
|
22
21
|
end
|
23
22
|
|
24
23
|
def run
|
25
|
-
test_classes = PryTest::Test.subclasses.shuffle
|
26
|
-
tests = test_classes.map{ |klass| klass.tests }.flatten
|
27
24
|
formatter.before_suite(test_classes)
|
28
|
-
|
25
|
+
run_test_classes
|
26
|
+
formatter.after_suite(test_classes)
|
27
|
+
failed
|
28
|
+
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
@tests << test
|
38
|
-
else
|
39
|
-
test.invoke(@formatter, @options)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
formatter.after_class(test_class)
|
43
|
-
end
|
44
|
-
end
|
30
|
+
def test_classes
|
31
|
+
@test_classes ||= PryTest::Test.subclasses.shuffle
|
32
|
+
end
|
33
|
+
|
34
|
+
def tests
|
35
|
+
@tests ||= test_classes.map{ |klass| klass.tests }.flatten
|
36
|
+
end
|
45
37
|
|
46
|
-
|
38
|
+
def failed_tests
|
39
|
+
tests.select{ |test| test.invoked? && !test.passed? }
|
40
|
+
end
|
41
|
+
|
42
|
+
def failed
|
43
|
+
failed_tests.length
|
44
|
+
end
|
47
45
|
|
46
|
+
def passed_tests
|
47
|
+
tests.select{ |test| test.invoked? && test.passed? }
|
48
|
+
end
|
49
|
+
|
50
|
+
def passed
|
51
|
+
passed_tests.length
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def run_test_classes
|
57
|
+
start = Time.now
|
58
|
+
queue ||= Queue.new if options[:async]
|
59
|
+
test_classes.each do |test_class|
|
60
|
+
run_test_class test_class, queue
|
61
|
+
end
|
62
|
+
run_threads(queue) if options[:async]
|
48
63
|
@duration = Time.now - start
|
49
|
-
@passed = tests.select{ |test| test.invoked? && test.passed? }.count
|
50
|
-
@failed = tests.select{ |test| test.invoked? && !test.passed? }.count
|
51
64
|
formatter.after_results(self)
|
52
|
-
formatter.after_suite(test_classes)
|
53
|
-
@failed
|
54
65
|
end
|
55
66
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
67
|
+
def run_test_class(test_class, queue)
|
68
|
+
return if PryTest::Runner.terminate?
|
69
|
+
formatter.before_class(test_class)
|
70
|
+
test_class.tests.shuffle.each do |test|
|
71
|
+
if options[:async]
|
72
|
+
queue << test
|
73
|
+
else
|
74
|
+
test.invoke(formatter, options)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
formatter.after_class(test_class)
|
60
78
|
end
|
61
79
|
|
62
|
-
|
80
|
+
def thread_count
|
81
|
+
count = OS.cpu_count
|
82
|
+
count < 2 ? 2 : count
|
83
|
+
end
|
63
84
|
|
64
|
-
def run_threads
|
65
|
-
threads = []
|
66
|
-
thread_count = OS.cpu_count
|
67
|
-
thread_count = 2 if thread_count < 2
|
85
|
+
def run_threads(queue)
|
68
86
|
puts "PryTest is running #{thread_count} threads."
|
69
|
-
thread_count.times do
|
70
|
-
|
71
|
-
while
|
72
|
-
Thread.current.
|
73
|
-
|
87
|
+
threads = thread_count.times.map do
|
88
|
+
Thread.new do
|
89
|
+
while !queue.empty?
|
90
|
+
Thread.current.terminate if PryTest::Runner.terminate?
|
91
|
+
test = queue.pop
|
92
|
+
test.invoke(formatter, options)
|
74
93
|
end
|
75
94
|
end
|
76
95
|
end
|
data/lib/pry-test/test.rb
CHANGED
@@ -34,12 +34,6 @@ module PryTest
|
|
34
34
|
@files ||= {}
|
35
35
|
end
|
36
36
|
|
37
|
-
# Resets the state in preparation for a new test run.
|
38
|
-
def reset
|
39
|
-
tests.each { |test| test.reset }
|
40
|
-
subclasses.each { |subclass| subclass.reset }
|
41
|
-
end
|
42
|
-
|
43
37
|
# A callback provided by Ruby that is invoked whenever a subclass is created.
|
44
38
|
def inherited(subclass)
|
45
39
|
file_path = caller[0][0, caller[0].index(/:[0-9]+:/)]
|
@@ -16,8 +16,8 @@ module PryTest
|
|
16
16
|
super() # inits MonitorMixin
|
17
17
|
@test_class = test_class
|
18
18
|
@desc = desc
|
19
|
+
@asserts = []
|
19
20
|
create_method(:test, &block)
|
20
|
-
reset
|
21
21
|
end
|
22
22
|
|
23
23
|
# Creates a method on this instance.
|
@@ -36,7 +36,6 @@ module PryTest
|
|
36
36
|
# @formatter [PryTest::Formatter] The formatter to use.
|
37
37
|
# @options [Hash]
|
38
38
|
def invoke(formatter, options={})
|
39
|
-
reset
|
40
39
|
@formatter = formatter
|
41
40
|
@options = options
|
42
41
|
@formatter.before_test(self)
|
@@ -44,8 +43,8 @@ module PryTest
|
|
44
43
|
before
|
45
44
|
test
|
46
45
|
@invoked = true
|
47
|
-
after
|
48
46
|
@duration = Time.now - start
|
47
|
+
after
|
49
48
|
@formatter.after_test(self)
|
50
49
|
end
|
51
50
|
|
@@ -63,7 +62,7 @@ module PryTest
|
|
63
62
|
@asserts << assert_info(caller).merge(:value => value)
|
64
63
|
|
65
64
|
if !value
|
66
|
-
Pry.start
|
65
|
+
Pry.start unless @options[:disable_pry]
|
67
66
|
|
68
67
|
# TODO: I don't really like the coupling to the runner here
|
69
68
|
PryTest::Runner.terminate if @options[:fail_fast]
|
@@ -72,12 +71,6 @@ module PryTest
|
|
72
71
|
value
|
73
72
|
end
|
74
73
|
|
75
|
-
# Indicates if this test has finished running.
|
76
|
-
# @return [Boolean]
|
77
|
-
def finished?
|
78
|
-
!@duration.nil?
|
79
|
-
end
|
80
|
-
|
81
74
|
# Indicates if this test has been invoked.
|
82
75
|
# @return [Boolean]
|
83
76
|
def invoked?
|
@@ -92,17 +85,9 @@ module PryTest
|
|
92
85
|
|
93
86
|
# Returns a list of all failed asserts.
|
94
87
|
def failed_asserts
|
95
|
-
return [] if passed?
|
96
88
|
@asserts.select { |a| !a[:value] }
|
97
89
|
end
|
98
90
|
|
99
|
-
# Resets this test in preparation for a clean test run.
|
100
|
-
def reset
|
101
|
-
@invoked = false
|
102
|
-
@asserts = []
|
103
|
-
@duration = nil
|
104
|
-
end
|
105
|
-
|
106
91
|
# Rounded duration.
|
107
92
|
def duration
|
108
93
|
return nil if @duration.nil?
|
data/lib/pry-test/version.rb
CHANGED
data/test/test_test.rb
CHANGED
@@ -39,17 +39,6 @@ unless ENV["PRY_TEST_DEMO"]
|
|
39
39
|
assert @test_test.files[file].select{ |l| l.start_with?(" assert @test_test.files[file].select{ |l| l.start_with?(") }.length > 0
|
40
40
|
end
|
41
41
|
|
42
|
-
test ".reset" do
|
43
|
-
@Example.tests.first.instance_eval do
|
44
|
-
@asserts = nil
|
45
|
-
@duration = nil
|
46
|
-
end
|
47
|
-
@Example.reset
|
48
|
-
assert @Example.tests.length == 1
|
49
|
-
assert @Example.tests.first.asserts == []
|
50
|
-
assert @Example.tests.first.duration == nil
|
51
|
-
end
|
52
|
-
|
53
42
|
test ".before" do
|
54
43
|
assert @Example.instance_eval { @before } == @before_callback
|
55
44
|
end
|
data/test/test_wrapper_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: binding_of_caller
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: os
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|