Use the manifest file on the Turtle-star test suite
This commit is contained in:
parent
3acda86d7e
commit
e230860bbc
2 changed files with 55 additions and 27 deletions
|
@ -7,34 +7,39 @@ defmodule RDF.Star.Turtle.W3C.EvalTest do
|
|||
|
||||
use ExUnit.Case, async: false
|
||||
|
||||
@turtle_star_eval_test_suite Path.join(RDF.TestData.dir(), "rdf-star/turtle/eval")
|
||||
alias RDF.{Turtle, TestSuite, NTriples}
|
||||
alias TestSuite.NS.RDFT
|
||||
|
||||
ExUnit.Case.register_attribute(__ENV__, :turtle_test)
|
||||
@path RDF.TestData.path("rdf-star/turtle/eval")
|
||||
@base "http://example/base/"
|
||||
@manifest TestSuite.manifest_path(@path) |> TestSuite.manifest_graph(base: @base)
|
||||
|
||||
@turtle_star_eval_test_suite
|
||||
|> File.ls!()
|
||||
|> Enum.filter(fn file -> Path.extname(file) == ".ttl" and file != "manifest.ttl" end)
|
||||
|> Enum.each(fn file ->
|
||||
base = Path.basename(file, ".ttl")
|
||||
TestSuite.test_cases(@manifest, RDFT.TestTurtleEval)
|
||||
|> Enum.each(fn test_case ->
|
||||
@tag test_case: test_case
|
||||
|
||||
if base in [
|
||||
if (test_case |> TestSuite.test_input_file_path(@path) |> Path.basename(".ttl")) in [
|
||||
"turtle-star-eval-bnode-1",
|
||||
"turtle-star-eval-bnode-2",
|
||||
# TODO: this one just fails, because our blank node counter starts at 0 instead of 1
|
||||
"turtle-star-eval-annotation-2"
|
||||
] do
|
||||
@tag earl_result: :passed
|
||||
@tag earl_mode: :semi_auto
|
||||
@tag skip: """
|
||||
The produced graphs are correct, but have different blank node labels than the result graph.
|
||||
TODO: Implement a graph isomorphism algorithm.
|
||||
"""
|
||||
end
|
||||
|
||||
@turtle_test ttl_file: Path.join(@turtle_star_eval_test_suite, file),
|
||||
nt_file: Path.join(@turtle_star_eval_test_suite, base <> ".nt")
|
||||
test "eval test: #{file}", context do
|
||||
assert RDF.Turtle.read_file!(context.registered.turtle_test[:ttl_file])
|
||||
|> RDF.Graph.clear_metadata() ==
|
||||
RDF.NTriples.read_file!(context.registered.turtle_test[:nt_file])
|
||||
test TestSuite.test_title(test_case), %{test_case: test_case} do
|
||||
assert RDF.Graph.equal?(
|
||||
TestSuite.test_input_file_path(test_case, @path)
|
||||
|> Turtle.read_file!()
|
||||
|> RDF.Graph.clear_metadata(),
|
||||
TestSuite.test_result_file_path(test_case, @path)
|
||||
|> NTriples.read_file!()
|
||||
)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -7,22 +7,45 @@ defmodule RDF.Star.Turtle.W3C.SyntaxTest do
|
|||
|
||||
use ExUnit.Case, async: false
|
||||
|
||||
@turtle_star_syntax_test_suite Path.join(RDF.TestData.dir(), "rdf-star/turtle/syntax")
|
||||
alias RDF.{Turtle, TestSuite}
|
||||
alias TestSuite.NS.RDFT
|
||||
|
||||
ExUnit.Case.register_attribute(__ENV__, :turtle_test)
|
||||
@path RDF.TestData.path("rdf-star/turtle/syntax")
|
||||
@base "http://example/base/"
|
||||
@manifest TestSuite.manifest_path(@path) |> TestSuite.manifest_graph(base: @base)
|
||||
|
||||
@turtle_star_syntax_test_suite
|
||||
|> File.ls!()
|
||||
|> Enum.filter(fn file -> Path.extname(file) == ".ttl" and file != "manifest.ttl" end)
|
||||
|> Enum.each(fn file ->
|
||||
@turtle_test file: Path.join(@turtle_star_syntax_test_suite, file)
|
||||
if file |> String.contains?("-bad-") do
|
||||
test "Negative syntax test: #{file}", context do
|
||||
assert {:error, _} = RDF.Turtle.read_file(context.registered.turtle_test[:file])
|
||||
TestSuite.test_cases(@manifest, RDFT.TestTurtlePositiveSyntax)
|
||||
|> Enum.each(fn test_case ->
|
||||
@tag test_case: test_case
|
||||
test TestSuite.test_title(test_case), %{test_case: test_case} do
|
||||
with base = to_string(TestSuite.test_input_file(test_case)) do
|
||||
assert {:ok, _} =
|
||||
TestSuite.test_input_file_path(test_case, @path)
|
||||
|> Turtle.read_file(base: base)
|
||||
end
|
||||
else
|
||||
test "Positive syntax test: #{file}", context do
|
||||
assert {:ok, %RDF.Graph{}} = RDF.Turtle.read_file(context.registered.turtle_test[:file])
|
||||
end
|
||||
end)
|
||||
|
||||
TestSuite.test_cases(@manifest, RDFT.TestNTriplesPositiveSyntax)
|
||||
|> Enum.each(fn test_case ->
|
||||
@tag test_case: test_case
|
||||
test TestSuite.test_title(test_case), %{test_case: test_case} do
|
||||
with base = to_string(TestSuite.test_input_file(test_case)) do
|
||||
assert {:ok, _} =
|
||||
TestSuite.test_input_file_path(test_case, @path)
|
||||
|> Turtle.read_file(base: base)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
TestSuite.test_cases(@manifest, RDFT.TestTurtleNegativeSyntax)
|
||||
|> Enum.each(fn test_case ->
|
||||
@tag test_case: test_case
|
||||
test TestSuite.test_title(test_case), %{test_case: test_case} do
|
||||
with base = to_string(TestSuite.test_input_file(test_case)) do
|
||||
assert {:error, _} =
|
||||
TestSuite.test_input_file_path(test_case, @path)
|
||||
|> Turtle.read_file(base: base)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue