Skip to content

Commit

Permalink
Handle test options (for hashAlgorithm) differently.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Aug 30, 2023
1 parent ddfffda commit f51bcb9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions script/tc
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ def run_tc(tc, **options)
begin
puts "open #{tc.action}" if options[:verbose]
options = {base_uri: tc.base}.merge(options)
options[:hash_algorithm] = options.delete(:algorithm).to_sym if options[:algorithm]

dataset = RDF::Repository.load(tc.action, format: :nquads)
result = if tc.type == 'rdfc:RDFC10MapTest'
input_map = RDF::Normalize::RDFC10.new(dataset, **options).to_hash
input_map = RDF::Normalize::RDFC10.new(dataset, **tc.writer_options.merge(options)).to_hash
result_map = JSON.load(tc.expected)
output = input_map.to_json(JSON::LD::JSON_STATE)
input_map == result_map ? "passed" : "failed"
elsif tc.type == 'rdfc:RDFC10NegativeEvalTest'
begin
RDF::Normalize::RDFC10.new(dataset, **options).to_hash
RDF::Normalize::RDFC10.new(dataset, **tc.writer_options.merge(options)).to_hash
"failed" # Should raise exception
rescue ::RDF::Normalize::MaxCallsExceeded
"passed"
Expand Down
1 change: 1 addition & 0 deletions spec/suite_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def expected
def writer_options
res = {}
res[:algorithm] = type.sub('rdfc:', '').sub('EvalTest', '').downcase.to_sym
res[:hash_algorithm] = hashAlgorithm.to_sym if hashAlgorithm
res
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/suite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
t.logger = RDF::Spec.logger
dataset = RDF::Repository.load(t.action, format: :nquads)
if t.type == 'rdfc:RDFC10MapTest'
input_map = RDF::Normalize::RDFC10.new(dataset).to_hash
input_map = RDF::Normalize::RDFC10.new(dataset, **t.writer_options).to_hash
result_map = JSON.load(t.expected)
expect(input_map).to produce(result_map, t)
elsif t.type == 'rdfc:RDFC10NegativeEvalTest'
Expand Down

0 comments on commit f51bcb9

Please sign in to comment.