1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-04-27 18:53:20 +02:00
parent 80be9e986b
commit 00c33d9c23
5 changed files with 77 additions and 9 deletions

View file

@ -1,4 +1,6 @@
TOLERANCE = 0.00003 unless Object.const_defined?(:TOLERANCE)
# To account for GC, context switches, other processes, load, etc.
TIME_TOLERANCE = 20.0 unless Object.const_defined?(:TIME_TOLERANCE)
class BeCloseMatcher
def initialize(expected, tolerance)

View file

@ -11,8 +11,8 @@ class Object
MSpec.describe mod, msg, &block
end
private def it(msg, &block)
MSpec.current.it msg, &block
private def it(desc, &block)
MSpec.current.it desc, &block
end
private def it_should_behave_like(desc)

View file

@ -1,4 +1,6 @@
# Remove old version guards in ruby/spec
# Removes old version guards in ruby/spec.
# Run it from the ruby/spec repository root.
# The argument is the new minimum supported version.
def dedent(line)
if line.start_with?(" ")
@ -8,9 +10,13 @@ def dedent(line)
end
end
def each_spec_file(&block)
Dir["*/**/*.rb"].each(&block)
end
def remove_guards(guard, keep)
Dir["*/**/*.rb"].each do |file|
contents = File.read(file)
each_spec_file do |file|
contents = File.binread(file)
if contents =~ guard
puts file
lines = contents.lines.to_a
@ -31,11 +37,29 @@ def remove_guards(guard, keep)
lines[first..last] = []
end
end
File.write file, lines.join
File.binwrite file, lines.join
end
end
end
version = (ARGV[0] || "2.3")
def search(regexp)
each_spec_file do |file|
contents = File.binread(file)
if contents =~ regexp
puts file
contents.each_line do |line|
if line =~ regexp
puts line
end
end
end
end
end
version = Regexp.escape(ARGV.fetch(0))
remove_guards(/ruby_version_is ["']#{version}["'] do/, true)
remove_guards(/ruby_version_is ["'][0-9.]*["']...["']#{version}["'] do/, false)
remove_guards(/ruby_bug "#\d+", ["'][0-9.]*["']...["']#{version}["'] do/, true)
search(/["']#{version}["']/)
search(/^\s*#.+#{version}/)

View file

@ -18,6 +18,9 @@ IMPLS = {
MSPEC = ARGV.delete('--mspec')
CHECK_LAST_MERGE = ENV['CHECK_LAST_MERGE'] != 'false'
TEST_TRUNK = ENV['TEST_TRUNK'] != 'false'
MSPEC_REPO = File.expand_path("../../..", __FILE__)
raise MSPEC_REPO if !Dir.exist?(MSPEC_REPO) or !Dir.exist?("#{MSPEC_REPO}/.git")
@ -144,7 +147,7 @@ def rebase_commits(impl)
commit_date = Time.at(Integer(commit_timestamp))
days_since_last_merge = (NOW-commit_date) / 86400
if days_since_last_merge > 60
if CHECK_LAST_MERGE and days_since_last_merge > 60
raise "#{days_since_last_merge.floor} days since last merge, probably wrong commit"
end
@ -177,7 +180,7 @@ def test_new_specs
run_test[min_version]
run_test[max_version]
run_test["trunk"]
run_test["trunk"] if TEST_TRUNK
end
end

View file

@ -0,0 +1,39 @@
# Adds tags based on error and failures output (e.g., from a CI log),
# without running any spec code.
tags_dir = %w[
spec/tags
spec/tags/ruby
].find { |dir| Dir.exist?("#{dir}/language") }
abort 'Could not find tags directory' unless tags_dir
output = ARGF.readlines
# Remove leading "[exec] " from JRuby logs
output = output.map { |line| line.sub(/^\[exec\] /, '') }
NUMBER = /^\d+\)$/
ERROR_OR_FAILED = / (ERROR|FAILED)$/
SPEC_FILE = /^(\/.+_spec\.rb)\:\d+/
failures = output.slice_before(NUMBER).select { |number, error_line, *rest|
number =~ NUMBER and error_line =~ ERROR_OR_FAILED
}.each { |number, error_line, *rest|
description = error_line.match(ERROR_OR_FAILED).pre_match
spec_file = rest.find { |line| line =~ SPEC_FILE }
spec_file = spec_file[SPEC_FILE, 1]
prefix = spec_file.index('spec/ruby')
spec_file = spec_file[prefix..-1]
tags_file = spec_file.sub('spec/ruby/', "#{tags_dir}/").sub(/_spec\.rb$/, '_tags.txt')
dir = File.dirname(tags_file)
Dir.mkdir(dir) unless Dir.exist?(dir)
tag_line = "fails:#{description}"
unless File.exist?(tags_file) and File.readlines(tags_file, chomp: true).include?(tag_line)
File.open(tags_file, 'a') do |f|
f.puts tag_line
end
end
}