Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9475410269e6
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 89605cbcaf43
Choose a head ref
  • 4 commits
  • 174 files changed
  • 1 contributor

Commits on Jun 23, 2017

  1. Squashed 'spec/mspec/' changes from 6c95759..86c3bee

    86c3bee Print the output of --verbose/-V and --marker/-m on STDERR
    b4236a6 Show more details when unexpected output is produced on STDOUT with mspec -j
    b4eefac Remove extra spacing
    a44aa8d Handle a closed STDIN in sub-processes
    7293fa1 Let the sub-processes die silently if the main process died
    91ea445 Inspect extra output sent by a worker
    72426f3 Rename the variable ok to success
    4bf8137 Use Process.wait2 to avoid relying on global variables
    84a8121 Close the child IO when it terminates
    d900a49 Highlight the important messages
    38c58f3 Grep for a commit starting with the last merge message
    f653f9b Simplify, avoid extra exceptions and add test for concurrent mspec mkdir_p
    46ae38c fix race condition
    9a80e01 Open files in binary modes for copying in MSpec's #cp
    165d46d Use RUBY_ENGINE directly and remove RUBY_NAME
    9a3fc4b Remove the --name option
    2f7b200 Make all MSpec guards private
    8a9182c Make all MSpec helpers private
    
    git-subtree-dir: spec/mspec
    git-subtree-split: 86c3bee671c1668fe5ac67902cbce450e5f590af
    eregon committed Jun 23, 2017
    Copy the full SHA
    fe7fe66 View commit details
  2. Copy the full SHA
    564ad98 View commit details
  3. Squashed 'spec/ruby/' changes from 2795010..874f42f

    874f42f Set the external encoding of the GzipReader
    c2285d8 Improve Time#{gmtime,utc} spec
    20ce06e Improve Time#gmtime spec regarding frozen Time instances
    ed3075b Correct usage of ruby_bug in Enumerable#uniq
    5cecc96 Add version guard for SecureRandom.random_number with a Range
    62cbf6e Fix spec: Time#localtime only raises if it needs to change the time zone on a frozen Time
    e4a7f8a Put in quarantine specs which are waiting for a resolution in MRI
    45de261 Zlib::GzipReader#pos underflows after calling #ungetbyte or #ungetc at start of file
    b2d03bf BigDecimal with Float::INFINITY is buggy on MRI before 2.4
    d109058 Add spec for nil buffer passed to Zlib::GzipReader#readpartial
    090c87b Add failing specs showing that frozen Time objects can be mutated
    18eece4 [spec] for SecureRandom.random_number (esp. for range argument)
    f1a4344 Add spec for Zlib::GzipReader#gets("")
    02eeed6 Add specs for Zlib::GzipReader#ungetbyte and #ungetc
    00ad47e Fix Float::INFINITY BigDecimal comparison
    e797cc6 Enumerable#uniq has been fixed in 2.5
    582b9f4 Add an example Kernel#clone with `freeze` option
    52b8515 Add MatchData#values_at specs for the new named captures
    44a0731 Write MatchData#named_captures specs
    370d2ad Fix ruby_bug use
    12ca459 Write Enumerator::Lazy#uniq specs
    2a2343c Follow ruby-lang `Bug #13669` in Enumerable#uniq
    39d313d Write Enumerable#uniq specs (#447)
    d313f22 Merge pull request #446 from kachick/enum-sum
    e8a37ce Suppress rubocop
    7f2961d Write Enumerable#sum specs
    ec1c161 Add RuboCop on CI to be notified of new failures
    1f29d20 Disable Lint/AssignmentInCondition as it warns for assignment in while
    5101462 Use while + assignment instead of loop + break in DummyFTP
    d334823 Disable a few cops which do not make sense for ruby/spec
    2a0bdb2 Allow EmptyExpression in language specs
    2d9590a Fix one useless empty expression
    fe66187 Disable a few cops which do not make sense for ruby/spec
    bc928b4 Fix alignment issues discovered by Lint/BlockAlignment
    3f45fea Add `.rubocop_todo.yml`
    47358a5 Add `.rubocop.yml`
    358ca15 Close the server in Socket#connect_nonblock spec
    b82d719 Add spec that a failing -S script sets the exit status correctly
    c730f07 Use just 'r' for the return value variable
    8654896 Close the write side to ensure the read side of the pipe see the data
    cd1b911 Remove unused arguments to DummyFTP server
    b2a6032 Remove SocketSpecs.port, and let the servers find an available port
    736411f Let TCPServer find an available port
    74cf1d7 Let UDPSocket find an available port
    7d8eeb3 Cleanup and reset state in NetHTTPSpecs.stop_server
    edc6bb5 Make sure the server is started to give the port
    a1c2d66 Run the Kernel#yield_self spec on TruffleRuby
    3639bb0 Implement Kernel#yield_self
    83485ce Use before/after in UNIXServer#accept spec
    a90afa1 Make {UNIX,TCP}Server#accept specs faster
    b344842 Detect whether readline is available, no matter if the feature is enabled or not
    5fb6c56 Fix DRb.start_service to use any available port
    fac8624 Remove bad spec which cannot behave nicely in a multi-process environment
    7f264f8 Remove empty files in drb specs
    0fe2eb4 Create the file in the File::TMPFILE spec in its own directory
    666458c Solaris 10 x86 raises SEGV
    f4f9b02 Clean up a bit the Process.setpriority specs
    a7bbcc4 Enable Process.setpriority for a single process on more platforms.
    f28c663 Run in separate process/pgrp [Bug#13609]
    6325c59 rubyspec: Fix method redefinition warning
    bdddf9c Explain why we do not capture stderr
    9b6201b Run the C-API specs on Windows!
    d6642a0 Relax rb_str_hash spec as conversion from st_index_t is very complex
    e8a430a Negative timestamp seems disallowed on x64-mingw32
    327370e Silence make warnings when ruby/spec is run under make
    fdbc0d4 Use nmake to build C APi specs on mswin
    97fe8c7 Use RUBY_ENGINE instead of RUBY_NAME
    33529f2 Remove duplicated `KernelBlockGiven` module
    71097bc Improve spec for String#split with capture and limit
    d8dac70 Simplify condition for run_mkmf_in_process
    419e82b add spec for String#split with capture and limit
    a34d2a5 MRI needs $extout = nil to build C extensions normally
    b2e6a3a Fix compile_extension() for MRI
    ca32ae2 Replace variable by its only usage
    23261e2 Remove implementation-specific headers
    ce7fbc0 Simplify as we only need to copy a single library file
    2a047c8 * remove trailing spaces.
    84ea66e Use mkmf to build C API specs
    c278889 Only compile once the module_under_autoload extension
    
    git-subtree-dir: spec/ruby
    git-subtree-split: 874f42fc50c378d12d2fb72a7045a446a2ecc354
    eregon committed Jun 23, 2017
    Copy the full SHA
    118e415 View commit details
  4. Copy the full SHA
    89605cb View commit details
Showing with 1,674 additions and 1,452 deletions.
  1. +0 −1 spec/mspec/lib/mspec/commands/mspec-ci.rb
  2. +0 −1 spec/mspec/lib/mspec/commands/mspec-run.rb
  3. +0 −1 spec/mspec/lib/mspec/commands/mspec-tag.rb
  4. +19 −7 spec/mspec/lib/mspec/commands/mspec.rb
  5. +0 −1 spec/mspec/lib/mspec/guards.rb
  6. +2 −4 spec/mspec/lib/mspec/guards/block_device.rb
  7. +2 −4 spec/mspec/lib/mspec/guards/bug.rb
  8. +6 −8 spec/mspec/lib/mspec/guards/conflict.rb
  9. +5 −7 spec/mspec/lib/mspec/guards/endian.rb
  10. +28 −30 spec/mspec/lib/mspec/guards/feature.rb
  11. +0 −1 spec/mspec/lib/mspec/guards/guard.rb
  12. +7 −9 spec/mspec/lib/mspec/guards/platform.rb
  13. +2 −4 spec/mspec/lib/mspec/guards/quarantine.rb
  14. +5 −7 spec/mspec/lib/mspec/guards/superuser.rb
  15. +2 −4 spec/mspec/lib/mspec/guards/support.rb
  16. +2 −4 spec/mspec/lib/mspec/guards/version.rb
  17. +32 −34 spec/mspec/lib/mspec/helpers/argf.rb
  18. +40 −42 spec/mspec/lib/mspec/helpers/argv.rb
  19. +39 −43 spec/mspec/lib/mspec/helpers/datetime.rb
  20. +22 −24 spec/mspec/lib/mspec/helpers/fixture.rb
  21. +2 −4 spec/mspec/lib/mspec/helpers/flunk.rb
  22. +53 −45 spec/mspec/lib/mspec/helpers/fs.rb
  23. +40 −42 spec/mspec/lib/mspec/helpers/io.rb
  24. +5 −7 spec/mspec/lib/mspec/helpers/mock_to_path.rb
  25. +51 −53 spec/mspec/lib/mspec/helpers/numeric.rb
  26. +82 −86 spec/mspec/lib/mspec/helpers/ruby_exe.rb
  27. +8 −10 spec/mspec/lib/mspec/helpers/tmp.rb
  28. +6 −8 spec/mspec/lib/mspec/helpers/warning.rb
  29. +1 −1 spec/mspec/lib/mspec/runner/formatters/html.rb
  30. +1 −2 spec/mspec/lib/mspec/runner/formatters/junit.rb
  31. +11 −3 spec/mspec/lib/mspec/runner/mspec.rb
  32. +2 −10 spec/mspec/lib/mspec/utils/options.rb
  33. +0 −8 spec/mspec/lib/mspec/utils/ruby_name.rb
  34. +0 −5 spec/mspec/spec/commands/mspec_ci_spec.rb
  35. +0 −5 spec/mspec/spec/commands/mspec_run_spec.rb
  36. +0 −5 spec/mspec/spec/commands/mspec_tag_spec.rb
  37. +6 −6 spec/mspec/spec/guards/bug_spec.rb
  38. +19 −19 spec/mspec/spec/guards/platform_spec.rb
  39. +8 −8 spec/mspec/spec/guards/support_spec.rb
  40. +13 −0 spec/mspec/spec/helpers/fs_spec.rb
  41. +18 −14 spec/mspec/spec/helpers/ruby_exe_spec.rb
  42. +3 −4 spec/mspec/spec/runner/formatters/html_spec.rb
  43. +0 −24 spec/mspec/spec/utils/options_spec.rb
  44. +5 −2 spec/mspec/tool/sync/sync-rubyspec.rb
  45. +40 −0 spec/ruby/.rubocop.yml
  46. +211 −0 spec/ruby/.rubocop_todo.yml
  47. +2 −1 spec/ruby/.travis.yml
  48. +2 −1 spec/ruby/appveyor.yml
  49. +6 −0 spec/ruby/command_line/dash_upper_s_spec.rb
  50. +1 −0 spec/ruby/command_line/fixtures/bin/dash_s_fail
  51. +11 −12 spec/ruby/core/array/element_set_spec.rb
  52. +30 −0 spec/ruby/core/enumerable/sum_spec.rb
  53. +29 −0 spec/ruby/core/enumerable/uniq_spec.rb
  54. +1 −1 spec/ruby/core/enumerator/lazy/grep_spec.rb
  55. +1 −1 spec/ruby/core/enumerator/lazy/grep_v_spec.rb
  56. +39 −0 spec/ruby/core/enumerator/lazy/uniq_spec.rb
  57. +5 −3 spec/ruby/core/file/open_spec.rb
  58. +3 −3 spec/ruby/core/io/output_spec.rb
  59. +10 −0 spec/ruby/core/kernel/clone_spec.rb
  60. +0 −16 spec/ruby/core/kernel/fixtures/classes.rb
  61. +2 −2 spec/ruby/core/kernel/public_method_spec.rb
  62. +26 −0 spec/ruby/core/kernel/yield_self_spec.rb
  63. +13 −0 spec/ruby/core/matchdata/named_captures_spec.rb
  64. +10 −0 spec/ruby/core/matchdata/values_at_spec.rb
  65. +40 −48 spec/ruby/core/module/module_function_spec.rb
  66. +43 −43 spec/ruby/core/module/shared/set_visibility.rb
  67. +12 −0 spec/ruby/core/process/fixtures/setpriority.rb
  68. +21 −40 spec/ruby/core/process/setpriority_spec.rb
  69. +1 −1 spec/ruby/core/regexp/encoding_spec.rb
  70. +1 −1 spec/ruby/core/string/encoding_spec.rb
  71. +4 −0 spec/ruby/core/string/split_spec.rb
  72. +12 −2 spec/ruby/core/time/localtime_spec.rb
  73. +22 −3 spec/ruby/core/time/shared/gmtime.rb
  74. +5 −5 spec/ruby/language/undef_spec.rb
  75. +11 −5 spec/ruby/library/bigdecimal/gt_spec.rb
  76. +11 −5 spec/ruby/library/bigdecimal/gte_spec.rb
  77. +11 −5 spec/ruby/library/bigdecimal/lt_spec.rb
  78. +11 −5 spec/ruby/library/bigdecimal/lte_spec.rb
  79. +0 −1 spec/ruby/library/drb/config_spec.rb
  80. +0 −1 spec/ruby/library/drb/current_server_spec.rb
  81. +0 −1 spec/ruby/library/drb/drbobject/__drbref_spec.rb
  82. +0 −1 spec/ruby/library/drb/drbobject/__drburi_spec.rb
  83. +0 −1 spec/ruby/library/drb/drbobject/_dump_spec.rb
  84. +0 −1 spec/ruby/library/drb/drbobject/_load_spec.rb
  85. +0 −1 spec/ruby/library/drb/drbobject/eql_spec.rb
  86. +0 −1 spec/ruby/library/drb/drbobject/equal_value_spec.rb
  87. +0 −1 spec/ruby/library/drb/drbobject/hash_spec.rb
  88. +0 −1 spec/ruby/library/drb/drbobject/method_missing_spec.rb
  89. +0 −1 spec/ruby/library/drb/drbobject/new_spec.rb
  90. +0 −1 spec/ruby/library/drb/drbobject/new_with_spec.rb
  91. +0 −1 spec/ruby/library/drb/drbobject/new_with_uri_spec.rb
  92. +0 −1 spec/ruby/library/drb/drbobject/prepare_backtrace_spec.rb
  93. +0 −1 spec/ruby/library/drb/drbobject/pretty_print_cycle_spec.rb
  94. +0 −1 spec/ruby/library/drb/drbobject/pretty_print_spec.rb
  95. +0 −1 spec/ruby/library/drb/drbobject/respond_to_spec.rb
  96. +0 −1 spec/ruby/library/drb/drbobject/with_friend_spec.rb
  97. +0 −1 spec/ruby/library/drb/fetch_server_spec.rb
  98. +0 −1 spec/ruby/library/drb/front_spec.rb
  99. +0 −1 spec/ruby/library/drb/here_spec.rb
  100. +0 −1 spec/ruby/library/drb/install_acl_spec.rb
  101. +0 −1 spec/ruby/library/drb/install_id_conv_spec.rb
  102. +0 −1 spec/ruby/library/drb/primary_server_spec.rb
  103. +0 −1 spec/ruby/library/drb/regist_server_spec.rb
  104. +0 −1 spec/ruby/library/drb/remove_server_spec.rb
  105. +8 −17 spec/ruby/library/drb/start_service_spec.rb
  106. +0 −25 spec/ruby/library/drb/stop_service_spec.rb
  107. +0 −1 spec/ruby/library/drb/thread_spec.rb
  108. +0 −1 spec/ruby/library/drb/to_id_spec.rb
  109. +0 −1 spec/ruby/library/drb/to_obj_spec.rb
  110. +0 −1 spec/ruby/library/drb/uri_spec.rb
  111. +5 −5 spec/ruby/library/erb/result_spec.rb
  112. +5 −5 spec/ruby/library/erb/run_spec.rb
  113. +7 −7 spec/ruby/library/matrix/regular_spec.rb
  114. +7 −7 spec/ruby/library/matrix/singular_spec.rb
  115. +4 −7 spec/ruby/library/net/ftp/fixtures/server.rb
  116. +4 −1 spec/ruby/library/net/http/http/fixtures/http_server.rb
  117. +7 −9 spec/ruby/library/readline/spec_helper.rb
  118. +1 −1 spec/ruby/library/rexml/element/add_attribute_spec.rb
  119. +24 −22 spec/ruby/library/securerandom/random_number_spec.rb
  120. +1 −1 spec/ruby/library/socket/addrinfo/bind_spec.rb
  121. +1 −1 spec/ruby/library/socket/basicsocket/close_read_spec.rb
  122. +1 −1 spec/ruby/library/socket/basicsocket/close_write_spec.rb
  123. +4 −3 spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb
  124. +1 −1 spec/ruby/library/socket/basicsocket/for_fd_spec.rb
  125. +4 −3 spec/ruby/library/socket/basicsocket/getpeername_spec.rb
  126. +5 −5 spec/ruby/library/socket/basicsocket/getsockname_spec.rb
  127. +6 −5 spec/ruby/library/socket/basicsocket/recv_spec.rb
  128. +4 −3 spec/ruby/library/socket/basicsocket/send_spec.rb
  129. +0 −23 spec/ruby/library/socket/fixtures/classes.rb
  130. +4 −4 spec/ruby/library/socket/ipsocket/addr_spec.rb
  131. +6 −5 spec/ruby/library/socket/ipsocket/peeraddr_spec.rb
  132. +3 −2 spec/ruby/library/socket/ipsocket/recvfrom_spec.rb
  133. +2 −2 spec/ruby/library/socket/shared/partially_closable_sockets.rb
  134. +4 −4 spec/ruby/library/socket/shared/recv_nonblock.rb
  135. +18 −18 spec/ruby/library/socket/socket/bind_spec.rb
  136. +13 −7 spec/ruby/library/socket/socket/connect_nonblock_spec.rb
  137. +3 −2 spec/ruby/library/socket/socket/for_fd_spec.rb
  138. +8 −8 spec/ruby/library/socket/socket/getnameinfo_spec.rb
  139. +1 −1 spec/ruby/library/socket/socket/listen_spec.rb
  140. +4 −4 spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb
  141. +2 −2 spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb
  142. +4 −3 spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb
  143. +7 −8 spec/ruby/library/socket/tcpserver/accept_spec.rb
  144. +1 −1 spec/ruby/library/socket/tcpserver/gets_spec.rb
  145. +1 −1 spec/ruby/library/socket/tcpserver/listen_spec.rb
  146. +17 −18 spec/ruby/library/socket/tcpserver/new_spec.rb
  147. +0 −9 spec/ruby/library/socket/tcpserver/output_spec.rb
  148. +0 −9 spec/ruby/library/socket/tcpserver/readpartial_spec.rb
  149. +3 −2 spec/ruby/library/socket/tcpserver/sysaccept_spec.rb
  150. +2 −3 spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb
  151. +7 −1 spec/ruby/library/socket/tcpsocket/shared/new.rb
  152. +13 −6 spec/ruby/library/socket/udpsocket/bind_spec.rb
  153. +0 −2 spec/ruby/library/socket/udpsocket/connect_spec.rb
  154. +0 −2 spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb
  155. +13 −9 spec/ruby/library/socket/udpsocket/send_spec.rb
  156. +3 −3 spec/ruby/library/socket/udpsocket/write_spec.rb
  157. +17 −21 spec/ruby/library/socket/unixserver/accept_spec.rb
  158. +1 −1 spec/ruby/library/stringio/printf_spec.rb
  159. +1 −1 spec/ruby/library/stringscanner/shared/matched_size.rb
  160. +8 −9 spec/ruby/library/zlib/deflate/params_spec.rb
  161. +43 −35 spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
  162. +59 −45 spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
  163. +6 −7 spec/ruby/library/zlib/gzipwriter/mtime_spec.rb
  164. +1 −1 spec/ruby/optional/capi/bignum_spec.rb
  165. +0 −10 spec/ruby/optional/capi/ext/jruby.h
  166. +0 −8 spec/ruby/optional/capi/ext/rubinius.h
  167. +0 −15 spec/ruby/optional/capi/ext/rubyspec.h
  168. +12 −10 spec/ruby/optional/capi/ext/thread_spec.c
  169. +0 −6 spec/ruby/optional/capi/ext/truffleruby.h
  170. +5 −3 spec/ruby/optional/capi/kernel_spec.rb
  171. +5 −3 spec/ruby/optional/capi/module_spec.rb
  172. +39 −108 spec/ruby/optional/capi/spec_helper.rb
  173. +1 −1 spec/ruby/optional/capi/string_spec.rb
  174. +44 −40 spec/ruby/optional/capi/time_spec.rb
1 change: 0 additions & 1 deletion spec/mspec/lib/mspec/commands/mspec-ci.rb
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@ def options(argv=ARGV)
options.chdir
options.prefix
options.configure { |f| load f }
options.name
options.pretend
options.interrupt

1 change: 0 additions & 1 deletion spec/mspec/lib/mspec/commands/mspec-run.rb
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ def options(argv=ARGV)
options.chdir
options.prefix
options.configure { |f| load f }
options.name
options.randomize
options.repeat
options.pretend
1 change: 0 additions & 1 deletion spec/mspec/lib/mspec/commands/mspec-tag.rb
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ def options(argv=ARGV)

options.doc "\n How to modify the execution"
options.configure { |f| load f }
options.name
options.pretend
options.unguarded
options.interrupt
26 changes: 19 additions & 7 deletions spec/mspec/lib/mspec/commands/mspec.rb
Original file line number Diff line number Diff line change
@@ -114,6 +114,7 @@ def multi_exec(argv)

puts children.map { |child| child.gets }.uniq
formatter.start
last_files = {}

until @files.empty?
IO.select(children)[0].each { |io|
@@ -127,22 +128,33 @@ def multi_exec(argv)
while chunk = (io.read_nonblock(4096) rescue nil)
reply += chunk
end
raise reply
reply.chomp!('.')
msg = "A child mspec-run process printed unexpected output on STDOUT"
if last_file = last_files[io]
msg += " while running #{last_file}"
end
abort "\n#{msg}: #{reply.inspect}"
end

unless @files.empty?
file = @files.shift
last_files[io] = file
io.puts file
end
io.puts @files.shift unless @files.empty?
}
end

ok = true
success = true
children.each { |child|
child.puts "QUIT"
Process.wait(child.pid)
ok &&= $?.success?
pid, status = Process.wait2(child.pid)
success &&= status.success?
child.close
}

formatter.aggregate_results(output_files)
formatter.finish
ok
success
end

def run
@@ -152,7 +164,7 @@ def run
argv.concat config[:flags]
argv.concat config[:loadpath]
argv.concat config[:requires]
argv << "#{MSPEC_HOME}/bin/mspec-#{ config[:command] || "run" }"
argv << "#{MSPEC_HOME}/bin/mspec-#{config[:command] || 'run'}"
argv.concat config[:options]

if config[:multi]
1 change: 0 additions & 1 deletion spec/mspec/lib/mspec/guards.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'mspec/utils/ruby_name'
require 'mspec/guards/block_device'
require 'mspec/guards/bug'
require 'mspec/guards/conflict'
6 changes: 2 additions & 4 deletions spec/mspec/lib/mspec/guards/block_device.rb
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@ def match?
end
end

class Object
def with_block_device(&block)
BlockDeviceGuard.new.run_if(:with_block_device, &block)
end
def with_block_device(&block)
BlockDeviceGuard.new.run_if(:with_block_device, &block)
end
6 changes: 2 additions & 4 deletions spec/mspec/lib/mspec/guards/bug.rb
Original file line number Diff line number Diff line change
@@ -23,8 +23,6 @@ def match?
end
end

class Object
def ruby_bug(bug, version, &block)
BugGuard.new(bug, version).run_unless(:ruby_bug, &block)
end
def ruby_bug(bug, version, &block)
BugGuard.new(bug, version).run_unless(:ruby_bug, &block)
end
14 changes: 6 additions & 8 deletions spec/mspec/lib/mspec/guards/conflict.rb
Original file line number Diff line number Diff line change
@@ -8,12 +8,10 @@ def match?
end
end

class Object
# In some cases, libraries will modify another Ruby method's
# behavior. The specs for the method's behavior will then fail
# if that library is loaded. This guard will not run if any of
# the specified constants exist in Object.constants.
def conflicts_with(*modules, &block)
ConflictsGuard.new(*modules).run_unless(:conflicts_with, &block)
end
# In some cases, libraries will modify another Ruby method's
# behavior. The specs for the method's behavior will then fail
# if that library is loaded. This guard will not run if any of
# the specified constants exist in Object.constants.
def conflicts_with(*modules, &block)
ConflictsGuard.new(*modules).run_unless(:conflicts_with, &block)
end
12 changes: 5 additions & 7 deletions spec/mspec/lib/mspec/guards/endian.rb
Original file line number Diff line number Diff line change
@@ -16,12 +16,10 @@ def match?
end
end

class Object
def big_endian(&block)
BigEndianGuard.new.run_if(:big_endian, &block)
end
def big_endian(&block)
BigEndianGuard.new.run_if(:big_endian, &block)
end

def little_endian(&block)
BigEndianGuard.new.run_unless(:little_endian, &block)
end
def little_endian(&block)
BigEndianGuard.new.run_unless(:little_endian, &block)
end
58 changes: 28 additions & 30 deletions spec/mspec/lib/mspec/guards/feature.rb
Original file line number Diff line number Diff line change
@@ -10,34 +10,32 @@ def match?
end
end

class Object
# Provides better documentation in the specs by
# naming sets of features that work together as
# a whole. Examples include :encoding, :fiber,
# :continuation, :fork.
#
# Usage example:
#
# with_feature :encoding do
# # specs for a method that provides aspects
# # of the encoding feature
# end
#
# Multiple features must all be enabled for the
# guard to run:
#
# with_feature :one, :two do
# # these specs will run if features :one AND
# # :two are enabled.
# end
#
# The implementation must explicitly enable a feature
# by adding code like the following to the .mspec
# configuration file:
#
# MSpec.enable_feature :encoding
#
def with_feature(*features, &block)
FeatureGuard.new(*features).run_if(:with_feature, &block)
end
# Provides better documentation in the specs by
# naming sets of features that work together as
# a whole. Examples include :encoding, :fiber,
# :continuation, :fork.
#
# Usage example:
#
# with_feature :encoding do
# # specs for a method that provides aspects
# # of the encoding feature
# end
#
# Multiple features must all be enabled for the
# guard to run:
#
# with_feature :one, :two do
# # these specs will run if features :one AND
# # :two are enabled.
# end
#
# The implementation must explicitly enable a feature
# by adding code like the following to the .mspec
# configuration file:
#
# MSpec.enable_feature :encoding
#
def with_feature(*features, &block)
FeatureGuard.new(*features).run_if(:with_feature, &block)
end
1 change: 0 additions & 1 deletion spec/mspec/lib/mspec/guards/guard.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'mspec/runner/mspec'
require 'mspec/runner/actions/tally'
require 'mspec/utils/ruby_name'

class SpecGuard
def self.report
16 changes: 7 additions & 9 deletions spec/mspec/lib/mspec/guards/platform.rb
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@ def self.implementation?(*args)
args.any? do |name|
case name
when :rubinius
RUBY_NAME.start_with?('rbx')
RUBY_ENGINE.start_with?('rbx')
when :ruby, :jruby, :truffleruby, :ironruby, :macruby, :maglev, :topaz, :opal
RUBY_NAME.start_with?(name.to_s)
RUBY_ENGINE.start_with?(name.to_s)
else
raise "unknown implementation #{name}"
end
@@ -67,12 +67,10 @@ def match?
end
end

class Object
def platform_is(*args, &block)
PlatformGuard.new(*args).run_if(:platform_is, &block)
end
def platform_is(*args, &block)
PlatformGuard.new(*args).run_if(:platform_is, &block)
end

def platform_is_not(*args, &block)
PlatformGuard.new(*args).run_unless(:platform_is_not, &block)
end
def platform_is_not(*args, &block)
PlatformGuard.new(*args).run_unless(:platform_is_not, &block)
end
6 changes: 2 additions & 4 deletions spec/mspec/lib/mspec/guards/quarantine.rb
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@ def match?
end
end

class Object
def quarantine!(&block)
QuarantineGuard.new.run_unless(:quarantine!, &block)
end
def quarantine!(&block)
QuarantineGuard.new.run_unless(:quarantine!, &block)
end
12 changes: 5 additions & 7 deletions spec/mspec/lib/mspec/guards/superuser.rb
Original file line number Diff line number Diff line change
@@ -6,12 +6,10 @@ def match?
end
end

class Object
def as_superuser(&block)
SuperUserGuard.new.run_if(:as_superuser, &block)
end
def as_superuser(&block)
SuperUserGuard.new.run_if(:as_superuser, &block)
end

def as_user(&block)
SuperUserGuard.new.run_unless(:as_user, &block)
end
def as_user(&block)
SuperUserGuard.new.run_unless(:as_user, &block)
end
6 changes: 2 additions & 4 deletions spec/mspec/lib/mspec/guards/support.rb
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@ def match?
end
end

class Object
def not_supported_on(*args, &block)
SupportedGuard.new(*args).run_unless(:not_supported_on, &block)
end
def not_supported_on(*args, &block)
SupportedGuard.new(*args).run_unless(:not_supported_on, &block)
end
6 changes: 2 additions & 4 deletions spec/mspec/lib/mspec/guards/version.rb
Original file line number Diff line number Diff line change
@@ -32,8 +32,6 @@ def match?
end
end

class Object
def ruby_version_is(*args, &block)
VersionGuard.new(*args).run_if(:ruby_version_is, &block)
end
def ruby_version_is(*args, &block)
VersionGuard.new(*args).run_if(:ruby_version_is, &block)
end
66 changes: 32 additions & 34 deletions spec/mspec/lib/mspec/helpers/argf.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
class Object
# Convenience helper for specs using ARGF.
# Set @argf to an instance of ARGF.class with the given +argv+.
# That instance must be used instead of ARGF as ARGF is global
# and it is not always possible to reset its state correctly.
#
# The helper yields to the block and then close
# the files open by the instance. Example:
#
# describe "That" do
# it "does something" do
# argf ['a', 'b'] do
# # do something
# end
# end
# end
def argf(argv)
if argv.empty? or argv.length > 2
raise "Only 1 or 2 filenames are allowed for the argf helper so files can be properly closed: #{argv.inspect}"
end
@argf ||= nil
raise "Cannot nest calls to the argf helper" if @argf
# Convenience helper for specs using ARGF.
# Set @argf to an instance of ARGF.class with the given +argv+.
# That instance must be used instead of ARGF as ARGF is global
# and it is not always possible to reset its state correctly.
#
# The helper yields to the block and then close
# the files open by the instance. Example:
#
# describe "That" do
# it "does something" do
# argf ['a', 'b'] do
# # do something
# end
# end
# end
def argf(argv)
if argv.empty? or argv.length > 2
raise "Only 1 or 2 filenames are allowed for the argf helper so files can be properly closed: #{argv.inspect}"
end
@argf ||= nil
raise "Cannot nest calls to the argf helper" if @argf

@argf = ARGF.class.new(*argv)
@__mspec_saved_argf_file__ = @argf.file
begin
yield
ensure
file1 = @__mspec_saved_argf_file__
file2 = @argf.file # Either the first file or the second
file1.close if !file1.closed? and file1 != STDIN
file2.close if !file2.closed? and file2 != STDIN
@argf = nil
@__mspec_saved_argf_file__ = nil
end
@argf = ARGF.class.new(*argv)
@__mspec_saved_argf_file__ = @argf.file
begin
yield
ensure
file1 = @__mspec_saved_argf_file__
file2 = @argf.file # Either the first file or the second
file1.close if !file1.closed? and file1 != STDIN
file2.close if !file2.closed? and file2 != STDIN
@argf = nil
@__mspec_saved_argf_file__ = nil
end
end
Loading