mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Don't use failure location in failed example block output
This is problematic, since the failure could have ocurred outside the example block (in a method call). The comment line under the failure details will still point to the result location, if it's available.
This commit is contained in:
parent
81f1966417
commit
7cb1545e83
3 changed files with 5 additions and 12 deletions
|
@ -1,14 +1,11 @@
|
|||
require "../../example"
|
||||
require "../../location"
|
||||
require "./comment"
|
||||
|
||||
module Spectator::Formatting::Components
|
||||
# Provides syntax for running a specific example from the command-line.
|
||||
struct ExampleCommand
|
||||
# Creates the component with the specified example.
|
||||
# The location can be overridden, for instance, pointing to a problematic line in the example.
|
||||
# Otherwise the example's location is used.
|
||||
def initialize(@example : Example, @location : Location? = nil)
|
||||
def initialize(@example : Example)
|
||||
end
|
||||
|
||||
# Produces output for running the previously specified example.
|
||||
|
@ -17,7 +14,7 @@ module Spectator::Formatting::Components
|
|||
|
||||
# Use location for argument if it's available, since it's simpler.
|
||||
# Otherwise, use the example name filter argument.
|
||||
if location = (@location || @example.location?)
|
||||
if location = @example.location?
|
||||
io << location
|
||||
else
|
||||
io << "-e " << @example
|
||||
|
|
|
@ -14,12 +14,7 @@ module Spectator::Formatting::Components
|
|||
io.puts "Failed examples:"
|
||||
io.puts
|
||||
@failures.each do |failure|
|
||||
# Use failed location if it's available.
|
||||
if (result = failure.result).responds_to?(:location)
|
||||
location = result.location
|
||||
end
|
||||
|
||||
io.puts ExampleCommand.new(failure, location).colorize(:red)
|
||||
io.puts ExampleCommand.new(failure).colorize(:red)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,8 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
end
|
||||
|
||||
# Produces the (example) location line.
|
||||
# Produces the location line.
|
||||
# This is where the result was determined.
|
||||
private def location_line(io)
|
||||
location = if (result = @example.result).responds_to?(:location)
|
||||
result.location
|
||||
|
|
Loading…
Reference in a new issue