mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Store tags with an optional string value
This commit is contained in:
parent
d9088b39ca
commit
4a9ec3df4a
4 changed files with 11 additions and 6 deletions
|
@ -6,15 +6,15 @@ module Spectator::DSL
|
|||
private macro _spectator_tags(name, source, *tags, **metadata)
|
||||
private def self.{{name.id}}
|
||||
%tags = {{source.id}}
|
||||
{% unless tags.empty? %}
|
||||
%tags.concat({ {{tags.map(&.id.symbolize).splat}} })
|
||||
{% for k in tags %}
|
||||
%tags[{{k.id.symbolize}}] = nil
|
||||
{% end %}
|
||||
{% for k, v in metadata %}
|
||||
%cond = begin
|
||||
{{v}}
|
||||
end
|
||||
if %cond
|
||||
%tags.add({{k.id.symbolize}})
|
||||
%tags[{{k.id.symbolize}}] = %cond
|
||||
else
|
||||
%tags.delete({{k.id.symbolize}})
|
||||
end
|
||||
|
|
|
@ -75,7 +75,8 @@ module Spectator
|
|||
# Note: The tags will not be merged with the parent tags.
|
||||
def self.pending(name : String? = nil, location : Location? = nil,
|
||||
group : ExampleGroup? = nil, tags = Tags.new)
|
||||
new(name, location, group, tags.add(:pending)) { nil }
|
||||
tags = tags.merge({:pending => nil}) { |_, v, _| v } # Add pending tag if it doesn't exist.
|
||||
new(name, location, group, tags) { nil }
|
||||
end
|
||||
|
||||
# Executes the test case.
|
||||
|
|
|
@ -43,7 +43,7 @@ module Spectator
|
|||
# Checks if the node has been marked as pending.
|
||||
# Pending items should be skipped during execution.
|
||||
def pending?
|
||||
tags.includes?(:pending)
|
||||
tags.has_key?(:pending)
|
||||
end
|
||||
|
||||
# Constructs the full name or description of the node.
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
module Spectator
|
||||
# User-defined keywords used for filtering and behavior modification.
|
||||
alias Tags = Set(Symbol)
|
||||
# The value of a tag is optional, but may contain useful information.
|
||||
# If the value is nil, the tag exists, but has no data.
|
||||
# However, when tags are given on examples and example groups,
|
||||
# if the value is falsey (false or nil), then the tag should be removed from the overall collection.
|
||||
alias Tags = Hash(Symbol, String?)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue