Skip to content

Instantly share code, notes, and snippets.

@zenspider
Last active July 15, 2024 18:46
Show Gist options
  • Save zenspider/6c2313d164f0df1b0e33e03649d44bec to your computer and use it in GitHub Desktop.
Save zenspider/6c2313d164f0df1b0e33e03649d44bec to your computer and use it in GitHub Desktop.
# NOTE: ironically, this breaks if using Werror + frozen-string-literals
def summary # :nodoc:
extra = ""
extra = "\n\nYou have skipped tests. Run with --verbose for details." if
results.any?(&:skipped?) unless
options[:verbose] or options[:show_skips] or ENV["MT_NO_SKIP_MSG"]
extra.prepend ", %d warnings" % [warnings] if options[:Werror]
"%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
[count, assertions, failures, errors, skips, extra]
end
# NOTE: make mutable strings
def summary2 # :nodoc:
extra = +""
extra = +"\n\nYou have skipped tests. Run with --verbose for details." if
results.any?(&:skipped?) unless
options[:verbose] or options[:show_skips] or ENV["MT_NO_SKIP_MSG"]
extra.prepend ", %d warnings" % [warnings] if options[:Werror]
"%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
[count, assertions, failures, errors, skips, extra]
end
# NOTE: Rearrange order to avoid prepend, use +=
def summary3 # :nodoc:
extra = ""
extra += ", %d warnings" % [warnings] if options[:Werror]
extra += "\n\nYou have skipped tests. Run with --verbose for details." if
results.any?(&:skipped?) unless
options[:verbose] or options[:show_skips] or ENV["MT_NO_SKIP_MSG"]
"%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
[count, assertions, failures, errors, skips, extra]
end
# NOTE: condition the original format string to include warnings
def summary4 # :nodoc:
extra = ""
extra = "\n\nYou have skipped tests. Run with --verbose for details." if
results.any?(&:skipped?) unless
options[:verbose] or options[:show_skips] or ENV["MT_NO_SKIP_MSG"]
if options[:Werror] then
"%d runs, %d assertions, %d failures, %d errors, %d skips, %d warnings%s" %
[count, assertions, failures, errors, skips, warnings, extra]
else
"%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
[count, assertions, failures, errors, skips, extra]
end
end
# NOTE: make extra an array
def summary5 # :nodoc:
extra = []
extra << "\n\nYou have skipped tests. Run with --verbose for details." if
results.any?(&:skipped?) unless
options[:verbose] or options[:show_skips] or ENV["MT_NO_SKIP_MSG"]
extra.prepend ", %d warnings" % [warnings] if options[:Werror]
"%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
[count, assertions, failures, errors, skips, extra.join]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment