From ade2d5e93442237782c1fcd7bc2afcfa8ccae5b5 Mon Sep 17 00:00:00 2001 From: Kay Robbins <1189050+VisLab@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:45:11 -0500 Subject: [PATCH 1/3] Updated the spec tests From e0f5ea8b845d1681bfca79f2d30835bbd3ad7580 Mon Sep 17 00:00:00 2001 From: Kay Robbins <1189050+VisLab@users.noreply.github.com> Date: Sat, 21 Sep 2024 13:15:10 -0500 Subject: [PATCH 2/3] Updated the json spec errors --- ...script_tests.json => javascriptTests.json} | 239 ++++++------------ spec_tests/jsonTests.spec.js | 5 +- 2 files changed, 83 insertions(+), 161 deletions(-) rename spec_tests/{javascript_tests.json => javascriptTests.json} (98%) diff --git a/spec_tests/javascript_tests.json b/spec_tests/javascriptTests.json similarity index 98% rename from spec_tests/javascript_tests.json rename to spec_tests/javascriptTests.json index fd4b2e7e..1272aec9 100644 --- a/spec_tests/javascript_tests.json +++ b/spec_tests/javascriptTests.json @@ -5,7 +5,7 @@ "name": "character-invalid-non-printing appears", "description": "The HED string contains a UTF-8 character.", "warning": false, - "schema": "8.2.0", + "schema": "8.3.0", "definitions": ["(Definition/Acc/#, (Acceleration/#, Red))", "(Definition/MyColor, (Label/Pie))"], "tests": { "string_tests": { @@ -26,7 +26,7 @@ { "event_code": { "HED": { - "show": "Red, Label/a \u00ca\u00b0 good" + "show": "Red, Label/a-\u00ca\u00b0-good" } } } @@ -42,7 +42,7 @@ "passes": [ [ ["onset", "duration", "HED"], - [4.5, 0, "Label/Temp, Label/a \u00ca\u00b0 good"] + [4.5, 0, "Label/Temp, Label/a-\u00ca\u00b0-good"] ] ] }, @@ -134,7 +134,7 @@ "error_code": "CHARACTER_INVALID", "alt_codes": ["TAG_INVALID", "VALUE_INVALID"], "name": "invalid-character-name-value-class", - "description": "An invalid character was used in an 8.3.0 or greater style text value class.", + "description": "An invalid character was used in an 8.3.0 or greater style name value class.", "warning": false, "schema": "8.3.0", "definitions": ["(Definition/Acc/#, (Acceleration/#, Red))", "(Definition/MyColor, (Label/Pie))"], @@ -165,11 +165,11 @@ "fails": [ [ ["onset", "duration", "HED"], - [4.5, 0, "Statistical-accuracy/1max1"] + [4.5, 0, "Label/%max1"] ], [ ["onset", "duration", "HED"], - [4.5, 0, "Label/30$"] + [4.5, 0, "Label/$30"] ], [ ["onset", "duration", "HED"], @@ -230,67 +230,6 @@ } } }, - { - "error_code": "CHARACTER_INVALID", - "alt_codes": ["UNITS_INVALID"], - "name": "invalid-character-numeric-class", - "description": "An invalid character was used in an 8.3.0 or greater style numeric value class.", - "warning": false, - "schema": "8.3.0", - "definitions": [], - "tests": { - "string_tests": { - "fails": [ - "Weight/3.0$ kg", - "Weight/3.0db kg", - "Weight/3.0& kg", - "Weight/abc kg", - "Weight/*3.0 kg", - "Weight/3.0% kg", - "Weight/3.0^ kg", - "Weight/3.0? kg" - ], - "passes": [ - "Weight/3.0e10 kg", - "Weight/3e10 kg", - "Weight/3.0 kg", - "Weight/3000 kg", - "Weight/3e10 kg", - "Weight/3.5e10 kg", - "Weight/2.998e8 g", - "Weight/6.022e23 g", - "Weight/7.0e-10 g", - "Weight/1.6e-35 kg" - ] - }, - "sidecar_tests": { - "fails": [ - { - "event_code": { - "HED": { - "show": "Weight/3.0a" - } - } - } - ], - "passes": [ - { - "event_code": { - "HED": "Weight/# g" - } - } - ] - }, - "event_tests": { - "fails": [], - "passes": [] - }, - "combo_tests": { - "fails": [], - "passes": [] - } - } - }, { "error_code": "COMMA_MISSING", "alt_codes": [], @@ -2521,7 +2460,7 @@ "fails": [ { "trial": { - "HED": "Def/Acc/# m-per-s^2, Label/#" + "HED": "Def/Acc/#, Label/#" }, "memory": { "HED": "Blue, Red, Label/#" @@ -2531,7 +2470,7 @@ "passes": [ { "trial": { - "HED": "Def/Acc/# m-per-s^2" + "HED": "Def/Acc/#" } } ] @@ -2708,7 +2647,7 @@ }, { "error_code": "SIDECAR_BRACES_INVALID", - "alt_codes": ["CHARACTER_INVALID"], + "alt_codes": ["CHARACTER_INVALID", "SIDECAR_INVALID"], "name": "sidecar-braces-contents-invalid", "description": "The item in curly braces is not the word HED or a column name with HED annotations in the sidecar.", "warning": false, @@ -2804,7 +2743,7 @@ }, { "error_code": "SIDECAR_BRACES_INVALID", - "alt_codes": ["VALUE_INVALID", "CHARACTER_INVALID", "UNITS_INVALID"], + "alt_codes": ["VALUE_INVALID", "CHARACTER_INVALID", "UNITS_INVALID", "DEF_INVALID"], "name": "sidecar-braces-invalid-spot", "description": "A curly brace reference must only appear where a tag could.", "warning": false, @@ -2821,7 +2760,7 @@ "event_code": { "HED": { "face": "(Red, Blue), (Green, (Yellow))", - "ball": "(Def/Acc/{response_time})" + "ball": "(Label/{response_time})" } }, "response_time": { @@ -2948,7 +2887,7 @@ }, "response_time": { "Description": "Has description with HED", - "HED": "Label/#" + "HED": "Parameter-value/#" } }, "events": [ @@ -2986,7 +2925,7 @@ } }, "response_time": { - "HED": "Label/#, {response_time}" + "HED": "Parameter-value/#, {response_time}" } } ], @@ -3000,7 +2939,7 @@ }, "response_time": { "Description": "Has description with HED", - "HED": "Label/#" + "HED": "Parameter-value/#" }, "response_count": { "Description": "A count used to test curly braces in value columns.", @@ -3016,7 +2955,7 @@ }, "response_action": { "Description": "Does not correspond to curly braces", - "HED": "Label/#" + "HED": "Parameter-value/#" } } ] @@ -3037,7 +2976,7 @@ }, "response_time": { "Description": "Has description with HED", - "HED": "Label/#, {response_time}" + "HED": "Parameter-value/#, {response_time}" } }, "events": [ @@ -3060,7 +2999,7 @@ }, "response_time": { "Description": "Has description with HED", - "HED": "Label/#" + "HED": "Parameter-value/#" } }, "events": [ @@ -3361,87 +3300,6 @@ } } }, - { - "error_code": "SIDECAR_INVALID", - "alt_codes": [], - "name": "curly-braces-has-no-hed", - "description": "A column name appears in curly braces, but that column name does not have a HED annotation.", - "warning": false, - "schema": "8.3.0", - "definitions": ["(Definition/Acc/#, (Acceleration/#, Red))", "(Definition/MyColor, (Label/Pie))"], - "tests": { - "string_tests": { - "fails": [], - "passes": [] - }, - "sidecar_tests": { - "fails": [ - { - "event_code": { - "HED": { - "face": "Statistical-accuracy/0.677, {response}" - } - }, - "response": { - "Description": "This is a response" - } - } - ], - "passes": [ - { - "event_code": { - "HED": { - "face": "Statistical-accuracy/0.677, {response}" - } - }, - "response": { - "HED": "Label/#" - } - } - ] - }, - "event_tests": { - "fails": [], - "passes": [] - }, - "combo_tests": { - "fails": [ - { - "sidecar": { - "event_code": { - "HED": { - "face": "Statistical-accuracy/0.677, {response}" - } - }, - "response": "This is a response" - }, - "events": [ - ["onset", "duration", "event_code", "response", "HED"], - [4.5, 0, "face", "yes", "Red, Def/MyColor"], - [5.0, 0, "ball", "no", "Green"] - ] - } - ], - "passes": [ - { - "sidecar": { - "event_code": { - "HED": { - "face": "Acceleration/5 m-per-s^2", - "ball": "Def/Acc/7, Blue" - } - } - }, - "events": [ - ["onset", "duration", "event_code", "response", "HED"], - [4.5, 0, "face", "yes", "Red, Def/MyColor"], - [5.0, 0, "ball", "no", "Green"] - ] - } - ] - } - } - }, { "error_code": "SIDECAR_KEY_MISSING", "alt_codes": [], @@ -4155,7 +4013,7 @@ }, { "error_code": "TAG_EXTENSION_INVALID", - "alt_codes": [], + "alt_codes": ["CHARACTER_INVALID", "PLACEHOLDER_INVALID"], "name": "tag-extension-invalid-bad-node-name", "description": "A tag extension term does not comply with rules for schema nodes.", "warning": false, @@ -7612,5 +7470,66 @@ ] } } + }, + { + "error_code": "VALUE_INVALID", + "alt_codes": ["UNITS_INVALID"], + "name": "invalid-character-numeric-class", + "description": "An invalid character was used in an 8.3.0 or greater style numeric value class.", + "warning": false, + "schema": "8.3.0", + "definitions": [], + "tests": { + "string_tests": { + "fails": [ + "Weight/3.0$ kg", + "Weight/3.0db kg", + "Weight/3.0& kg", + "Weight/abc kg", + "Weight/*3.0 kg", + "Weight/3.0% kg", + "Weight/3.0^ kg", + "Weight/3.0? kg" + ], + "passes": [ + "Weight/3.0e10 kg", + "Weight/3e10 kg", + "Weight/3.0 kg", + "Weight/3000 kg", + "Weight/3e10 kg", + "Weight/3.5e10 kg", + "Weight/2.998e8 g", + "Weight/6.022e23 g", + "Weight/7.0e-10 g", + "Weight/1.6e-35 kg" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "show": "Weight/3.0a" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": "Weight/# g" + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [], + "passes": [] + } + } } ] diff --git a/spec_tests/jsonTests.spec.js b/spec_tests/jsonTests.spec.js index 14eae138..0f2a850e 100644 --- a/spec_tests/jsonTests.spec.js +++ b/spec_tests/jsonTests.spec.js @@ -20,7 +20,7 @@ const skippedErrors = { 'invalid-character-name-value-class-deprecated': 'We will let this pass regardless of schema version.', } const readFileSync = fs.readFileSync -const test_file_name = 'javascript_tests.json' +const test_file_name = 'javascriptTests.json' //const test_file_name = 'temp3.json' function comboListToStrings(items) { @@ -117,6 +117,7 @@ describe('HED validation using JSON tests', () => { let hedSchema let itemLog let defs + let hasWarning const failedSidecars = stringifyList(tests.sidecar_tests.fails) const passedSidecars = stringifyList(tests.sidecar_tests.passes) const failedEvents = tsvListToStrings(tests.event_tests.fails) @@ -128,6 +129,7 @@ describe('HED validation using JSON tests', () => { const errors = [] const log = [header] totalTests += 1 + for (const issue of issues) { if (issue instanceof BidsHedIssue) { errors.push(`${issue.hedIssue.hedCode}`) @@ -240,6 +242,7 @@ describe('HED validation using JSON tests', () => { hedSchema = schemaMap.get(schema) defs = { definitions: { HED: { defList: definitions.join(',') } } } itemLog = [] + hasWarning = warning }) afterAll(() => { From 62b0f301c3eb7193c179b9f1f4061f806f1484b5 Mon Sep 17 00:00:00 2001 From: Kay Robbins <1189050+VisLab@users.noreply.github.com> Date: Sun, 22 Sep 2024 05:41:18 -0500 Subject: [PATCH 3/3] Correction in SchemaProperty plus echo node version in action --- .github/workflows/ci.yml | 4 ++++ validator/schema/types.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d28b86ff..5229fb2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,10 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + - name: Print Node.js version and CI environment + run: | + echo "Node.js version: $(node -v)" + echo "Environment: CI=${{ env.CI }}" - name: Download dependencies run: npm ci - name: Test with Node.js ${{ matrix.node-version }} diff --git a/validator/schema/types.js b/validator/schema/types.js index 83dcefe8..62cd713c 100644 --- a/validator/schema/types.js +++ b/validator/schema/types.js @@ -325,7 +325,7 @@ export class SchemaProperty extends SchemaEntry { _propertyType constructor(name, propertyType) { - super(name, new Set(), new Map()) + super(name) this._propertyType = propertyType }