Skip to content
Merged
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
209 changes: 25 additions & 184 deletions spec_tests/javascriptTests.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,16 @@
},
{
"error_code": "CHARACTER_INVALID",
"alt_codes": ["TAG_INVALID", "UNITS_INVALID", "VALUE_INVALID"],
"name": "invalid-character-name-value-class-deprecated",
"description": "An invalid character was used in an 8.2.0 or lower style text value class.",
"alt_codes": ["TAG_INVALID", "VALUE_INVALID"],
"name": "invalid-character-name-value-class",
"description": "An invalid character was used in an 8.2.0 or earlier.",
"warning": false,
"schema": "8.2.0",
"definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"],
"tests": {
"string_tests": {
"fails": ["Parameter-label/[", "Parameter-label/Taco\u00c3\u201e"],
"passes": ["Parameter-label/Words", "Parameter-label/Taco*"]
"fails": ["Parameter-label/[", "Parameter-label/Taco*", "Label/30$", "Label/30db kg"],
"passes": ["Parameter-label/Words", "Label/30e10", "Label/3e10asdf"]
},
"sidecar_tests": {
"fails": [
Expand All @@ -225,8 +225,26 @@
]
},
"event_tests": {
"fails": [],
"passes": []
"fails": [
[
["onset", "duration", "HED"],
[4.5, 0, "Label/%max1"]
],
[
["onset", "duration", "HED"],
[4.5, 0, "Label/$30"]
],
[
["onset", "duration", "HED"],
[4.5, 0, "Label/30db kg"]
]
],
"passes": [
[
["onset", "duration", "HED"],
[4.5, 0, "Label/3e10asdf"]
]
]
},
"combo_tests": {
"fails": [],
Expand Down Expand Up @@ -3378,95 +3396,6 @@
}
}
},
{
"error_code": "STYLE_WARNING",
"alt_codes": [],
"name": "style-warning-bad-naming-style",
"description": "An extension or label does not follow HED naming conventions.",
"warning": true,
"schema": "8.3.0",
"definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"],
"tests": {
"string_tests": {
"fails": ["Red-color/red"],
"passes": ["Blue-color/Blue"]
},
"sidecar_tests": {
"fails": [
{
"event_code": {
"HED": {
"face": "Red/red_blech",
"ball": "Blue-color/blue"
}
}
}
],
"passes": [
{
"event_code": {
"HED": {
"face": "Red-color/Red",
"ball": "Blue-color/Blue"
}
}
}
]
},
"event_tests": {
"fails": [
[
["onset", "duration", "HED"],
[4.5, 0, "Red/red_blech"],
[5.0, 0, "Blue-color/blue"]
]
],
"passes": [
[
["onset", "duration", "HED"],
[4.5, 0, "Red-color/Red"],
[5.0, 0, "Blue-color/Blue"]
]
]
},
"combo_tests": {
"fails": [
{
"sidecar": {
"event_code": {
"HED": {
"face": "Red/red_blech",
"ball": "Blue-color/blue"
}
}
},
"events": [
["onset", "duration", "event_code", "HED"],
[4.5, 0, "face", "Red, Def/MyColor"],
[5.0, 0, "ball", "Green"]
]
}
],
"passes": [
{
"sidecar": {
"event_code": {
"HED": {
"face": "Red-color/Red",
"ball": "Blue-color/Blue"
}
}
},
"events": [
["onset", "duration", "event_code", "HED"],
[4.5, 0, "face", "Blue"],
[5.0, 0, "ball", "Green, Def/MyColor"]
]
}
]
}
}
},
{
"error_code": "TAG_EMPTY",
"alt_codes": [],
Expand Down Expand Up @@ -7216,94 +7145,6 @@
}
}
},
{
"error_code": "TILDES_UNSUPPORTED",
"alt_codes": ["CHARACTER_INVALID"],
"name": "tildes-unsupported",
"description": "The tilde syntax is no longer supported for any version of HED.",
"warning": false,
"schema": "8.3.0",
"definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"],
"tests": {
"string_tests": {
"fails": ["Red ~ Blue", "Red, Blue ~ Green ~ Yellow"],
"passes": ["Red, Blue"]
},
"sidecar_tests": {
"fails": [
{
"event_code": {
"HED": {
"face": "Red ~ Blue",
"ball": "Red, Blue ~ Green ~ Yellow"
}
}
}
],
"passes": [
{
"event_code": {
"HED": {
"face": "(Red, Blue), (Green, (Yellow))",
"ball": "(Def/MyColor, Onset),(Def/Acc/3.5)"
}
}
}
]
},
"event_tests": {
"fails": [
[
["onset", "duration", "HED"],
[4.5, 0, "Red ~ Blue"],
[5.0, 0, "Red, Blue ~ Green ~ Yellow"]
]
],
"passes": [
[
["onset", "duration", "HED"],
[4.5, 0, "(Red, Blue), (Green, (Yellow))"]
]
]
},
"combo_tests": {
"fails": [
{
"sidecar": {
"event_code": {
"HED": {
"face": "Red ~ Blue",
"ball": "Red, Blue ~ Green ~ Yellow"
}
}
},
"events": [
["onset", "duration", "event_code", "HED"],
[4.5, 0, "face", "Red, Def/MyColor"],
[5.0, 0, "ball", "Blue ~ Green ~ Yellow"]
]
}
],
"passes": [
{
"sidecar": {
"event_code": {
"HED": {
"face": "Acceleration/5 m-per-s^2",
"ball": "Def/Acc/7, Blue"
}
}
},
"events": [
["onset", "duration", "event_code", "HED"],
[4.5, 0, "face", "Blue"],
[5.0, 0, "ball", "Green, Def/MyColor"]
]
}
]
}
}
},
{
"error_code": "UNITS_INVALID",
"alt_codes": [],
Expand Down
11 changes: 4 additions & 7 deletions spec_tests/jsonTests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ const runMap = new Map([['TAG_EXPRESSION_REPEATED', ['tags-duplicated-across-mul
//const runOnly = new Set(["eventsPass"])
const runOnly = new Set()
const skippedErrors = {
VERSION_DEPRECATED: 'not handling in the spec tests.',
ELEMENT_DEPRECATED: 'not handling tag deprecated in the spec tests.',
STYLE_WARNING: 'not handling style warnings at this time',
'invalid-character-name-value-class-deprecated': 'not handling deprecated in the spec tests.',
TAG_EXTENDED: 'Warning not being checked',
SIDECAR_KEY_MISSING: 'Warning not being checked',
ELEMENT_DEPRECATED: 'Warning not being checked',
}
const readFileSync = fs.readFileSync
const test_file_name = 'javascriptTests.json'
Expand Down Expand Up @@ -286,9 +285,7 @@ describe('HED validation using JSON tests', () => {
return
}
// Run tests except for the ones explicitly skipped or because they are warnings
if (warning) {
test.skip(`Skipping tests ${error_code} [${name}] skipped because warning not error`, () => {})
} else if (error_code in skippedErrors) {
if (error_code in skippedErrors) {
test.skip(`Skipping tests ${error_code} [${name}] skipped because ${skippedErrors[error_code]}`, () => {})
} else if (name in skippedErrors) {
test.skip(`Skipping tests ${error_code} [${name}] skipped because ${skippedErrors[name]}`, () => {})
Expand Down
4 changes: 2 additions & 2 deletions src/bids/types/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export class BidsFile {
}
if (!schemas) {
BidsHedIssue.fromHedIssue(
generateIssue('genericError', {
message: 'BIDS file HED validation requires a HED schema, but the schema received was null.',
generateIssue('missingSchemaSpecification', {
message: 'No valid HED schema specification was supplied.',
}),
{ path: this.file.file, relativePath: this.file.file },
)
Expand Down
8 changes: 1 addition & 7 deletions src/issues/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export default {
missingSchemaSpecification: {
hedCode: 'SCHEMA_LOAD_FAILED',
level: 'error',
message: stringTemplate`No schema specification was supplied.`,
message: stringTemplate`No valid HED schema specification was supplied.`,
},
bundledSchemaLoadFailed: {
hedCode: 'SCHEMA_LOAD_FAILED',
Expand Down Expand Up @@ -468,12 +468,6 @@ export default {
level: 'error',
message: stringTemplate`The key 'HED' was illegally used within a non-HED sidecar column.`,
},
// Generic errors
genericError: {
hedCode: 'GENERIC_ERROR',
level: 'error',
message: stringTemplate`Unknown HED error "${'internalCode'}" - parameters: "${'parameters'}".`,
},
internalError: {
hedCode: 'INTERNAL_ERROR',
level: 'error',
Expand Down
4 changes: 2 additions & 2 deletions src/issues/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export class Issue {
* @returns {Issue} An object representing the issue.
*/
export const generateIssue = function (internalCode, parameters) {
const issueCodeData = issueData[internalCode] ?? issueData.genericError
const issueCodeData = issueData[internalCode] ?? issueData.internalError
const { hedCode, level } = issueCodeData
if (issueCodeData === issueData.genericError) {
if (issueCodeData === issueData.internalError) {
parameters.internalCode = internalCode
parameters.parameters = 'Issue parameters: ' + JSON.stringify(parameters)
}
Expand Down
Loading