Skip to content
Permalink
Browse files
Updated MSpec source to �[33m4d5.
  • Loading branch information
YorickPeterse committed Dec 26, 2015
1 parent a2d2919 commit dfa4f06d67599b04c3f94df78f70a77bf784ab92
Showing with 834 additions and 865 deletions.
  1. +0 −8 mspec/lib/mspec/commands/mspec.rb
  2. +1 −1 mspec/lib/mspec/guards/block_device.rb
  3. +4 −0 mspec/lib/mspec/guards/platform.rb
  4. +15 −10 mspec/lib/mspec/helpers/environment.rb
  5. +36 −1 mspec/lib/mspec/helpers/io.rb
  6. +3 −1 mspec/lib/mspec/helpers/mock_to_path.rb
  7. +1 −1 mspec/lib/mspec/helpers/numeric.rb
  8. +11 −4 mspec/lib/mspec/helpers/ruby_exe.rb
  9. +1 −1 mspec/lib/mspec/helpers/tmp.rb
  10. +1 −0 mspec/lib/mspec/matchers.rb
  11. +34 −0 mspec/lib/mspec/matchers/block_caller.rb
  12. +6 −6 mspec/lib/mspec/matchers/output.rb
  13. +4 −4 mspec/lib/mspec/mocks/mock.rb
  14. +0 −1 mspec/lib/mspec/runner/actions.rb
  15. +0 −17 mspec/lib/mspec/runner/actions/gdb.rb
  16. +6 −2 mspec/lib/mspec/runner/actions/timer.rb
  17. +1 −1 mspec/lib/mspec/runner/context.rb
  18. +2 −2 mspec/lib/mspec/runner/exception.rb
  19. +6 −6 mspec/lib/mspec/utils/options.rb
  20. +0 −1 mspec/lib/mspec/utils/script.rb
  21. +1 −1 mspec/lib/mspec/version.rb
  22. +31 −31 mspec/spec/commands/mkspec_spec.rb
  23. +14 −14 mspec/spec/commands/mspec_ci_spec.rb
  24. +4 −4 mspec/spec/commands/mspec_run_spec.rb
  25. +35 −58 mspec/spec/commands/mspec_spec.rb
  26. +29 −29 mspec/spec/commands/mspec_tag_spec.rb
  27. +2 −2 mspec/spec/guards/background_spec.rb
  28. +1 −1 mspec/spec/guards/block_device_spec.rb
  29. +4 −4 mspec/spec/guards/bug_spec.rb
  30. +2 −2 mspec/spec/guards/compliance_spec.rb
  31. +5 −5 mspec/spec/guards/conflict_spec.rb
  32. +8 −8 mspec/spec/guards/endian_spec.rb
  33. +1 −1 mspec/spec/guards/extensions_spec.rb
  34. +5 −5 mspec/spec/guards/feature_spec.rb
  35. +22 −22 mspec/spec/guards/guard_spec.rb
  36. +1 −1 mspec/spec/guards/noncompliance_spec.rb
  37. +14 −14 mspec/spec/guards/platform_spec.rb
  38. +1 −1 mspec/spec/guards/quarantine_spec.rb
  39. +7 −7 mspec/spec/guards/runner_spec.rb
  40. +7 −7 mspec/spec/guards/specified_spec.rb
  41. +3 −3 mspec/spec/guards/superuser_spec.rb
  42. +1 −1 mspec/spec/guards/support_spec.rb
  43. +1 −1 mspec/spec/guards/tty_spec.rb
  44. +3 −3 mspec/spec/guards/user_spec.rb
  45. +3 −3 mspec/spec/guards/version_spec.rb
  46. +3 −3 mspec/spec/helpers/ducktype_spec.rb
  47. +18 −10 mspec/spec/helpers/environment_spec.rb
  48. +2 −2 mspec/spec/helpers/flunk_spec.rb
  49. +12 −12 mspec/spec/helpers/fs_spec.rb
  50. +2 −2 mspec/spec/helpers/io_spec.rb
  51. +1 −1 mspec/spec/helpers/numeric_spec.rb
  52. +5 −9 mspec/spec/helpers/ruby_exe_spec.rb
  53. +6 −6 mspec/spec/matchers/be_an_instance_of_spec.rb
  54. +4 −4 mspec/spec/matchers/be_computed_by_function_spec.rb
  55. +5 −5 mspec/spec/matchers/be_computed_by_spec.rb
  56. +8 −8 mspec/spec/matchers/be_valid_dns_name_spec.rb
  57. +13 −0 mspec/spec/matchers/block_caller_spec.rb
  58. +32 −32 mspec/spec/matchers/equal_element_spec.rb
  59. +4 −4 mspec/spec/matchers/have_class_variable_spec.rb
  60. +2 −2 mspec/spec/matchers/have_constant_spec.rb
  61. +4 −4 mspec/spec/matchers/have_data_spec.rb
  62. +4 −4 mspec/spec/matchers/have_instance_method_spec.rb
  63. +4 −4 mspec/spec/matchers/have_instance_variable_spec.rb
  64. +6 −6 mspec/spec/matchers/have_method_spec.rb
  65. +4 −4 mspec/spec/matchers/have_private_instance_method_spec.rb
  66. +2 −2 mspec/spec/matchers/have_private_method_spec.rb
  67. +4 −4 mspec/spec/matchers/have_protected_instance_method_spec.rb
  68. +4 −4 mspec/spec/matchers/have_public_instance_method_spec.rb
  69. +3 −3 mspec/spec/matchers/have_singleton_method_spec.rb
  70. +1 −1 mspec/spec/matchers/output_spec.rb
  71. +46 −46 mspec/spec/mocks/mock_spec.rb
  72. +9 −9 mspec/spec/mocks/proxy_spec.rb
  73. +1 −1 mspec/spec/runner/actions/filter_spec.rb
  74. +0 −61 mspec/spec/runner/actions/gdb_spec.rb
  75. +24 −24 mspec/spec/runner/actions/tag_spec.rb
  76. +11 −11 mspec/spec/runner/actions/taglist_spec.rb
  77. +11 −11 mspec/spec/runner/actions/tagpurge_spec.rb
  78. +4 −4 mspec/spec/runner/actions/timer_spec.rb
  79. +49 −49 mspec/spec/runner/context_spec.rb
  80. +1 −1 mspec/spec/runner/example_spec.rb
  81. +3 −3 mspec/spec/runner/exception_spec.rb
  82. +2 −2 mspec/spec/runner/filters/profile_spec.rb
  83. +6 −6 mspec/spec/runner/filters/tag_spec.rb
  84. +6 −6 mspec/spec/runner/formatters/describe_spec.rb
  85. +25 −25 mspec/spec/runner/formatters/dotted_spec.rb
  86. +6 −6 mspec/spec/runner/formatters/file_spec.rb
  87. +10 −10 mspec/spec/runner/formatters/html_spec.rb
  88. +11 −11 mspec/spec/runner/formatters/junit_spec.rb
  89. +3 −3 mspec/spec/runner/formatters/method_spec.rb
  90. +3 −3 mspec/spec/runner/formatters/specdoc_spec.rb
  91. +4 −4 mspec/spec/runner/formatters/spinner_spec.rb
  92. +7 −7 mspec/spec/runner/formatters/unit_spec.rb
  93. +10 −10 mspec/spec/runner/formatters/yaml_spec.rb
  94. +39 −35 mspec/spec/runner/mspec_spec.rb
  95. +1 −1 mspec/spec/runner/shared_spec.rb
  96. +37 −61 mspec/spec/utils/options_spec.rb
  97. +15 −24 mspec/spec/utils/script_spec.rb
@@ -37,10 +37,6 @@ def options(argv=ARGV)

options.targets

options.on("-D", "--gdb", "Run under gdb") do
config[:use_gdb] = true
end

options.on("-A", "--valgrind", "Run under valgrind") do
config[:use_valgrind] = true
end
@@ -162,12 +158,8 @@ def run
else
if config[:use_valgrind]
more = ["--child-silent-after-fork=yes",
"--db-attach=#{config[:use_gdb] ? 'yes' : 'no'}",
config[:target]] + argv
exec "valgrind", *more
elsif config[:use_gdb]
more = ["--args", config[:target]] + argv
exec "gdb", *more
else
cmd, *rest = config[:target].split(/\s+/)
argv = rest + argv unless rest.empty?
@@ -2,7 +2,7 @@

class BlockDeviceGuard < SpecGuard
def match?
platform_is_not :freebsd, :windows do
platform_is_not :freebsd, :windows, :opal do
block = `find /dev /devices -type b 2> /dev/null`
return !(block.nil? || block.empty?)
end
@@ -5,6 +5,10 @@ def self.windows?
PlatformGuard.new(:os => :windows).match?
end

def self.opal?
PlatformGuard.new(:opal)
end

def initialize(*args)
if args.last.is_a?(Hash)
@options, @platforms = args.last, args[0..-2]
@@ -2,27 +2,29 @@

class Object
def env
env = ""
if PlatformGuard.windows?
env = Hash[*`cmd.exe /C set`.split("\n").map { |e| e.split("=", 2) }.flatten]
Hash[*`cmd.exe /C set`.split("\n").map { |e| e.split("=", 2) }.flatten]
elsif PlatformGuard.opal?
{}
else
env = Hash[*`env`.split("\n").map { |e| e.split("=", 2) }.flatten]
Hash[*`env`.split("\n").map { |e| e.split("=", 2) }.flatten]
end
env
end

def windows_env_echo(var)
`cmd.exe /C ECHO %#{var}%`.strip
platform_is_not :opal do
`cmd.exe /C ECHO %#{var}%`.strip
end
end

def username
user = ""
if PlatformGuard.windows?
user = windows_env_echo('USERNAME')
windows_env_echo('USERNAME')
elsif PlatformGuard.opal?
""
else
user = `whoami`.strip
`whoami`.strip
end
user
end

def home_directory
@@ -41,7 +43,10 @@ def dev_null
def hostname
commands = ['hostname', 'uname -n']
commands.each do |command|
name = `#{command}`
name = ''
platform_is_not :opal do
name = `#{command}`
end
return name.strip if $?.success?
end
raise Exception, "hostname: unable to find a working command"
@@ -1,14 +1,36 @@
require 'mspec/guards/feature'

class IOStub < String
class IOStub
def initialize
@buffer = []
@output = ''
end

def write(*str)
self << str.join
end

def << str
@buffer << str
self
end

def print(*str)
write(str.join + $\.to_s)
end

def method_missing(name, *args, &block)
to_s.send(name, *args, &block)
end

def == other
to_s == other
end

def =~ other
to_s =~ other
end

def puts(*str)
if str.empty?
write "\n"
@@ -22,8 +44,21 @@ def printf(format, *args)
end

def flush
@output += @buffer.join('')
@buffer.clear
self
end

def to_s
flush
@output
end

alias_method :to_str, :to_s

def inspect
to_s.inspect
end
end

class Object
@@ -1,6 +1,8 @@
require 'mspec/mocks/proxy'

class Object
def mock_to_path(path)
obj = mock('path')
obj = MockObject.new('path')
obj.should_receive(:to_path).and_return(path)
obj
end
@@ -18,7 +18,7 @@ def bignum_value(plus=0)
# values.
guard = SpecGuard.new

if guard.standard? or guard.implementation? :topaz
if guard.standard? or guard.implementation? :topaz or guard.implementation? :opal
if guard.wordsize? 32
def fixnum_max()
(2**30) - 1
@@ -128,7 +128,9 @@ def ruby_exe(code, opts = {})
end

begin
`#{ruby_cmd(code, opts)}`
platform_is_not :opal do
`#{ruby_cmd(code, opts)}`
end
ensure
saved_env.each { |key, value| ENV[key] = value }
env.keys.each do |key|
@@ -144,11 +146,16 @@ def ruby_cmd(code, opts = {})

if code and not File.exist?(code)
if opts[:escape]
code = "'#{code}'"
heredoc_separator = "END_OF_RUBYCODE"
lines = code.lines
until lines.none? {|line| line.start_with? heredoc_separator }
heredoc_separator << heredoc_separator
end

body = %Q!-e "$(cat <<'#{heredoc_separator}'\n#{code}\n#{heredoc_separator}\n)"!
else
code = code.inspect
body = "-e #{code.inspect}"
end
body = "-e #{code}"
end

[RUBY_EXE, ENV['RUBY_FLAGS'], opts[:options], body, opts[:args]].compact.join(' ')
@@ -3,7 +3,7 @@
# should clean up any temporary files created so that the temp
# directory is empty when the process exits.

SPEC_TEMP_DIR = "#{File.expand_path(Dir.pwd)}/rubyspec_temp"
SPEC_TEMP_DIR = ENV["SPEC_TEMP_DIR"] || "#{File.expand_path(Dir.pwd)}/rubyspec_temp"

SPEC_TEMP_UNIQUIFIER = "0"

@@ -36,3 +36,4 @@
require 'mspec/matchers/output_to_fd'
require 'mspec/matchers/respond_to'
require 'mspec/matchers/signed_zero'
require 'mspec/matchers/block_caller'
@@ -0,0 +1,34 @@
class BlockingMatcher
def initialize(timeout = 0.1)
@timeout = timeout
end

def matches?(block)
blocking = true

thread = Thread.new do
block.call

blocking = false
end

thread.join(@timeout)
thread.kill

blocking
end

def failure_message
['Expected the given Proc', 'to block the caller']
end

def negative_failure_message
['Expected the given Proc', 'to not block the caller']
end
end

class Object
def block_caller(timeout = 0.1)
BlockingMatcher.new(timeout)
end
end
@@ -42,20 +42,20 @@ def failure_message
expected_out = "\n"
actual_out = "\n"
unless @out.nil?
expected_out << " $stdout: #{@out.inspect}\n"
actual_out << " $stdout: #{@stdout.chomp.inspect}\n"
expected_out += " $stdout: #{@out.inspect}\n"
actual_out += " $stdout: #{@stdout.inspect}\n"
end
unless @err.nil?
expected_out << " $stderr: #{@err.inspect}\n"
actual_out << " $stderr: #{@stderr.chomp.inspect}\n"
expected_out += " $stderr: #{@err.inspect}\n"
actual_out += " $stderr: #{@stderr.inspect}\n"
end
["Expected:#{expected_out}", " got:#{actual_out}"]
end

def negative_failure_message
out = ""
out << " $stdout: #{@stdout.chomp.dump}\n" unless @out.nil?
out << " $stderr: #{@stderr.chomp.dump}\n" unless @err.nil?
out += " $stdout: #{@stdout.chomp.dump}\n" unless @out.nil?
out += " $stderr: #{@stderr.chomp.dump}\n" unless @err.nil?
["Expected output not to be:\n", out]
end
end
@@ -62,11 +62,11 @@ def self.install_method(obj, sym, type=nil)
meta.__send__ :alias_method, key.first, sym
end

meta.class_eval <<-END
def #{sym}(*args, &block)
Mock.verify_call self, :#{sym}, *args, &block
meta.class_eval {
define_method(sym) do |*args, &block|
Mock.verify_call self, sym, *args, &block
end
END
}

proxy = MockProxy.new type

@@ -4,4 +4,3 @@
require 'mspec/runner/actions/tag'
require 'mspec/runner/actions/taglist'
require 'mspec/runner/actions/tagpurge'
require 'mspec/runner/actions/gdb'

This file was deleted.

@@ -5,11 +5,11 @@ def register
end

def start
@start = Time.now
@start = current_time
end

def finish
@stop = Time.now
@stop = current_time
end

def elapsed
@@ -19,4 +19,8 @@ def elapsed
def format
"Finished in %f seconds" % elapsed
end

def current_time
Time.now
end
end
@@ -6,7 +6,7 @@
#--
# A note on naming: this is named _ContextState_ rather
# than _DescribeState_ because +describe+ is the keyword
# in the DSL for refering to the context in which an example
# in the DSL for referring to the context in which an example
# is evaluated, just as +it+ refers to the example itself.
#++
class ContextState
@@ -6,8 +6,8 @@ def initialize(state, location, exception)

@description = location ? "An exception occurred during: #{location}" : ""
if state
@description << "\n" unless @description.empty?
@description << state.description
@description += "\n" unless @description.empty?
@description += state.description
@describe = state.describe
@it = state.it
else

3 comments on commit dfa4f06

@heftig

This comment has been minimized.

Copy link
Contributor

@heftig heftig replied Dec 26, 2015

What's the ANSI escape doing in the commit subject?

@YorickPeterse

This comment has been minimized.

Copy link
Member Author

@YorickPeterse YorickPeterse replied Dec 27, 2015

@heftig I think that's because I have colours enabled when running git log.

@YorickPeterse

This comment has been minimized.

Copy link
Member Author

@YorickPeterse YorickPeterse replied Dec 27, 2015

Fixed in 1142534

Please sign in to comment.