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 macro _spectator_tags(name, source, *tags, **metadata)
|
||||||
private def self.{{name.id}}
|
private def self.{{name.id}}
|
||||||
%tags = {{source.id}}
|
%tags = {{source.id}}
|
||||||
{% unless tags.empty? %}
|
{% for k in tags %}
|
||||||
%tags.concat({ {{tags.map(&.id.symbolize).splat}} })
|
%tags[{{k.id.symbolize}}] = nil
|
||||||
{% end %}
|
{% end %}
|
||||||
{% for k, v in metadata %}
|
{% for k, v in metadata %}
|
||||||
%cond = begin
|
%cond = begin
|
||||||
{{v}}
|
{{v}}
|
||||||
end
|
end
|
||||||
if %cond
|
if %cond
|
||||||
%tags.add({{k.id.symbolize}})
|
%tags[{{k.id.symbolize}}] = %cond
|
||||||
else
|
else
|
||||||
%tags.delete({{k.id.symbolize}})
|
%tags.delete({{k.id.symbolize}})
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,7 +75,8 @@ module Spectator
|
||||||
# Note: The tags will not be merged with the parent tags.
|
# Note: The tags will not be merged with the parent tags.
|
||||||
def self.pending(name : String? = nil, location : Location? = nil,
|
def self.pending(name : String? = nil, location : Location? = nil,
|
||||||
group : ExampleGroup? = nil, tags = Tags.new)
|
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
|
end
|
||||||
|
|
||||||
# Executes the test case.
|
# Executes the test case.
|
||||||
|
|
|
@ -43,7 +43,7 @@ module Spectator
|
||||||
# Checks if the node has been marked as pending.
|
# Checks if the node has been marked as pending.
|
||||||
# Pending items should be skipped during execution.
|
# Pending items should be skipped during execution.
|
||||||
def pending?
|
def pending?
|
||||||
tags.includes?(:pending)
|
tags.has_key?(:pending)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Constructs the full name or description of the node.
|
# Constructs the full name or description of the node.
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
module Spectator
|
module Spectator
|
||||||
# User-defined keywords used for filtering and behavior modification.
|
# 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
|
end
|
||||||
|
|
Loading…
Reference in a new issue