baretest 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,7 +40,6 @@ lib/baretest/run.rb
40
40
  lib/baretest/run/cli.rb
41
41
  lib/baretest/run/minimal.rb
42
42
  lib/baretest/run/none.rb
43
- lib/baretest/run/profile.rb
44
43
  lib/baretest/run/spec.rb
45
44
  lib/baretest/run/tap.rb
46
45
  lib/baretest/run/xml.rb
@@ -84,14 +84,14 @@ module BareTest
84
84
 
85
85
  # Enure that the suite is run wiht a minimal version of baretest
86
86
  def self.require_baretest(version)
87
- if (version.split(".").map { |s| s.to_i } <=> BareTest::VERSION.to_a) == 0 then
87
+ if (version.split(".").map { |s| s.to_i } <=> BareTest::VERSION.to_a) > 0 then
88
88
  abort "Requires baretest version #{version}, you have #{BareTest::VERSION}"
89
89
  end
90
90
  end
91
91
 
92
92
  # Ensure that the suite is run with a minimal version of ruby
93
93
  def self.require_ruby(version)
94
- if (version.split(".").map { |s| s.to_i } <=> RUBY_VERSION.split(".").map { |s| s.to_i }) == 1 then
94
+ if (version.split(".").map { |s| s.to_i } <=> RUBY_VERSION.split(".").map { |s| s.to_i }) > 0 then
95
95
  abort "Requires ruby version #{version}, you have #{RUBY_VERSION}"
96
96
  end
97
97
  end
@@ -24,12 +24,14 @@ module BareTest
24
24
  return super unless suite.description
25
25
  puts("\n"+' '*@depth+suite.description)
26
26
  @depth += 1
27
- super
27
+ rv = super
28
28
  @depth -= 1
29
+ rv
29
30
  end
30
31
 
31
32
  def run_test(assertion, setup)
32
33
  puts(' '*@depth+assertion.description)
34
+ BareTest::Status.new(assertion, :success)
33
35
  end
34
36
  end
35
37
  end
@@ -21,7 +21,6 @@ module BareTest
21
21
  count = proc { |acc,csuite|
22
22
  acc+
23
23
  csuite.assertions.size+
24
- csuite.skipped.size+
25
24
  csuite.suites.map { |d,suite| suite }.inject(0, &count)
26
25
  }
27
26
  puts "1..#{count[0, suite]}"
@@ -34,8 +33,10 @@ module BareTest
34
33
  printf "%sok %d - %s%s\n",
35
34
  rv.status == :success ? '' : 'not ',
36
35
  @current+=1,
37
- rv.description,
36
+ assertion.description,
38
37
  rv.status == :success ? '' : " # #{rv.status}"
38
+
39
+ rv
39
40
  end
40
41
  end
41
42
  end
@@ -18,7 +18,7 @@ module BareTest
18
18
  MINOR = 4
19
19
 
20
20
  # The tiny version number
21
- TINY = 0
21
+ TINY = 1
22
22
 
23
23
  # Prerelease number - nil for release versions
24
24
  PRERELEASE = nil
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Stefan Rusterholz
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-18 00:00:00 +01:00
17
+ date: 2010-04-16 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -71,7 +71,6 @@ files:
71
71
  - lib/baretest/run/cli.rb
72
72
  - lib/baretest/run/minimal.rb
73
73
  - lib/baretest/run/none.rb
74
- - lib/baretest/run/profile.rb
75
74
  - lib/baretest/run/spec.rb
76
75
  - lib/baretest/run/tap.rb
77
76
  - lib/baretest/run/xml.rb
@@ -129,7 +128,7 @@ rdoc_options:
129
128
  - --tab-width
130
129
  - "2"
131
130
  - -t
132
- - baretest-0.4.0
131
+ - baretest-0.4.1
133
132
  require_paths:
134
133
  - lib
135
134
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -1,151 +0,0 @@
1
- # encoding: utf-8
2
- #--
3
- # Copyright 2009-2010 by Stefan Rusterholz.
4
- # All rights reserved.
5
- # See LICENSE.txt for permissions.
6
- #++
7
-
8
-
9
-
10
- module BareTest
11
- class Run
12
-
13
- # CLI runner is invoked with `-f cli` or `--format cli`.
14
- # It is intended for use with an interactive shell, to provide a comfortable, human
15
- # readable output.
16
- # It prints colored output (requires ANSI colors compatible terminal).
17
- #
18
- module Profile # :nodoc:
19
- Formats = {
20
- :pending => "\e[43m%9s\e[0m %s%s (%s)\n",
21
- :skipped => "\e[43m%9s\e[0m %s%s (%s)\n",
22
- :success => "\e[42m%9s\e[0m %s%s (%s)\n",
23
- :failure => "\e[41m%9s\e[0m %s%s (%s)\n",
24
- :error => "\e[37;40;1m%9s\e[0m %s%s (%s)\n" # ]]]]]]]] - bbedit hates open brackets...
25
- }
26
-
27
- FooterFormats = {
28
- :incomplete => "\e[43m%9s\e[0m\n",
29
- :success => "\e[42m%9s\e[0m\n",
30
- :failure => "\e[41m%9s\e[0m\n",
31
- :error => "\e[37;40;1m%9s\e[0m\n" # ]]]]]]]] - bbedit hates open brackets...
32
- }
33
-
34
- def run_all(*args)
35
- @depth = 0
36
- puts "Running all tests#{' verbosly' if $VERBOSE}"
37
- start = Time.now
38
- super # run all suites
39
- status = global_status
40
- printf "\n%2$d tests run in %1$.1fs\n%3$d successful, %4$d pending, %5$d failures, %6$d errors\n",
41
- Time.now-start, *@count.values_at(:test, :success, :pending, :failure, :error)
42
- print "Final status: "
43
- printf FooterFormats[status], status_label(status)
44
- end
45
-
46
- def run_suite(suite)
47
- return super unless suite.description
48
- skipped = suite.skipped.size
49
- case size = suite.assertions.size
50
- when 0
51
- if skipped.zero? then
52
- puts "\n \e[1m#{' '*@depth+suite.description}\e[0m"
53
- else
54
- puts "\n \e[1m#{' '*@depth+suite.description}\e[0m (#{skipped} skipped)"
55
- end
56
- when 1
57
- if skipped.zero? then
58
- puts "\n \e[1m#{' '*@depth+suite.description}\e[0m (1 test)"
59
- else
60
- puts "\n \e[1m#{' '*@depth+suite.description}\e[0m (1 test/#{skipped} skipped)"
61
- end
62
- else
63
- if skipped.zero? then
64
- puts "\n \e[1m#{' '*@depth+suite.description}\e[0m (#{size} tests)"
65
- else
66
- puts "\n \e[1m#{' '*@depth+suite.description}\e[0m (#{size} tests/#{skipped} skipped)"
67
- end
68
- end
69
- @depth += 1
70
- super(suite) # run the suite
71
- @depth -= 1
72
- end
73
-
74
- def run_test(assertion, setup)
75
- start = Time.now
76
- rv = super # run the assertion
77
- times = [Time.now-start]
78
-
79
- if times.first < 1e-3 then
80
- iters = 19
81
- elsif times.first < 1
82
- iters = 2
83
- else
84
- iters = 0
85
- end
86
-
87
- iters.times do
88
- assertion.reset
89
- start = Time.now
90
- assertion.execute
91
- times << (Time.now-start)
92
- end
93
-
94
- time = times.inject{ |a,b| a+b }/iters
95
-
96
- indent = ' '+' '*@depth
97
- message = []
98
- deeper = []
99
-
100
- printf(
101
- Formats[rv.status],
102
- status_label(rv.status),
103
- ' '*@depth,
104
- rv.description,
105
- humanized_duration(time)
106
- )
107
- if rv.status == :error then
108
- message = (rv.exception.message || "no error message given").split("\n")
109
- deeper = $VERBOSE ? rv.exception.backtrace : rv.exception.backtrace.first(1)
110
- elsif rv.status == :failure
111
- message = (rv.reason || "no failure reason given").split("\n")
112
- deeper = ["#{rv.file}:#{rv.line}"]
113
- end
114
- message.each do |line| print(indent, line, "\n") end
115
- deeper.each do |line| print(indent, ' ', line, "\n") end
116
-
117
- rv
118
- end
119
-
120
- def word_wrap(string, cols)
121
- str.scan(/[^ ]+ /)
122
- end
123
-
124
- def status_label(status)
125
- status.to_s.capitalize.center(9)
126
- end
127
-
128
- def humanized_duration(duration)
129
- case
130
- when duration < 1e-3
131
- "%dµs" % (duration*1e6)
132
- when duration < 1
133
- "%.1fms" % (duration*1e3)
134
- when duration < 60
135
- "%.1fs" % duration
136
- else
137
- minutes, seconds = *duration.divmod(60)
138
- hours, minutes = *minutes.divmod(60)
139
- # lets assume unit tests don't take more than a day :)
140
- if hours > 0 then
141
- "#{hours}h #{minutes}m #{seconds}s"
142
- else
143
- "#{minutes}m #{seconds}s"
144
- end
145
- end
146
- end
147
- end
148
- end
149
-
150
- @format["baretest/run/profile"] = Run::Profile # register the extender
151
- end