Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4342,9 +4342,6 @@ AS_IF([test -n "${LIBS}"], [
MAINFLAGS=`echo " $MAINLIBS " | sed "s|$libspat"'||;s/^ *//;s/ *$//'`
])
LIBRUBYARG_STATIC="${LIBRUBYARG_STATIC} \$(MAINLIBS)"
AS_IF([test "$enable_shared" = yes], [
LIBRUBYARG_SHARED="${LIBRUBYARG_SHARED} \$(MAINLIBS)"
])
CPPFLAGS="$CPPFLAGS "'$(DEFS) ${cppflags}'
AS_IF([test -n "${cflags+set}"], [
cflagspat=`eval echo '"'"${cflags}"'"' | sed 's/[[][|.*]]/\\&/g;s/^ */ /;s/^ *$/ /'`
Expand Down
2 changes: 1 addition & 1 deletion template/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ miniruby$(EXEEXT):
$(PROGRAM):
@$(RM) $@
$(ECHO) linking $@
$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(EXTLIBS) $(OUTFLAG)$@
$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(EXTLIBS) $(OUTFLAG)$@
$(Q) $(POSTLINK)

$(PROGRAM): @XRUBY_LIBPATHENV_WRAPPER@
Expand Down
4 changes: 1 addition & 3 deletions test/ruby/test_gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,8 @@ def test_thrashing_for_young_objects
debug_msg = "before_stats: #{before_stats}\nbefore_stat_heap: #{before_stat_heap}\nafter_stats: #{after_stats}\nafter_stat_heap: #{after_stat_heap}"
# Should not be thrashing in page creation
assert_equal before_stats[:heap_allocated_pages], after_stats[:heap_allocated_pages], debug_msg
assert_in_epsilon before_stats[:heap_allocated_pages], after_stats[:heap_allocated_pages], 0.5, debug_msg
assert_equal 0, after_stats[:total_freed_pages], debug_msg
# Only young objects, so should not trigger major GC
assert_equal before_stats[:major_gc_count], after_stats[:major_gc_count], debug_msg
RUBY
end

Expand Down
56 changes: 36 additions & 20 deletions tool/lib/colorize.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# frozen-string-literal: true

# Decorate TTY output using ANSI Select Graphic Rendition control
# sequences.
class Colorize
# call-seq:
# Colorize.new(colorize = nil)
# Colorize.new(color: color, colors_file: colors_file)
def initialize(color = nil, opts = ((_, color = color, nil)[0] if Hash === color))
#
# Creates and load color settings.
def initialize(_color = nil, color: _color, colors_file: nil)
@colors = nil
@color = opts && opts[:color] || color
@color = color
if color or (color == nil && coloring?)
if (%w[smso so].any? {|attr| /\A\e\[.*m\z/ =~ IO.popen("tput #{attr}", "r", :err => IO::NULL, &:read)} rescue nil)
if (%w[smso so].any? {|attr| /\A\e\[.*m\z/ =~ IO.popen("tput #{attr}", "r", err: IO::NULL, &:read)} rescue nil)
@beg = "\e["
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
if opts and colors_file = opts[:colors_file]
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(COLORS_PATTERN)] : {}
if colors_file
begin
File.read(colors_file).scan(/(\w+)=([^:\n]*)/) do |n, c|
File.read(colors_file).scan(COLORS_PATTERN) do |n, c|
colors[n] ||= c
end
rescue Errno::ENOENT
Expand All @@ -25,22 +29,28 @@ def initialize(color = nil, opts = ((_, color = color, nil)[0] if Hash === color
self
end

COLORS_PATTERN = /(\w+)=([^:\n]*)/
private_constant :COLORS_PATTERN

DEFAULTS = {
# color names
"black"=>"30", "red"=>"31", "green"=>"32", "yellow"=>"33",
"blue"=>"34", "magenta"=>"35", "cyan"=>"36", "white"=>"37",
"bold"=>"1", "faint"=>"2", "underline"=>"4", "reverse"=>"7",
"bright_black"=>"90", "bright_red"=>"91", "bright_green"=>"92", "bright_yellow"=>"93",
"bright_blue"=>"94", "bright_magenta"=>"95", "bright_cyan"=>"96", "bright_white"=>"97",
"bg_black"=>"40", "bg_red"=>"41", "bg_green"=>"42", "bg_yellow"=>"43",
"bg_blue"=>"44", "bg_magenta"=>"45", "bg_cyan"=>"46", "bg_white"=>"47",
"bg_bright_black"=>"100", "bg_bright_red"=>"101",
"bg_bright_green"=>"102", "bg_bright_yellow"=>"103",
"bg_bright_blue"=>"104", "bg_bright_magenta"=>"105",
"bg_bright_cyan"=>"106", "bg_bright_white"=>"107",

# abstract decorations
"pass"=>"green", "fail"=>"red;bold", "skip"=>"yellow;bold",
"note"=>"bright_yellow", "notice"=>"bright_yellow", "info"=>"bright_magenta",
}

def coloring?
STDOUT.tty? && (!(nc = ENV['NO_COLOR']) || nc.empty?)
end
}.freeze
private_constant :DEFAULTS

# colorize.decorate(str, name = color_name)
def decorate(str, name = @color)
Expand All @@ -51,6 +61,18 @@ def decorate(str, name = @color)
end
end

DEFAULTS.each_key do |name|
define_method(name) {|str|
decorate(str, name)
}
end

private

def coloring?
STDOUT.tty? && (!(nc = ENV['NO_COLOR']) || nc.empty?)
end

def resolve_color(color = @color, seen = {}, colors = nil)
return unless @colors
color.to_s.gsub(/\b[a-z][\w ]+/) do |n|
Expand All @@ -70,28 +92,22 @@ def resolve_color(color = @color, seen = {}, colors = nil)

def reset_color(colors)
resets = []
colors.scan(/\G;*\K(?:[34]8;5;\d+|2(?:;\d+){3}|\d+)/) do |c|
colors.scan(/\G;*\K(?:[34]8;(?:5;\d+|2(?:;\d+){3})|\d+)/) do |c|
case c
when '1', '2'
resets << '22'
when '4'
resets << '24'
when '7'
resets << '27'
when /\A3\d\z/
when /\A[39]\d(?:;|\z)/
resets << '39'
when /\A4\d\z/
when /\A(?:4|10)\d(?:;|\z)/
resets << '49'
end
end
"#{@beg}#{resets.reverse.join(';')}m"
end

DEFAULTS.each_key do |name|
define_method(name) {|str|
decorate(str, name)
}
end
end

if $0 == __FILE__
Expand Down