Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
upgrade-submodules:
git submodule update --remote --init --recursive

test:
python tests/runtests.py
23 changes: 17 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions specifications/json-ld-api
Submodule json-ld-api added at 229c82
1 change: 1 addition & 0 deletions specifications/json-ld-framing
Submodule json-ld-framing added at f13920
1 change: 1 addition & 0 deletions specifications/rdf-dataset-canonicalization
28 changes: 15 additions & 13 deletions tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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.
Expand Down Expand Up @@ -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:
Expand Down