Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure test file generation is consistent #71

Merged
merged 2 commits into from
Mar 11, 2024
Merged

Conversation

phillord
Copy link
Owner

@phillord phillord commented Mar 8, 2024

Previously, test files were generated in a variety of different ways, both manually and using bubo; it was often unclear why files were generated like this. Where it is possible to do, test files are now generated using bubo consistently.

An upper level make file has been added for convenience, and a README file which documents the generation of these files.

DataUnionOf constructs are now supported, and the erroneous test file that was hiding this breakage has been updated.

Previously, test files were generated in a variety of different ways, both manually and using bubo; it was often unclear why files were generated like this. Where it is possible to do, test files are now generated using bubo consistently.

An upper level make file has been added for convenience, and a README file which documents the generation of these files.

DataUnionOf constructs are now supported, and the erroneous test file that was hiding this breakage has been updated.
@althonos
Copy link
Collaborator

althonos commented Mar 8, 2024

Any way to avoid the whitespaces and comments in the OWL Functional files? This is gonna be a bit more tedious for roundtripping...

@phillord
Copy link
Owner Author

phillord commented Mar 9, 2024

Hmmm. Not straight-forwardly. The files are written by the OWL API and I don't control the whitespace (unless it is configurable in the OWL API).

What is the problem with roundtripping? Are you not comparing the semantics?

Getting horned-owl to be compatible with the OWL API white space is going to be a pain.

@althonos
Copy link
Collaborator

althonos commented Mar 9, 2024

No, the roundtripping is comparing the result of the serializer after parsing, so I'm also comparing syntax, that's why I had the OWL functional files formatted that way. I could probably add support for writing comments in a very weird and broken way buy I don't think we should be testing that, in theory the OWL Functional syntax does not even need to have newlines between the different axioms...

@phillord
Copy link
Owner Author

I use multi-tripping -- read an ontology, save it, read the saved version, the compare the semantics of the original to the generated.

It has it's flaws - errors paired in parser and renderer are missed, but it does seem to mostly work. For the rest, I put in specific checks of semantics into the rust test files.

I did used to keep a file that I have generated using horned and then parse that which was useful in the early days, but this patch actually removes it. That is also a possibility -- we could generate four or five functional files, using horned, put them into the manual directory and not autogenerate them. This way you could be testing horned files against horned files, so the white space should be consistent.

@althonos
Copy link
Collaborator

Ok that works, I'll use the multi-tripping for testing 👍

@phillord
Copy link
Owner Author

The other thing that I do is check that the reader works by checking that the ontology from an RDF file is the same as the ontology from an XML file.

With this new directory structure, actually, it is now clear which files should be semantically identical because they are autogenerated. So, I could simplify the test structure in both XML reader and writer by autogenerating all of the tests with a macro maybe.

That would mean that all of the tests of specific semantics could be in one place (the XML reader probably). Any other reader/writer would only need to write syntax specific tests.

@filippodebortoli
Copy link
Collaborator

The other thing that I do is check that the reader works by checking that the ontology from an RDF file is the same as the ontology from an XML file.

With this new directory structure, actually, it is now clear which files should be semantically identical because they are autogenerated. So, I could simplify the test structure in both XML reader and writer by autogenerating all of the tests with a macro maybe.

That would mean that all of the tests of specific semantics could be in one place (the XML reader probably). Any other reader/writer would only need to write syntax specific tests.

Could it make sense to have these compatibility tests sitting in io/mod.rs, having a io::test module?

For the test files that are generated using bubo, there could be a unique test that loops over the files contained in ont/bubo and for each entry picks up the generated files, parses them and compares the obtained ontologies. With this approach we avoid writing declarative macros, and we should still be able to pinpoint a failure in the test to a specific .clj file and related serializations in other formats.

@phillord
Copy link
Owner Author

Yes, we could move everything to mod.rs. That would make more sense and would cover everything. We can then document which is the "primary" format that we care about where we run the semantic tests -- this is XML at the moment because it is the one I wrote first.

I thought about having a single loop which tests all the files. But this is clunky from the test side, blocks parallelization and earlier failures mask later ones. There is https://github.com/frehberg/test-generator which seems to be aimed at exactly this problem.

@phillord
Copy link
Owner Author

If everyone one is happy, I will merge this to devel. Future enhancements, like automating the test can go into another PR.

@filippodebortoli
Copy link
Collaborator

filippodebortoli commented Mar 11, 2024

If everyone one is happy, I will merge this to devel. Future enhancements, like automating the test can go into another PR.

I have nothing against you merging onto devel. 👍

@phillord phillord merged commit 25fa218 into devel Mar 11, 2024
2 checks passed
@filippodebortoli filippodebortoli deleted the fix/clean-test-files branch March 12, 2024 09:47
@althonos
Copy link
Collaborator

@phillord : Just realized that this produces invalid IRIs in the prefixes:

Prefix(:=<o>)

In here <o> is a quoted IRI but o is not a valid IRI as per RFC 3987.

@phillord
Copy link
Owner Author

Now that is strange. It should be showing

o:=http://www.example.com

This looks like an OWL API bug, though. Can you create the same ontology in the OWL API (or protege) and see what that produces?

@phillord
Copy link
Owner Author

@ignazio1977 Do you know about this one? Is the OWL API generating the right thing here?

@ignazio1977
Copy link

@phillord is there a small example that shows what's going on?

@phillord
Copy link
Owner Author

@ignazio1977
Copy link

Interesting - the prefix isn't actually used in the ontologies, if I'm not mistaken.

@phillord
Copy link
Owner Author

The URL for the prefix is the default namespace, so the prefix itself isn't used no.

This is generated by Tawny-OWL, so it's built on version 4 of the OWL API. I need to switch at some point, but it will need time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants