Skip to content

Commit 9652481

Browse files
authored
In test suite, drop source from non-fallback formatted parts (#1061)
* Drop source from non-fallback formatted parts * Fix test schema, fix ajv warnings * Use relative reference for $schema
1 parent 11f98cb commit 9652481

File tree

17 files changed

+60
-81
lines changed

17 files changed

+60
-81
lines changed

.github/workflows/validate_tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
paths:
88
- test/**
99
pull_request:
10-
branches: '**'
1110
paths:
1211
- test/**
1312

@@ -22,7 +21,7 @@ jobs:
2221
run: npm install --global ajv-cli
2322
- name: Validate tests using the latest schema version
2423
run: >
25-
ajv validate --spec=draft2020
24+
ajv validate --spec=draft2020 --allow-union-types
2625
-s $(ls -1v schemas/*/*schema.json | tail -1)
2726
-d 'tests/**/*.json'
2827
working-directory: ./test

test/schemas/v0/tests.schema.json

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
{
4040
"properties": {
4141
"defaultTestProperties": {
42+
"type": "object",
4243
"required": [
4344
"locale"
4445
]
@@ -50,6 +51,7 @@
5051
"tests": {
5152
"type": "array",
5253
"items": {
54+
"type": "object",
5355
"required": [
5456
"locale"
5557
]
@@ -64,6 +66,7 @@
6466
{
6567
"properties": {
6668
"defaultTestProperties": {
69+
"type": "object",
6770
"required": [
6871
"src"
6972
]
@@ -75,6 +78,7 @@
7578
"tests": {
7679
"type": "array",
7780
"items": {
81+
"type": "object",
7882
"required": [
7983
"src"
8084
]
@@ -290,9 +294,6 @@
290294
"close"
291295
]
292296
},
293-
"source": {
294-
"type": "string"
295-
},
296297
"name": {
297298
"type": "string"
298299
},
@@ -308,23 +309,21 @@
308309
"description": "Message expression part.",
309310
"type": "object",
310311
"required": [
311-
"type",
312-
"source"
312+
"type"
313313
],
314-
"not": {
315-
"required": [
316-
"parts",
317-
"value"
318-
]
319-
},
320314
"properties": {
321315
"type": {
322-
"type": "string"
316+
"enum": [
317+
"datetime",
318+
"number",
319+
"string",
320+
"test"
321+
]
323322
},
324-
"source": {
323+
"locale": {
325324
"type": "string"
326325
},
327-
"locale": {
326+
"id": {
328327
"type": "string"
329328
},
330329
"parts": {
@@ -334,11 +333,7 @@
334333
"properties": {
335334
"type": {
336335
"type": "string"
337-
},
338-
"source": {
339-
"type": "string"
340-
},
341-
"value": {}
336+
}
342337
},
343338
"required": [
344339
"type"
@@ -347,6 +342,23 @@
347342
},
348343
"value": {}
349344
}
345+
},
346+
{
347+
"description": "Fallback part.",
348+
"type": "object",
349+
"additionalProperties": false,
350+
"required": [
351+
"type",
352+
"source"
353+
],
354+
"properties": {
355+
"type": {
356+
"const": "fallback"
357+
},
358+
"source": {
359+
"type": "string"
360+
}
361+
}
350362
}
351363
]
352364
}
@@ -385,6 +397,7 @@
385397
}
386398
},
387399
"anyExp": {
400+
"type": "object",
388401
"anyOf": [
389402
{
390403
"required": [

test/tests/bidi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../schemas/v0/tests.schema.json",
23
"scenario": "Bidi support",
34
"description": "Tests for correct parsing of messages with bidirectional marks and isolates",
45
"defaultTestProperties": {

test/tests/data-model-errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
2+
"$schema": "../schemas/v0/tests.schema.json",
33
"scenario": "Data model errors",
44
"defaultTestProperties": {
55
"locale": "en-US"

test/tests/fallback.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
2+
"$schema": "../schemas/v0/tests.schema.json",
33
"scenario": "Fallback",
44
"description": "Test cases for fallback behaviour.",
55
"defaultTestProperties": {
@@ -11,7 +11,8 @@
1111
{
1212
"description": "function with unquoted literal operand",
1313
"src": "{42 :test:function fails=format}",
14-
"exp": "{|42|}"
14+
"exp": "{|42|}",
15+
"expParts": [{ "type": "fallback", "source": "|42|" }]
1516
},
1617
{
1718
"description": "function with quoted literal operand",
@@ -26,7 +27,8 @@
2627
{
2728
"description": "annotated implicit input variable",
2829
"src": "{$var :number}",
29-
"exp": "{$var}"
30+
"exp": "{$var}",
31+
"expParts": [{ "type": "fallback", "source": "$var" }]
3032
},
3133
{
3234
"description": "local variable with unknown function in declaration",
@@ -46,7 +48,8 @@
4648
{
4749
"description": "function with no operand",
4850
"src": "{:test:undefined}",
49-
"exp": "{:test:undefined}"
51+
"exp": "{:test:undefined}",
52+
"expParts": [{ "type": "fallback", "source": ":test:undefined" }]
5053
}
5154
]
5255
}

test/tests/functions/currency.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
2+
"$schema": "../../schemas/v0/tests.schema.json",
33
"scenario": "Currency function",
44
"description": "The built-in formatter and selector for currencies.",
55
"defaultTestProperties": {

test/tests/functions/date.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
2+
"$schema": "../../schemas/v0/tests.schema.json",
33
"scenario": "Date function",
44
"description": "The built-in formatter for dates.",
55
"defaultTestProperties": {

test/tests/functions/datetime.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
2+
"$schema": "../../schemas/v0/tests.schema.json",
33
"scenario": "Datetime function",
44
"description": "The built-in formatter for datetimes.",
55
"defaultTestProperties": {

test/tests/functions/integer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
2+
"$schema": "../../schemas/v0/tests.schema.json",
33
"scenario": "Integer function",
44
"description": "The built-in formatter for integers.",
55
"defaultTestProperties": {

test/tests/functions/math.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
2+
"$schema": "../../schemas/v0/tests.schema.json",
33
"scenario": "Math function",
44
"description": "The built-in formatter and selector for addition and subtraction.",
55
"defaultTestProperties": {

0 commit comments

Comments
 (0)