From e75866f838e6dbf18601c60669908cfd9b3dac52 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Thu, 4 Mar 2021 15:23:54 -0500 Subject: [PATCH 1/7] Improved testing of unresolvable phylorefs. We allow "correct" Phyx files to be "empty" (i.e. to complete with no successes or failures, such as for a Phyx file containing only an apomorphy). This change now displays a notice indicating that no successes were found in the file. --- test/jphyloref.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/test/jphyloref.js b/test/jphyloref.js index 8c005d3e..ed3a78dd 100644 --- a/test/jphyloref.js +++ b/test/jphyloref.js @@ -55,7 +55,7 @@ describe('JPhyloRef', function () { fs.readdirSync(path.resolve(__dirname, 'examples', 'correct')) .filter(filename => filename.endsWith('.nq')) .forEach((filename) => { - it(`testing ${filename}`, function () { + describe(`testing ${filename}`, function () { this.timeout(20000); // Start JPhyloRef to test filename. @@ -71,24 +71,34 @@ describe('JPhyloRef', function () { shell: true, } ); + const matches = /Testing complete:(\d+) successes, (\d+) failures, (\d+) failures marked TODO, (\d+) skipped./.exec(child.stderr); - expect(matches, `Test result line not found in STDERR <${child.stderr}>`).to.have.lengthOf(5); + it('should return the expected result line', () => { + expect(matches, `Test result line not found in STDERR <${child.stderr}>`).to.have.lengthOf(5); + }); - // const countSuccess = Number(matches[1]); + const countSuccess = Number(matches[1]); const countFailure = Number(matches[2]); const countTODOs = Number(matches[3]); // const countSkipped = Number(matches[4]); + it('should run without any failures or TODOs', () => { + expect(countFailure, 'Expected zero failures').to.equal(0); + expect(countTODOs, 'Expected zero TODOs').to.equal(0); + }); + // We can't test for one or more successes since some example Phyx file // such as apomorphy-based phyloreferences don't have any successes at all. - // expect(countSuccess, 'Expected one or more successes').to.be.greaterThan(0); - expect(countFailure, 'Expected zero failures').to.equal(0); - expect(countTODOs, 'Expected zero TODOs').to.equal(0); - - // An exit code of 0 means success. An exit code of 255 means that while - // there were no successes, there were also no failures. Either is acceptable here. - expect(child.status).to.be.oneOf([0, 255]); + // But we'll report both. + if (countSuccess === 0 && child.status === 255) { + it('No phyloreferences resolved successfully'); + } else { + it('should resolve one or more phyloreferences', () => { + expect(countSuccess, 'Expected one or more successes').to.be.greaterThan(0); + expect(child.status).to.be.oneOf([0, 255]); + }); + } }); }); }); From 3d6faa0b1d03a415cbe53e069f5e99b0b586b00f Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Thu, 4 Mar 2021 15:28:32 -0500 Subject: [PATCH 2/7] Added a test file with a phyloref without an expected resolution. --- .../correct/example_no_successes.json | 28 + .../correct/example_no_successes.jsonld | 597 ++++++++++++++++++ test/examples/correct/example_no_successes.nq | 328 ++++++++++ 3 files changed, 953 insertions(+) create mode 100644 test/examples/correct/example_no_successes.json create mode 100644 test/examples/correct/example_no_successes.jsonld create mode 100644 test/examples/correct/example_no_successes.nq diff --git a/test/examples/correct/example_no_successes.json b/test/examples/correct/example_no_successes.json new file mode 100644 index 00000000..bb8b3ddc --- /dev/null +++ b/test/examples/correct/example_no_successes.json @@ -0,0 +1,28 @@ +{ + "@context": "../../../docs/context/development/phyx.json", + "phylogenies": [{ + "newick": "((((Aa_a, Bb_b)Expected, Cc_c), (Dd_d, (Ee_e, Ff_f, (Gg_g, Hh_h)))), Ii_i)" + }], + "phylorefs": [{ + "label": "Unexpected", + "definition": "Includes A_a, excludes C_c.", + "internalSpecifiers": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "nameComplete": "Aa a" + } + } + ], + "externalSpecifiers": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "nameComplete": "Cc c" + } + } + ] + }] +} diff --git a/test/examples/correct/example_no_successes.jsonld b/test/examples/correct/example_no_successes.jsonld new file mode 100644 index 00000000..457ebc25 --- /dev/null +++ b/test/examples/correct/example_no_successes.jsonld @@ -0,0 +1,597 @@ +{ + "@context": "../../../docs/context/development/phyx.json", + "phylogenies": [ + { + "newick": "((((Aa_a, Bb_b)Expected, Cc_c), (Dd_d, (Ee_e, Ff_f, (Gg_g, Hh_h)))), Ii_i)", + "@id": "http://example.org/phyx.js/example#phylogeny0", + "@type": "testcase:PhyloreferenceTestPhylogeny", + "nodes": [ + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node0", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + } + ], + "children": [ + "http://example.org/phyx.js/example#phylogeny0_node1", + "http://example.org/phyx.js/example#phylogeny0_node2" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node1", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Ii i" + } + } + } + ], + "labels": [ + "Ii_i" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Ii_i", + "nameComplete": "Ii i", + "genusPart": "Ii", + "specificEpithet": "i" + }, + "label": "Ii_i" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node0", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node2" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node2", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node0", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node1" + ], + "children": [ + "http://example.org/phyx.js/example#phylogeny0_node3", + "http://example.org/phyx.js/example#phylogeny0_node11" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node3", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node2", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node11" + ], + "children": [ + "http://example.org/phyx.js/example#phylogeny0_node4", + "http://example.org/phyx.js/example#phylogeny0_node10" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node4", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node3", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node10" + ], + "children": [ + "http://example.org/phyx.js/example#phylogeny0_node5", + "http://example.org/phyx.js/example#phylogeny0_node8", + "http://example.org/phyx.js/example#phylogeny0_node9" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node5", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node4", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node8", + "http://example.org/phyx.js/example#phylogeny0_node9" + ], + "children": [ + "http://example.org/phyx.js/example#phylogeny0_node6", + "http://example.org/phyx.js/example#phylogeny0_node7" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node6", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Hh h" + } + } + } + ], + "labels": [ + "Hh_h" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Hh_h", + "nameComplete": "Hh h", + "genusPart": "Hh", + "specificEpithet": "h" + }, + "label": "Hh_h" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node5", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node7" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node7", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Gg g" + } + } + } + ], + "labels": [ + "Gg_g" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Gg_g", + "nameComplete": "Gg g", + "genusPart": "Gg", + "specificEpithet": "g" + }, + "label": "Gg_g" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node5", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node6" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node8", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Ff f" + } + } + } + ], + "labels": [ + "Ff_f" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Ff_f", + "nameComplete": "Ff f", + "genusPart": "Ff", + "specificEpithet": "f" + }, + "label": "Ff_f" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node4", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node5", + "http://example.org/phyx.js/example#phylogeny0_node9" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node9", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Ee e" + } + } + } + ], + "labels": [ + "Ee_e" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Ee_e", + "nameComplete": "Ee e", + "genusPart": "Ee", + "specificEpithet": "e" + }, + "label": "Ee_e" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node4", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node5", + "http://example.org/phyx.js/example#phylogeny0_node8" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node10", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Dd d" + } + } + } + ], + "labels": [ + "Dd_d" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Dd_d", + "nameComplete": "Dd d", + "genusPart": "Dd", + "specificEpithet": "d" + }, + "label": "Dd_d" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node3", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node4" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node11", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node2", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node3" + ], + "children": [ + "http://example.org/phyx.js/example#phylogeny0_node12", + "http://example.org/phyx.js/example#phylogeny0_node13" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node12", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Cc c" + } + } + } + ], + "labels": [ + "Cc_c" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Cc_c", + "nameComplete": "Cc c", + "genusPart": "Cc", + "specificEpithet": "c" + }, + "label": "Cc_c" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node11", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node13" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node13", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Expected" + } + } + } + ], + "labels": [ + "Expected" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Expected", + "nameComplete": "Expected", + "uninomial": "Expected" + }, + "label": "Expected" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node11", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node12" + ], + "children": [ + "http://example.org/phyx.js/example#phylogeny0_node14", + "http://example.org/phyx.js/example#phylogeny0_node15" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node14", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Bb b" + } + } + } + ], + "labels": [ + "Bb_b" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Bb_b", + "nameComplete": "Bb b", + "genusPart": "Bb", + "specificEpithet": "b" + }, + "label": "Bb_b" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node13", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node15" + ] + }, + { + "@id": "http://example.org/phyx.js/example#phylogeny0_node15", + "rdf:type": [ + { + "@id": "obo:CDAO_0000140" + }, + { + "@type": "owl:Restriction", + "onProperty": "obo:CDAO_0000187", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Aa a" + } + } + } + ], + "labels": [ + "Aa_a" + ], + "representsTaxonomicUnits": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "label": "Aa_a", + "nameComplete": "Aa a", + "genusPart": "Aa", + "specificEpithet": "a" + }, + "label": "Aa_a" + } + ], + "parent": "http://example.org/phyx.js/example#phylogeny0_node13", + "siblings": [ + "http://example.org/phyx.js/example#phylogeny0_node14" + ] + } + ], + "hasRootNode": { + "@id": "http://example.org/phyx.js/example#phylogeny0_node0" + } + } + ], + "phylorefs": [ + { + "label": "Unexpected", + "definition": "Includes A_a, excludes C_c.", + "internalSpecifiers": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "nameComplete": "Aa a" + } + } + ], + "externalSpecifiers": [ + { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept", + "hasName": { + "@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName", + "nameComplete": "Cc c" + } + } + ], + "@id": "http://example.org/phyx.js/example#phyloref0", + "@type": "owl:Class", + "hasComponentClass": [], + "equivalentClass": { + "@type": "owl:Class", + "intersectionOf": [ + { + "@type": "owl:Restriction", + "onProperty": "phyloref:includes_TU", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Aa a" + } + } + }, + { + "@type": "owl:Restriction", + "onProperty": "phyloref:excludes_TU", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName", + "someValuesFrom": { + "@type": "owl:Restriction", + "onProperty": "http://rs.tdwg.org/ontology/voc/TaxonName#nameComplete", + "hasValue": "Cc c" + } + } + } + ] + }, + "subClassOf": [ + "phyloref:Phyloreference", + "phyloref:PhyloreferenceUsingMaximumClade" + ] + } + ], + "hasTaxonomicUnitMatches": [], + "@id": "http://example.org/phyx.js/example#", + "@type": [ + "testcase:PhyloreferenceTestCase", + "owl:Ontology" + ], + "owl:imports": [ + "http://raw.githubusercontent.com/phyloref/curation-workflow/develop/ontologies/phyloref_testcase.owl", + "http://ontology.phyloref.org/2018-12-14/phyloref.owl", + "http://ontology.phyloref.org/2018-12-14/tcan.owl" + ] +} \ No newline at end of file diff --git a/test/examples/correct/example_no_successes.nq b/test/examples/correct/example_no_successes.nq new file mode 100644 index 00000000..ae42204c --- /dev/null +++ b/test/examples/correct/example_no_successes.nq @@ -0,0 +1,328 @@ + . + . + . + . + . + . + . + "((((Aa_a, Bb_b)Expected, Cc_c), (Dd_d, (Ee_e, Ff_f, (Gg_g, Hh_h)))), Ii_i)" . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + _:b25 . + . + _:b27 . + "Dd_d" . + . + . + . + . + . + . + . + _:b30 . + . + _:b32 . + "Cc_c" . + . + . + . + . + _:b35 . + . + _:b37 . + "Expected" . + . + . + _:b40 . + . + _:b42 . + "Bb_b" . + . + . + _:b45 . + . + _:b47 . + "Aa_a" . + . + . + _:b0 . + . + _:b2 . + "Ii_i" . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + . + _:b5 . + . + _:b7 . + "Hh_h" . + . + . + _:b10 . + . + _:b12 . + "Gg_g" . + . + . + . + _:b15 . + . + _:b17 . + "Ff_f" . + . + . + . + _:b20 . + . + _:b22 . + "Ee_e" . + "Includes A_a, excludes C_c." . + _:b50 . + _:b52 . + . + "Unexpected" . + . + . + _:b54 . +_:b0 _:b1 . +_:b0 . +_:b0 "Ii_i" . +_:b1 "Ii" . +_:b1 "Ii i" . +_:b1 "i" . +_:b1 . +_:b1 "Ii_i" . +_:b10 _:b11 . +_:b10 . +_:b10 "Gg_g" . +_:b11 "Gg" . +_:b11 "Gg g" . +_:b11 "g" . +_:b11 . +_:b11 "Gg_g" . +_:b12 . +_:b12 . +_:b12 _:b13 . +_:b13 . +_:b13 . +_:b13 _:b14 . +_:b14 . +_:b14 "Gg g" . +_:b14 . +_:b15 _:b16 . +_:b15 . +_:b15 "Ff_f" . +_:b16 "Ff" . +_:b16 "Ff f" . +_:b16 "f" . +_:b16 . +_:b16 "Ff_f" . +_:b17 . +_:b17 . +_:b17 _:b18 . +_:b18 . +_:b18 . +_:b18 _:b19 . +_:b19 . +_:b19 "Ff f" . +_:b19 . +_:b2 . +_:b2 . +_:b2 _:b3 . +_:b20 _:b21 . +_:b20 . +_:b20 "Ee_e" . +_:b21 "Ee" . +_:b21 "Ee e" . +_:b21 "e" . +_:b21 . +_:b21 "Ee_e" . +_:b22 . +_:b22 . +_:b22 _:b23 . +_:b23 . +_:b23 . +_:b23 _:b24 . +_:b24 . +_:b24 "Ee e" . +_:b24 . +_:b25 _:b26 . +_:b25 . +_:b25 "Dd_d" . +_:b26 "Dd" . +_:b26 "Dd d" . +_:b26 "d" . +_:b26 . +_:b26 "Dd_d" . +_:b27 . +_:b27 . +_:b27 _:b28 . +_:b28 . +_:b28 . +_:b28 _:b29 . +_:b29 . +_:b29 "Dd d" . +_:b29 . +_:b3 . +_:b3 . +_:b3 _:b4 . +_:b30 _:b31 . +_:b30 . +_:b30 "Cc_c" . +_:b31 "Cc" . +_:b31 "Cc c" . +_:b31 "c" . +_:b31 . +_:b31 "Cc_c" . +_:b32 . +_:b32 . +_:b32 _:b33 . +_:b33 . +_:b33 . +_:b33 _:b34 . +_:b34 . +_:b34 "Cc c" . +_:b34 . +_:b35 _:b36 . +_:b35 . +_:b35 "Expected" . +_:b36 "Expected" . +_:b36 . +_:b36 "Expected" . +_:b37 . +_:b37 . +_:b37 _:b38 . +_:b38 . +_:b38 . +_:b38 _:b39 . +_:b39 . +_:b39 "Expected" . +_:b39 . +_:b4 . +_:b4 "Ii i" . +_:b4 . +_:b40 _:b41 . +_:b40 . +_:b40 "Bb_b" . +_:b41 "Bb" . +_:b41 "Bb b" . +_:b41 "b" . +_:b41 . +_:b41 "Bb_b" . +_:b42 . +_:b42 . +_:b42 _:b43 . +_:b43 . +_:b43 . +_:b43 _:b44 . +_:b44 . +_:b44 "Bb b" . +_:b44 . +_:b45 _:b46 . +_:b45 . +_:b45 "Aa_a" . +_:b46 "Aa" . +_:b46 "Aa a" . +_:b46 "a" . +_:b46 . +_:b46 "Aa_a" . +_:b47 . +_:b47 . +_:b47 _:b48 . +_:b48 . +_:b48 . +_:b48 _:b49 . +_:b49 . +_:b49 "Aa a" . +_:b49 . +_:b5 _:b6 . +_:b5 . +_:b5 "Hh_h" . +_:b50 _:b51 . +_:b50 . +_:b51 "Cc c" . +_:b51 . +_:b52 _:b53 . +_:b52 . +_:b53 "Aa a" . +_:b53 . +_:b54 . +_:b54 _:b61 . +_:b55 . +_:b55 . +_:b55 _:b56 . +_:b56 . +_:b56 . +_:b56 _:b57 . +_:b57 . +_:b57 "Aa a" . +_:b57 . +_:b58 . +_:b58 . +_:b58 _:b59 . +_:b59 . +_:b59 . +_:b59 _:b60 . +_:b6 "Hh" . +_:b6 "Hh h" . +_:b6 "h" . +_:b6 . +_:b6 "Hh_h" . +_:b60 . +_:b60 "Cc c" . +_:b60 . +_:b61 _:b55 . +_:b61 _:b62 . +_:b62 _:b58 . +_:b62 . +_:b7 . +_:b7 . +_:b7 _:b8 . +_:b8 . +_:b8 . +_:b8 _:b9 . +_:b9 . +_:b9 "Hh h" . +_:b9 . From 0529858220241e8ec2e41090230a7b3bd2ab17b3 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Thu, 4 Mar 2021 23:43:58 -0500 Subject: [PATCH 3/7] Improved tests for cases with incorrect JPhyloRef output. --- test/jphyloref.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/test/jphyloref.js b/test/jphyloref.js index ed3a78dd..6d54b142 100644 --- a/test/jphyloref.js +++ b/test/jphyloref.js @@ -78,26 +78,31 @@ describe('JPhyloRef', function () { expect(matches, `Test result line not found in STDERR <${child.stderr}>`).to.have.lengthOf(5); }); - const countSuccess = Number(matches[1]); - const countFailure = Number(matches[2]); - const countTODOs = Number(matches[3]); - // const countSkipped = Number(matches[4]); + // If this is not true, the previous expect with fail. Unfortunately, + // code execution continues even if that one `it()` fails, so we need + // to test it here as well. + if (matches.length === 5) { + const countSuccess = Number(matches[1]); + const countFailure = Number(matches[2]); + const countTODOs = Number(matches[3]); + // const countSkipped = Number(matches[4]); - it('should run without any failures or TODOs', () => { - expect(countFailure, 'Expected zero failures').to.equal(0); - expect(countTODOs, 'Expected zero TODOs').to.equal(0); - }); - - // We can't test for one or more successes since some example Phyx file - // such as apomorphy-based phyloreferences don't have any successes at all. - // But we'll report both. - if (countSuccess === 0 && child.status === 255) { - it('No phyloreferences resolved successfully'); - } else { - it('should resolve one or more phyloreferences', () => { - expect(countSuccess, 'Expected one or more successes').to.be.greaterThan(0); - expect(child.status).to.be.oneOf([0, 255]); + it('should run without any failures or TODOs', () => { + expect(countFailure, 'Expected zero failures').to.equal(0); + expect(countTODOs, 'Expected zero TODOs').to.equal(0); }); + + // We can't test for one or more successes since some example Phyx file + // such as apomorphy-based phyloreferences don't have any successes at all. + // But we'll report both. + if (countSuccess === 0 && child.status === 255) { + it('No phyloreferences resolved successfully'); + } else { + it('should resolve one or more phyloreferences', () => { + expect(countSuccess, 'Expected one or more successes').to.be.greaterThan(0); + expect(child.status).to.be.oneOf([0, 255]); + }); + } } }); }); From b10c7ddc4e28beac37afc1cfdfe2b37ebdaa0731 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Thu, 4 Mar 2021 23:47:31 -0500 Subject: [PATCH 4/7] Further attempts to improve status line detection. --- test/jphyloref.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jphyloref.js b/test/jphyloref.js index 6d54b142..f25ca420 100644 --- a/test/jphyloref.js +++ b/test/jphyloref.js @@ -81,7 +81,7 @@ describe('JPhyloRef', function () { // If this is not true, the previous expect with fail. Unfortunately, // code execution continues even if that one `it()` fails, so we need // to test it here as well. - if (matches.length === 5) { + if (matches && matches.length === 5) { const countSuccess = Number(matches[1]); const countFailure = Number(matches[2]); const countTODOs = Number(matches[3]); From 4accbada2d523ebd2c162eb1e160cad6400bfb0b Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Thu, 4 Mar 2021 23:55:56 -0500 Subject: [PATCH 5/7] Possible fix to incomplete download bug. --- test/jphyloref.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jphyloref.js b/test/jphyloref.js index f25ca420..fd13b76f 100644 --- a/test/jphyloref.js +++ b/test/jphyloref.js @@ -42,7 +42,7 @@ describe('JPhyloRef', function () { it('should be downloadable', function () { this.timeout(10000); // Download JPhyloRef from Maven and save it to JPHYLOREF_PATH. - return new Downloader({ + new Downloader({ url: JPHYLOREF_URL, directory: path.dirname(JPHYLOREF_PATH), fileName: path.basename(JPHYLOREF_PATH), From 8eadfa1a6832cf7ed2b8f3377967affd8fc809c8 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Fri, 5 Mar 2021 01:14:30 -0500 Subject: [PATCH 6/7] Reorganized JPhyloRef tests to ensure JAR is downloaded before testing. --- test/jphyloref.js | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/test/jphyloref.js b/test/jphyloref.js index fd13b76f..436f9e15 100644 --- a/test/jphyloref.js +++ b/test/jphyloref.js @@ -24,31 +24,40 @@ const JPHYLOREF_URL = `https://repo.maven.apache.org/maven2/org/phyloref/jphylor // Where should the JPhyloRef be stored? const JPHYLOREF_PATH = path.resolve(__dirname, `jphyloref-${JPHYLOREF_VERSION}.jar`); +// TODO: we should eventually use SHA to ensure that we have the expected file. +if (fs.existsSync(JPHYLOREF_PATH) && fs.statSync(JPHYLOREF_PATH).size > 0) { + // We've already downloaded it! Nothing to do. +} else { + // Download JPhyloRef from Maven and save it to JPHYLOREF_PATH. + // Since Downloader() works asynchronously, we need to wrap it in + // an async() here to ensure that it finishes the download *before* + // we start the `describe()` below. + (async () => { + const downloader = new Downloader({ + url: JPHYLOREF_URL, + directory: path.dirname(JPHYLOREF_PATH), + fileName: path.basename(JPHYLOREF_PATH), + }); + + try { + await downloader.download(); + } catch (error) { + throw new Error(`Could not download JPhyloRef from Maven: ${error}`); + } + })(); +} + /** * Test whether the expected JSON-LD files pass testing using JPhyloRef. */ describe('JPhyloRef', function () { - describe('download JPhyloRef', function () { + describe('make sure JPhyloRef has been downloaded', function () { // TODO: we should eventually use SHA to ensure that we have the expected file. - if ( - fs.existsSync(JPHYLOREF_PATH) - && fs.statSync(JPHYLOREF_PATH).size > 0 - ) { - it('has already been downloaded', function () { - expect(true); - }); - } else { - it('should be downloadable', function () { - this.timeout(10000); - // Download JPhyloRef from Maven and save it to JPHYLOREF_PATH. - new Downloader({ - url: JPHYLOREF_URL, - directory: path.dirname(JPHYLOREF_PATH), - fileName: path.basename(JPHYLOREF_PATH), - }).download(); - }); - } + it('has been downloaded', function () { + expect(fs.existsSync(JPHYLOREF_PATH)).to.be.true; + expect(fs.statSync(JPHYLOREF_PATH).size).to.be.greaterThan(0); + }); }); describe('test example JSON-LD files using JPhyloRef', function () { From f00292f4fccd90e3dfa02be430b2fdf27ae86ae9 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Sun, 7 Mar 2021 16:07:07 -0500 Subject: [PATCH 7/7] Failed attempt to download JPhyloRef before tests. --- test/jphyloref.js | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/test/jphyloref.js b/test/jphyloref.js index 436f9e15..30e8053c 100644 --- a/test/jphyloref.js +++ b/test/jphyloref.js @@ -24,28 +24,22 @@ const JPHYLOREF_URL = `https://repo.maven.apache.org/maven2/org/phyloref/jphylor // Where should the JPhyloRef be stored? const JPHYLOREF_PATH = path.resolve(__dirname, `jphyloref-${JPHYLOREF_VERSION}.jar`); -// TODO: we should eventually use SHA to ensure that we have the expected file. -if (fs.existsSync(JPHYLOREF_PATH) && fs.statSync(JPHYLOREF_PATH).size > 0) { - // We've already downloaded it! Nothing to do. -} else { - // Download JPhyloRef from Maven and save it to JPHYLOREF_PATH. - // Since Downloader() works asynchronously, we need to wrap it in - // an async() here to ensure that it finishes the download *before* - // we start the `describe()` below. - (async () => { - const downloader = new Downloader({ - url: JPHYLOREF_URL, - directory: path.dirname(JPHYLOREF_PATH), - fileName: path.basename(JPHYLOREF_PATH), - }); +// Download JPhyloRef from Maven and save it to JPHYLOREF_PATH. +// Since Downloader() works asynchronously, we need to wrap it in +// an async() here to ensure that it finishes the download *before* +// we start the `describe()` below. +const downloader = new Downloader({ + url: JPHYLOREF_URL, + directory: path.dirname(JPHYLOREF_PATH), + fileName: path.basename(JPHYLOREF_PATH), +}); - try { - await downloader.download(); - } catch (error) { - throw new Error(`Could not download JPhyloRef from Maven: ${error}`); - } - })(); -} +before(function (done) { + this.timeout(20000); + downloader.download() + .then(done) + .catch(err => done(err)); +}); /** * Test whether the expected JSON-LD files pass testing using JPhyloRef.