diff --git a/.gitignore b/.gitignore index 022ac422..665eab28 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,9 @@ lib/PyLD.egg-info profiler tests/test_caching.py tests/data/test_caching.json + +# Local Python version with `pyenv` +.python-version + +# PyCharm & other JetBrains IDEs +.idea diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..92fcb2e6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,11 @@ +[submodule "specifications/json-ld-api"] + path = specifications/json-ld-api + url = git@github.com:w3c/json-ld-api.git + +[submodule "specifications/json-ld-framing"] + path = specifications/json-ld-framing + url = git@github.com:w3c/json-ld-framing.git + +[submodule "specifications/rdf-dataset-canonicalization"] + path = specifications/rdf-dataset-canonicalization + url = git@github.com:w3c-ccg/rdf-dataset-canonicalization.git diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..effc1641 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +upgrade-submodules: + git submodule update --remote --init --recursive + +test: + python tests/runtests.py diff --git a/README.rst b/README.rst index 978d9774..2cc24857 100644 --- a/README.rst +++ b/README.rst @@ -190,16 +190,27 @@ Tests This library includes a sample testing utility which may be used to verify that changes to the processor maintain the correct output. -To run the sample tests you will need to get the test suite files by cloning -the ``json-ld-api``, ``json-ld-framing``, and ``normalization`` repositories -hosted on GitHub: +To run the sample tests you will need the test suite files provided in the +``json-ld-api``, ``json-ld-framing``, and ``rdf-dataset-canonicalization`` +repositories hosted +on GitHub: - https://github.com/w3c/json-ld-api - https://github.com/w3c/json-ld-framing -- https://github.com/json-ld/normalization +- https://github.com/w3c-ccg/rdf-dataset-canonicalization -If the suites repositories are available as sibling directories of the PyLD -source directory, then all the tests can be run with the following: +They are included beneath ``specifications`` directory of this repository as +Git submodules. By default, ``git clone`` does +not retrieve submodules; to download them, please issue the following command: + +.. code-block:: bash + + make upgrade-submodules + +Issue the same command to update each submodule to the latest available commit. + +If the suites repositories are available then all the tests can be run with +the following: .. code-block:: bash diff --git a/specifications/json-ld-api b/specifications/json-ld-api new file mode 160000 index 00000000..229c8236 --- /dev/null +++ b/specifications/json-ld-api @@ -0,0 +1 @@ +Subproject commit 229c8236ce88083dc08985609dcab03ca3ae4731 diff --git a/specifications/json-ld-framing b/specifications/json-ld-framing new file mode 160000 index 00000000..f1392029 --- /dev/null +++ b/specifications/json-ld-framing @@ -0,0 +1 @@ +Subproject commit f1392029b39019ae8f69ec81347d4f8b9607f858 diff --git a/specifications/rdf-dataset-canonicalization b/specifications/rdf-dataset-canonicalization new file mode 160000 index 00000000..fbcfce57 --- /dev/null +++ b/specifications/rdf-dataset-canonicalization @@ -0,0 +1 @@ +Subproject commit fbcfce5730bf2726c131a84d06ffb686a190a969 diff --git a/tests/runtests.py b/tests/runtests.py index 08ed0d34..d98c3d6d 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -17,6 +17,8 @@ import unittest import re from argparse import ArgumentParser +from pathlib import Path +from typing import List from unittest import TextTestResult sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'lib')) @@ -32,9 +34,20 @@ LOCAL_BASES = [ 'https://w3c.github.io/json-ld-api/tests', 'https://w3c.github.io/json-ld-framing/tests', - 'https://github.com/json-ld/normalization/tests' + 'https://github.com/w3c-ccg/rdf-dataset-canonicalization/tree/main/tests', ] + +def default_test_targets() -> List[Path]: + """Default test directories from specifications.""" + specifications = Path(__file__).parent.parent / 'specifications' + return [ + specifications / 'json-ld-api/tests', + specifications / 'json-ld-framing/tests', + specifications / 'rdf-dataset-canonicalization/tests', + ] + + class TestRunner(unittest.TextTestRunner): """ Loads test manifests and runs tests. @@ -95,18 +108,7 @@ def main(self): test_targets = self.options.tests else: # default to find known sibling test dirs - test_targets = [] - sibling_dirs = [ - '../json-ld-api/tests/', - '../json-ld-framing/tests/', - '../normalization/tests/', - ] - for dir in sibling_dirs: - if os.path.exists(dir): - print('Test dir found', dir) - test_targets.append(dir) - else: - print('Test dir not found', dir) + test_targets = default_test_targets() # ensure a manifest or a directory was specified if len(test_targets) == 0: