mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/mspec@ee29a34
This commit is contained in:
parent
b78fba447a
commit
a68ddf4287
7 changed files with 89 additions and 20 deletions
|
@ -153,5 +153,7 @@ def ruby_cmd(code, opts = {})
|
||||||
body = "-e #{code.inspect}"
|
body = "-e #{code.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
[RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ')
|
command = [RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ')
|
||||||
|
STDERR.puts "\nruby_cmd: #{command}" if ENV["DEBUG_MSPEC_RUBY_CMD"] == "true"
|
||||||
|
command
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,25 +4,13 @@
|
||||||
# directory is empty when the process exits.
|
# directory is empty when the process exits.
|
||||||
|
|
||||||
SPEC_TEMP_DIR_PID = Process.pid
|
SPEC_TEMP_DIR_PID = Process.pid
|
||||||
SPEC_TEMP_DIR_LIST = []
|
SPEC_TEMP_DIR = File.expand_path(ENV["SPEC_TEMP_DIR"] || "rubyspec_temp/#{SPEC_TEMP_DIR_PID}")
|
||||||
if tmpdir = ENV['SPEC_TEMP_DIR']
|
|
||||||
temppath = File.realdirpath(tmpdir) + "/"
|
|
||||||
else
|
|
||||||
tmpdir = File.realdirpath("rubyspec_temp")
|
|
||||||
temppath = tmpdir + "/#{SPEC_TEMP_DIR_PID}"
|
|
||||||
SPEC_TEMP_DIR_LIST << tmpdir
|
|
||||||
end
|
|
||||||
SPEC_TEMP_DIR_LIST << temppath
|
|
||||||
SPEC_TEMP_DIR = temppath
|
|
||||||
SPEC_TEMP_UNIQUIFIER = "0"
|
SPEC_TEMP_UNIQUIFIER = "0"
|
||||||
|
|
||||||
at_exit do
|
at_exit do
|
||||||
begin
|
begin
|
||||||
if SPEC_TEMP_DIR_PID == Process.pid
|
if SPEC_TEMP_DIR_PID == Process.pid
|
||||||
while temppath = SPEC_TEMP_DIR_LIST.pop
|
Dir.delete SPEC_TEMP_DIR if File.directory? SPEC_TEMP_DIR
|
||||||
next unless File.directory? temppath
|
|
||||||
Dir.delete temppath
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
rescue SystemCallError
|
rescue SystemCallError
|
||||||
STDERR.puts <<-EOM
|
STDERR.puts <<-EOM
|
||||||
|
@ -30,7 +18,7 @@ at_exit do
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
The rubyspec temp directory is not empty. Ensure that
|
The rubyspec temp directory is not empty. Ensure that
|
||||||
all specs are cleaning up temporary files:
|
all specs are cleaning up temporary files:
|
||||||
#{temppath}
|
#{SPEC_TEMP_DIR}
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|
||||||
EOM
|
EOM
|
||||||
|
|
|
@ -7,6 +7,7 @@ require 'mspec/runner/formatters/summary'
|
||||||
require 'mspec/runner/formatters/unit'
|
require 'mspec/runner/formatters/unit'
|
||||||
require 'mspec/runner/formatters/spinner'
|
require 'mspec/runner/formatters/spinner'
|
||||||
require 'mspec/runner/formatters/method'
|
require 'mspec/runner/formatters/method'
|
||||||
|
require 'mspec/runner/formatters/stats'
|
||||||
require 'mspec/runner/formatters/yaml'
|
require 'mspec/runner/formatters/yaml'
|
||||||
require 'mspec/runner/formatters/profile'
|
require 'mspec/runner/formatters/profile'
|
||||||
require 'mspec/runner/formatters/junit'
|
require 'mspec/runner/formatters/junit'
|
||||||
|
|
57
spec/mspec/lib/mspec/runner/formatters/stats.rb
Normal file
57
spec/mspec/lib/mspec/runner/formatters/stats.rb
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
require 'mspec/runner/formatters/base'
|
||||||
|
|
||||||
|
class StatsPerFileFormatter < BaseFormatter
|
||||||
|
def initialize(out = nil)
|
||||||
|
super(out)
|
||||||
|
@data = {}
|
||||||
|
@root = File.expand_path(MSpecScript.get(:prefix) || '.')
|
||||||
|
end
|
||||||
|
|
||||||
|
def register
|
||||||
|
super
|
||||||
|
MSpec.register :load, self
|
||||||
|
MSpec.register :unload, self
|
||||||
|
end
|
||||||
|
|
||||||
|
# Resets the tallies so the counts are only for this file.
|
||||||
|
def load
|
||||||
|
tally.counter.examples = 0
|
||||||
|
tally.counter.errors = 0
|
||||||
|
tally.counter.failures = 0
|
||||||
|
tally.counter.tagged = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def unload
|
||||||
|
file = format_file MSpec.file
|
||||||
|
|
||||||
|
raise if @data.key?(file)
|
||||||
|
@data[file] = {
|
||||||
|
examples: tally.counter.examples,
|
||||||
|
errors: tally.counter.errors,
|
||||||
|
failures: tally.counter.failures,
|
||||||
|
tagged: tally.counter.tagged,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def finish
|
||||||
|
width = @data.keys.max_by(&:size).size
|
||||||
|
f = "%3d"
|
||||||
|
@data.each_pair do |file, data|
|
||||||
|
total = data[:examples]
|
||||||
|
passing = total - data[:errors] - data[:failures] - data[:tagged]
|
||||||
|
puts "#{file.ljust(width)} #{f % passing}/#{f % total}"
|
||||||
|
end
|
||||||
|
|
||||||
|
require 'yaml'
|
||||||
|
yaml = YAML.dump(@data)
|
||||||
|
File.write "results-#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}.yml", yaml
|
||||||
|
end
|
||||||
|
|
||||||
|
private def format_file(file)
|
||||||
|
if file.start_with?(@root)
|
||||||
|
file[@root.size+1..-1]
|
||||||
|
else
|
||||||
|
raise file
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -274,6 +274,8 @@ class MSpecOptions
|
||||||
config[:formatter] = SpinnerFormatter
|
config[:formatter] = SpinnerFormatter
|
||||||
when 't', 'method'
|
when 't', 'method'
|
||||||
config[:formatter] = MethodFormatter
|
config[:formatter] = MethodFormatter
|
||||||
|
when 'e', 'stats'
|
||||||
|
config[:formatter] = StatsPerFileFormatter
|
||||||
when 'y', 'yaml'
|
when 'y', 'yaml'
|
||||||
config[:formatter] = YamlFormatter
|
config[:formatter] = YamlFormatter
|
||||||
when 'p', 'profile'
|
when 'p', 'profile'
|
||||||
|
@ -300,6 +302,7 @@ class MSpecOptions
|
||||||
doc " m, summary SummaryFormatter"
|
doc " m, summary SummaryFormatter"
|
||||||
doc " a, *, spin SpinnerFormatter"
|
doc " a, *, spin SpinnerFormatter"
|
||||||
doc " t, method MethodFormatter"
|
doc " t, method MethodFormatter"
|
||||||
|
doc " e, stats StatsPerFileFormatter"
|
||||||
doc " y, yaml YamlFormatter"
|
doc " y, yaml YamlFormatter"
|
||||||
doc " p, profile ProfileFormatter"
|
doc " p, profile ProfileFormatter"
|
||||||
doc " j, junit JUnitFormatter\n"
|
doc " j, junit JUnitFormatter\n"
|
||||||
|
@ -467,8 +470,6 @@ class MSpecOptions
|
||||||
end
|
end
|
||||||
|
|
||||||
def all
|
def all
|
||||||
# Generated with:
|
|
||||||
# puts File.read(__FILE__).scan(/def (\w+).*\n\s*on\(/)
|
|
||||||
configure {}
|
configure {}
|
||||||
targets
|
targets
|
||||||
formatters
|
formatters
|
||||||
|
@ -481,6 +482,7 @@ class MSpecOptions
|
||||||
repeat
|
repeat
|
||||||
verbose
|
verbose
|
||||||
interrupt
|
interrupt
|
||||||
|
timeout
|
||||||
verify
|
verify
|
||||||
action_filters
|
action_filters
|
||||||
actions
|
actions
|
||||||
|
|
|
@ -1283,3 +1283,22 @@ describe "The -d, --debug option" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "MSpecOptions#all" do
|
||||||
|
it "includes all options" do
|
||||||
|
meth = MSpecOptions.instance_method(:all)
|
||||||
|
file, line = meth.source_location
|
||||||
|
contents = File.read(file)
|
||||||
|
lines = contents.lines
|
||||||
|
|
||||||
|
from = line
|
||||||
|
to = from
|
||||||
|
to += 1 until /^\s*end\s*$/ =~ lines[to]
|
||||||
|
calls = lines[from...to].map(&:strip)
|
||||||
|
|
||||||
|
option_methods = contents.scan(/def (\w+).*\n\s*on\(/).map(&:first)
|
||||||
|
option_methods[0].sub!("configure", "configure {}")
|
||||||
|
|
||||||
|
calls.should == option_methods
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ IMPLS = {
|
||||||
MSPEC = ARGV.delete('--mspec')
|
MSPEC = ARGV.delete('--mspec')
|
||||||
|
|
||||||
CHECK_LAST_MERGE = ENV['CHECK_LAST_MERGE'] != 'false'
|
CHECK_LAST_MERGE = ENV['CHECK_LAST_MERGE'] != 'false'
|
||||||
TEST_TRUNK = ENV['TEST_TRUNK'] != 'false'
|
TEST_MASTER = ENV['TEST_MASTER'] != 'false'
|
||||||
|
|
||||||
MSPEC_REPO = File.expand_path("../../..", __FILE__)
|
MSPEC_REPO = File.expand_path("../../..", __FILE__)
|
||||||
raise MSPEC_REPO if !Dir.exist?(MSPEC_REPO) or !Dir.exist?("#{MSPEC_REPO}/.git")
|
raise MSPEC_REPO if !Dir.exist?(MSPEC_REPO) or !Dir.exist?("#{MSPEC_REPO}/.git")
|
||||||
|
@ -172,7 +172,7 @@ def test_new_specs
|
||||||
|
|
||||||
run_test[min_version]
|
run_test[min_version]
|
||||||
run_test[max_version]
|
run_test[max_version]
|
||||||
run_test["trunk"] if TEST_TRUNK
|
run_test["master"] if TEST_MASTER
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue