micro_test 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -1
- data/lib/micro_test/formatters/mt_async.rb +1 -0
- data/lib/micro_test/runner.rb +23 -16
- data/lib/micro_test/test_wrapper.rb +2 -4
- data/lib/micro_test/version.rb +1 -1
- data/lib/micro_test.rb +0 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -9,7 +9,7 @@ MicroTest avoids this pitfall with a relentless focus on simplicity.
|
|
9
9
|
|
10
10
|
* A simple test API/interface
|
11
11
|
* An awesome test + dev workflow using Pry
|
12
|
-
* Fast asynchronous test runs
|
12
|
+
* Fast asynchronous test runs
|
13
13
|
|
14
14
|
## The Interface
|
15
15
|
|
@@ -99,4 +99,8 @@ Try some of the more advanced features.
|
|
99
99
|
MicroTest is small & unobtrusive. It can run parallel with other test frameworks,
|
100
100
|
and can be introduced to existing projects with minimal effort.
|
101
101
|
|
102
|
+
## Advanced
|
103
|
+
|
104
|
+
[See the wiki](https://github.com/hopsoft/micro_test/wiki) to troubleshoot or dig into more advanced topics.
|
105
|
+
|
102
106
|
Start testing today!
|
data/lib/micro_test/runner.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "os"
|
2
|
+
require "thread"
|
3
|
+
|
1
4
|
module MicroTest
|
2
5
|
class Runner
|
3
6
|
class << self
|
@@ -21,10 +24,10 @@ module MicroTest
|
|
21
24
|
test_classes.each do |test_class|
|
22
25
|
formatter.before_class(test_class)
|
23
26
|
test_class.tests.shuffle.each do |test|
|
24
|
-
stop && exit if MicroTest::Runner.exit
|
25
27
|
@active_test = test
|
26
|
-
if options[:async]
|
27
|
-
|
28
|
+
if @options[:async]
|
29
|
+
@tests ||= Queue.new
|
30
|
+
@tests << test
|
28
31
|
else
|
29
32
|
test.invoke(@formatter, @options)
|
30
33
|
end
|
@@ -32,7 +35,8 @@ module MicroTest
|
|
32
35
|
formatter.after_class(test_class)
|
33
36
|
end
|
34
37
|
|
35
|
-
|
38
|
+
run_threads if @options[:async]
|
39
|
+
|
36
40
|
@duration = Time.now - start
|
37
41
|
@passed = tests.select{ |test| test.passed? }.count
|
38
42
|
@failed = tests.select{ |test| !test.passed? }.count
|
@@ -40,25 +44,28 @@ module MicroTest
|
|
40
44
|
formatter.after_suite(test_classes)
|
41
45
|
end
|
42
46
|
|
43
|
-
def stop
|
44
|
-
MicroTest::Test.subclasses.each do |subclass|
|
45
|
-
subclass.tests.each { |test| test.terminate }
|
46
|
-
end
|
47
|
-
puts
|
48
|
-
sleep 0.5
|
49
|
-
true
|
50
|
-
end
|
51
|
-
|
52
47
|
def reset
|
53
48
|
@duration = 0
|
54
49
|
@passed = 0
|
55
50
|
@failed = 0
|
56
51
|
end
|
57
52
|
|
58
|
-
|
53
|
+
protected
|
59
54
|
|
60
|
-
def
|
61
|
-
|
55
|
+
def run_threads
|
56
|
+
threads = []
|
57
|
+
thread_count = OS.cpu_count
|
58
|
+
thread_count = 2 if thread_count < 2
|
59
|
+
puts "MicroTest is running #{thread_count} threads."
|
60
|
+
thread_count.times do
|
61
|
+
threads << Thread.new do
|
62
|
+
while @tests.empty? == false
|
63
|
+
Thread.current.kill if MicroTest::Runner.exit
|
64
|
+
@tests.pop.invoke(@formatter, @options)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
threads.each { |t| t.join }
|
62
69
|
end
|
63
70
|
|
64
71
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module MicroTest
|
2
2
|
|
3
3
|
# A wrapper class for individual tests.
|
4
|
-
# Exists for the purpose of isolating the test method
|
5
|
-
# Celluloid Actor to support asynchronous test runs.
|
4
|
+
# Exists for the purpose of isolating the test method so it can run in its own thread.
|
6
5
|
class TestWrapper
|
7
|
-
include Celluloid
|
8
6
|
attr_reader :test_class, :desc, :asserts, :duration
|
9
7
|
|
10
8
|
# Constructor.
|
@@ -62,8 +60,8 @@ module MicroTest
|
|
62
60
|
|
63
61
|
if !value
|
64
62
|
binding.pry(:quiet => true) if @options[:pry]
|
63
|
+
|
65
64
|
# I don't really like the coupling to the runner here
|
66
|
-
# but I couldn't get an observer to work with celluloid & pry
|
67
65
|
MicroTest::Runner.exit = true if @options[:fail_fast]
|
68
66
|
end
|
69
67
|
|
data/lib/micro_test/version.rb
CHANGED
data/lib/micro_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micro_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: os
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
description: ! " Simple test API.\n Awesome test/dev workflow with pry.\n Asynchronous
|
31
|
-
test runs
|
31
|
+
test runs.\n What more could you want?\n"
|
32
32
|
email:
|
33
33
|
- natehop@gmail.com
|
34
34
|
executables:
|