Skip to content

Commit 6cec3a0

Browse files
committed
Support new WG test suites.
- Support for json-ld-api tests. - Future support for json-ld-framing tests. - Use old json-ld.org framing tests. - Update document loader to handle w3c URLs.
1 parent c8f945d commit 6cec3a0

File tree

6 files changed

+64
-14
lines changed

6 files changed

+64
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# jsonld ChangeLog
22

3+
### Changed
4+
- Use JSON-LD WG tests.
5+
36
## 1.2.1 - 2018-12-11
47

58
### Fixed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ that changes to the processor maintain the correct output.
344344
The main test suites are included in external repositories. Check out each of
345345
the following:
346346

347+
https://github.com/w3c/json-ld-api
348+
https://github.com/w3c/json-ld-framing
347349
https://github.com/json-ld/json-ld.org
348350
https://github.com/json-ld/normalization
349351

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@
9393
"build": "npm run build-webpack && npm run build-node6",
9494
"build-webpack": "webpack",
9595
"build-node6": "babel --no-babelrc --out-dir dist/node6 --presets=node6-es6 lib/*.js lib/*/*.js",
96-
"fetch-test-suites": "npm run fetch-json-ld-org-test-suite && npm run fetch-normalization-test-suite",
96+
"fetch-test-suites": "npm run fetch-json-ld-wg-test-suite && npm run fetch-json-ld-org-test-suite && npm run fetch-normalization-test-suite",
97+
"fetch-json-ld-wg-test-suite": "npm run fetch-json-ld-api-test-suite && npm run fetch-json-ld-framing-test-suite",
98+
"fetch-json-ld-api-test-suite": "if [ ! -e test-suites/json-wg-api ]; then git clone --depth 1 https://github.com/w3c/json-ld-api.git test-suites/json-ld-api; fi",
99+
"fetch-json-ld-framing-test-suite": "if [ ! -e test-suites/json-wg-framing ]; then git clone --depth 1 https://github.com/w3c/json-ld-framing.git test-suites/json-ld-framing; fi",
97100
"fetch-json-ld-org-test-suite": "if [ ! -e test-suites/json-ld.org ]; then git clone --depth 1 https://github.com/json-ld/json-ld.org.git test-suites/json-ld.org; fi",
98101
"fetch-normalization-test-suite": "if [ ! -e test-suites/normalization ]; then git clone --depth 1 https://github.com/json-ld/normalization.git test-suites/normalization; fi",
99102
"test": "cross-env NODE_ENV=test mocha --delay -t 30000 -A -R ${REPORTER:-spec} tests/test.js",

tests/test-common.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,12 @@ function basename(filename) {
674674
* @return the document loader.
675675
*/
676676
function createDocumentLoader(test) {
677-
const _httpTestSuiteBase = 'http://json-ld.org/test-suite';
678-
const _httpsTestSuiteBase = 'https://json-ld.org/test-suite';
677+
const localBases = [
678+
'http://json-ld.org/test-suite',
679+
'https://json-ld.org/test-suite',
680+
'https://w3c.github.io/json-ld-api/tests',
681+
'https://w3c.github.io/json-ld-framing/tests'
682+
];
679683
const localLoader = function(url, callback) {
680684
// always load remote-doc tests remotely in node
681685
if(options.nodejs && test.manifest.name === 'Remote document') {
@@ -685,9 +689,9 @@ function createDocumentLoader(test) {
685689
// FIXME: this check only works for main test suite and will not work if:
686690
// - running other tests and main test suite not installed
687691
// - use other absolute URIs but want to load local files
688-
const isTestSuite =
689-
url.startsWith(_httpTestSuiteBase) ||
690-
url.startsWith(_httpsTestSuiteBase);
692+
const isTestSuite = localBases.some(function(base) {
693+
return url.startsWith(base);
694+
});
691695
// TODO: improve this check
692696
const isRelative = url.indexOf(':') === -1;
693697
if(isTestSuite || isRelative) {

tests/test-karma.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,25 @@ if(process.env.JSONLD_TESTS) {
5252
const _top = process.env.TEST_ROOT_DIR;
5353
// TODO: support just adding certain entries in EARL mode?
5454

55-
// json-ld.org main test suite
55+
// json-ld-api main test suite
5656
// FIXME: add path detection
57-
entries.push(join(_top, 'test-suites/json-ld.org/test-suite'));
58-
entries.push(join(_top, '../json-ld.org/test-suite'));
57+
entries.push(join(_top, 'test-suites/json-ld-api/tests'));
58+
entries.push(join(_top, '../json-ld-api/tests'));
59+
60+
/*
61+
// json-ld-framing main test suite
62+
// FIXME: add path detection
63+
entries.push(join(_top, 'test-suites/json-ld-framing/tests'));
64+
entries.push(join(_top, '../json-ld-framing/tests'));
65+
*/
66+
67+
// TODO: use json-ld-framing once tests are moved
68+
// json-ld.org framing test suite
69+
// FIXME: add path detection
70+
entries.push(join(
71+
_top, 'test-suites/json-ld.org/test-suite/tests/frame-manifest.jsonld'));
72+
entries.push(join(
73+
_top, '../json-ld.org/test-suite/tests/frame-manifests.jsonld'));
5974

6075
// json-ld.org normalization test suite
6176
// FIXME: add path detection

tests/test.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,36 @@ if(process.env.JSONLD_TESTS) {
3333
} else {
3434
const _top = path.resolve(__dirname, '..');
3535

36-
// json-ld.org main test suite
37-
const orgPath = path.resolve(_top, 'test-suites/json-ld.org/test-suite');
38-
if(fs.existsSync(orgPath)) {
39-
entries.push(orgPath);
36+
// json-ld-api main test suite
37+
const apiPath = path.resolve(_top, 'test-suites/json-ld-api/tests');
38+
if(fs.existsSync(apiPath)) {
39+
entries.push(apiPath);
4040
} else {
4141
// default to sibling dir
42-
entries.push(path.resolve(_top, '../json-ld.org/test-suite'));
42+
entries.push(path.resolve(_top, '../json-ld-api/tests'));
43+
}
44+
45+
/*
46+
// json-ld-framing main test suite
47+
const framingPath = path.resolve(_top, 'test-suites/json-ld-framing/tests');
48+
if(fs.existsSync(framingPath)) {
49+
entries.push(framingPath);
50+
} else {
51+
// default to sibling dir
52+
entries.push(path.resolve(_top, '../json-ld-framing/tests'));
53+
}
54+
*/
55+
56+
// TODO: use json-ld-framing once tests are moved
57+
// json-ld.org framing test suite
58+
const framingPath = path.resolve(
59+
_top, 'test-suites/json-ld.org/test-suite/tests/frame-manifest.jsonld');
60+
if(fs.existsSync(framingPath)) {
61+
entries.push(framingPath);
62+
} else {
63+
// default to sibling dir
64+
entries.push(path.resolve(
65+
_top, '../json-ld.org/test-suite/tests/frame-manifest.jsonld'));
4366
}
4467

4568
// json-ld.org normalization test suite

0 commit comments

Comments
 (0)