this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

encoding/jsonschema: use StrictFeatures in external tests

The spec specifically says that unknown keywords should be ignored, so
use `StrictFeatures` in the external tests so they correspond better to
the spec.

Also, use `StrictFeatures` rather than `Strict` in one of the
constraints, as we should never be using `Strict` as a condition.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: If4d66285b6a9f77bb6ae4915a4818967290578f2
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1201117
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+41 -101
+2 -2
encoding/jsonschema/constraints_meta.go
··· 34 34 } 35 35 36 36 if u.Fragment != "" { 37 - // TODO do not use Strict for this. The specification is clear: 37 + // TODO do not use StrictFeatures for this. The specification is clear: 38 38 // before 2019-09, IDs could contain plain-name fragments; 39 39 // (see https://json-schema.org/draft-07/draft-handrews-json-schema-01#rfc.section.5) 40 40 // afterwards, $anchor was reserved for that purpose. 41 - if s.cfg.Strict { 41 + if s.cfg.StrictFeatures { 42 42 s.errf(n, "$id URI may not contain a fragment") 43 43 } 44 44 return
+1 -1
encoding/jsonschema/external_test.go
··· 92 92 t.Skipf("skipping test for unknown schema version %v", versStr) 93 93 } 94 94 schemaAST, extractErr := jsonschema.Extract(jsonValue, &jsonschema.Config{ 95 - Strict: true, 95 + StrictFeatures: true, 96 96 DefaultVersion: vers, 97 97 }) 98 98 var schemaValue cue.Value
+6 -6
encoding/jsonschema/external_teststats.txt
··· 1 1 # Generated by teststats. DO NOT EDIT 2 2 v2: 3 - schema extract (pass / total): 1072 / 1637 = 65.5% 4 - tests (pass / total): 3457 / 7175 = 48.2% 5 - tests on extracted schemas (pass / total): 3457 / 3874 = 89.2% 3 + schema extract (pass / total): 1077 / 1637 = 65.8% 4 + tests (pass / total): 3467 / 7175 = 48.3% 5 + tests on extracted schemas (pass / total): 3467 / 3884 = 89.3% 6 6 7 7 v3: 8 - schema extract (pass / total): 1060 / 1637 = 64.8% 9 - tests (pass / total): 3408 / 7175 = 47.5% 10 - tests on extracted schemas (pass / total): 3408 / 3830 = 89.0% 8 + schema extract (pass / total): 1065 / 1637 = 65.1% 9 + tests (pass / total): 3418 / 7175 = 47.6% 10 + tests on extracted schemas (pass / total): 3418 / 3840 = 89.0%
+4 -4
encoding/jsonschema/testdata/external/tests/draft2019-09/optional/refOfUnknownKeyword.json
··· 13 13 } 14 14 }, 15 15 "skip": { 16 - "v2": "extract error: unknown keyword \"unknown-keyword\"", 17 - "v3": "extract error: unknown keyword \"unknown-keyword\"" 16 + "v2": "extract error: cannot compile resulting schema: bar: reference \"_X0\" not found:\n generated.cue:3:8\n", 17 + "v3": "extract error: cannot compile resulting schema: bar: reference \"_X0\" not found:\n generated.cue:3:8\n" 18 18 }, 19 19 "tests": [ 20 20 { ··· 57 57 } 58 58 }, 59 59 "skip": { 60 - "v2": "extract error: unknown keyword \"unknown-keyword\"", 61 - "v3": "extract error: unknown keyword \"unknown-keyword\"" 60 + "v2": "extract error: cannot compile resulting schema: bar: reference \"foo\" not found:\n generated.cue:4:10\n", 61 + "v3": "extract error: cannot compile resulting schema: bar: reference \"foo\" not found:\n generated.cue:4:10\n" 62 62 }, 63 63 "tests": [ 64 64 {
+2 -2
encoding/jsonschema/testdata/external/tests/draft2019-09/optional/unknownKeyword.json
··· 43 43 ] 44 44 }, 45 45 "skip": { 46 - "v2": "extract error: unknown keyword \"array_of_schemas\" (and 1 more errors)", 47 - "v3": "extract error: unknown keyword \"array_of_schemas\" (and 1 more errors)" 46 + "v2": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/draft2019-09/unknownKeyword/my_identifier.json:my_identifier\":\n generated.cue:1:8\n", 47 + "v3": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/draft2019-09/unknownKeyword/my_identifier.json:my_identifier\":\n generated.cue:1:8\n" 48 48 }, 49 49 "tests": [ 50 50 {
+4 -4
encoding/jsonschema/testdata/external/tests/draft2020-12/optional/refOfUnknownKeyword.json
··· 13 13 } 14 14 }, 15 15 "skip": { 16 - "v2": "extract error: unknown keyword \"unknown-keyword\"", 17 - "v3": "extract error: unknown keyword \"unknown-keyword\"" 16 + "v2": "extract error: cannot compile resulting schema: bar: reference \"_X0\" not found:\n generated.cue:3:8\n", 17 + "v3": "extract error: cannot compile resulting schema: bar: reference \"_X0\" not found:\n generated.cue:3:8\n" 18 18 }, 19 19 "tests": [ 20 20 { ··· 57 57 } 58 58 }, 59 59 "skip": { 60 - "v2": "extract error: unknown keyword \"unknown-keyword\"", 61 - "v3": "extract error: unknown keyword \"unknown-keyword\"" 60 + "v2": "extract error: cannot compile resulting schema: bar: reference \"foo\" not found:\n generated.cue:4:10\n", 61 + "v3": "extract error: cannot compile resulting schema: bar: reference \"foo\" not found:\n generated.cue:4:10\n" 62 62 }, 63 63 "tests": [ 64 64 {
+2 -2
encoding/jsonschema/testdata/external/tests/draft2020-12/optional/unknownKeyword.json
··· 43 43 ] 44 44 }, 45 45 "skip": { 46 - "v2": "extract error: unknown keyword \"array_of_schemas\" (and 1 more errors)", 47 - "v3": "extract error: unknown keyword \"array_of_schemas\" (and 1 more errors)" 46 + "v2": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/draft2020-12/unknownKeyword/my_identifier.json:my_identifier\":\n generated.cue:1:8\n", 47 + "v3": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/draft2020-12/unknownKeyword/my_identifier.json:my_identifier\":\n generated.cue:1:8\n" 48 48 }, 49 49 "tests": [ 50 50 {
+2 -2
encoding/jsonschema/testdata/external/tests/draft4/optional/id.json
··· 33 33 ] 34 34 }, 35 35 "skip": { 36 - "v2": "extract error: keyword \"const\" is not supported in JSON schema version http://json-schema.org/draft-04/schema#", 37 - "v3": "extract error: keyword \"const\" is not supported in JSON schema version http://json-schema.org/draft-04/schema#" 36 + "v2": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/my_identifier.json:my_identifier\":\n generated.cue:1:8\n", 37 + "v3": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/my_identifier.json:my_identifier\":\n generated.cue:1:8\n" 38 38 }, 39 39 "tests": [ 40 40 {
+2 -2
encoding/jsonschema/testdata/external/tests/draft4/ref.json
··· 329 329 ] 330 330 }, 331 331 "skip": { 332 - "v2": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-04/schema# (and 1 more errors)", 333 - "v3": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-04/schema# (and 1 more errors)" 332 + "v2": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/sibling_id/foo.json:foo\":\n generated.cue:1:8\n", 333 + "v3": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/sibling_id/foo.json:foo\":\n generated.cue:1:8\n" 334 334 }, 335 335 "tests": [ 336 336 {
+2 -2
encoding/jsonschema/testdata/external/tests/draft6/optional/unknownKeyword.json
··· 42 42 ] 43 43 }, 44 44 "skip": { 45 - "v2": "extract error: unknown keyword \"array_of_schemas\" (and 1 more errors)", 46 - "v3": "extract error: unknown keyword \"array_of_schemas\" (and 1 more errors)" 45 + "v2": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/unknownKeyword/my_identifier.json:my_identifier\":\n generated.cue:1:8\n", 46 + "v3": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/unknownKeyword/my_identifier.json:my_identifier\":\n generated.cue:1:8\n" 47 47 }, 48 48 "tests": [ 49 49 {
+12 -72
encoding/jsonschema/testdata/external/tests/draft6/ref.json
··· 329 329 ] 330 330 }, 331 331 "skip": { 332 - "v2": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema# (and 1 more errors)", 333 - "v3": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema# (and 1 more errors)" 332 + "v2": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/sibling_id/foo.json:foo\":\n generated.cue:1:8\n", 333 + "v3": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/sibling_id/foo.json:foo\":\n generated.cue:1:8\n" 334 334 }, 335 335 "tests": [ 336 336 { ··· 993 993 } 994 994 } 995 995 }, 996 - "skip": { 997 - "v2": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#", 998 - "v3": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#" 999 - }, 1000 996 "tests": [ 1001 997 { 1002 998 "description": "valid under the URN IDed schema", 1003 999 "data": { 1004 1000 "foo": 37 1005 1001 }, 1006 - "valid": true, 1007 - "skip": { 1008 - "v2": "could not compile schema", 1009 - "v3": "could not compile schema" 1010 - } 1002 + "valid": true 1011 1003 }, 1012 1004 { 1013 1005 "description": "invalid under the URN IDed schema", 1014 1006 "data": { 1015 1007 "foo": 12 1016 1008 }, 1017 - "valid": false, 1018 - "skip": { 1019 - "v2": "could not compile schema", 1020 - "v3": "could not compile schema" 1021 - } 1009 + "valid": false 1022 1010 } 1023 1011 ] 1024 1012 }, ··· 1037 1025 "type": "string" 1038 1026 } 1039 1027 } 1040 - }, 1041 - "skip": { 1042 - "v2": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#", 1043 - "v3": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#" 1044 1028 }, 1045 1029 "tests": [ 1046 1030 { ··· 1048 1032 "data": { 1049 1033 "foo": "bar" 1050 1034 }, 1051 - "valid": true, 1052 - "skip": { 1053 - "v2": "could not compile schema", 1054 - "v3": "could not compile schema" 1055 - } 1035 + "valid": true 1056 1036 }, 1057 1037 { 1058 1038 "description": "a non-string is invalid", 1059 1039 "data": { 1060 1040 "foo": 12 1061 1041 }, 1062 - "valid": false, 1063 - "skip": { 1064 - "v2": "could not compile schema", 1065 - "v3": "could not compile schema" 1066 - } 1042 + "valid": false 1067 1043 } 1068 1044 ] 1069 1045 }, ··· 1083 1059 } 1084 1060 } 1085 1061 }, 1086 - "skip": { 1087 - "v2": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#", 1088 - "v3": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#" 1089 - }, 1090 1062 "tests": [ 1091 1063 { 1092 1064 "description": "a string is valid", 1093 1065 "data": { 1094 1066 "foo": "bar" 1095 1067 }, 1096 - "valid": true, 1097 - "skip": { 1098 - "v2": "could not compile schema", 1099 - "v3": "could not compile schema" 1100 - } 1068 + "valid": true 1101 1069 }, 1102 1070 { 1103 1071 "description": "a non-string is invalid", 1104 1072 "data": { 1105 1073 "foo": 12 1106 1074 }, 1107 - "valid": false, 1108 - "skip": { 1109 - "v2": "could not compile schema", 1110 - "v3": "could not compile schema" 1111 - } 1075 + "valid": false 1112 1076 } 1113 1077 ] 1114 1078 }, ··· 1128 1092 } 1129 1093 } 1130 1094 }, 1131 - "skip": { 1132 - "v2": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#", 1133 - "v3": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#" 1134 - }, 1135 1095 "tests": [ 1136 1096 { 1137 1097 "description": "a string is valid", 1138 1098 "data": { 1139 1099 "foo": "bar" 1140 1100 }, 1141 - "valid": true, 1142 - "skip": { 1143 - "v2": "could not compile schema", 1144 - "v3": "could not compile schema" 1145 - } 1101 + "valid": true 1146 1102 }, 1147 1103 { 1148 1104 "description": "a non-string is invalid", 1149 1105 "data": { 1150 1106 "foo": 12 1151 1107 }, 1152 - "valid": false, 1153 - "skip": { 1154 - "v2": "could not compile schema", 1155 - "v3": "could not compile schema" 1156 - } 1108 + "valid": false 1157 1109 } 1158 1110 ] 1159 1111 }, ··· 1173 1125 } 1174 1126 } 1175 1127 }, 1176 - "skip": { 1177 - "v2": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#", 1178 - "v3": "extract error: keyword \"$comment\" is not supported in JSON schema version http://json-schema.org/draft-06/schema#" 1179 - }, 1180 1128 "tests": [ 1181 1129 { 1182 1130 "description": "a string is valid", 1183 1131 "data": { 1184 1132 "foo": "bar" 1185 1133 }, 1186 - "valid": true, 1187 - "skip": { 1188 - "v2": "could not compile schema", 1189 - "v3": "could not compile schema" 1190 - } 1134 + "valid": true 1191 1135 }, 1192 1136 { 1193 1137 "description": "a non-string is invalid", 1194 1138 "data": { 1195 1139 "foo": 12 1196 1140 }, 1197 - "valid": false, 1198 - "skip": { 1199 - "v2": "could not compile schema", 1200 - "v3": "could not compile schema" 1201 - } 1141 + "valid": false 1202 1142 } 1203 1143 ] 1204 1144 },
+2 -2
encoding/jsonschema/testdata/external/tests/draft7/optional/unknownKeyword.json
··· 42 42 ] 43 43 }, 44 44 "skip": { 45 - "v2": "extract error: unknown keyword \"array_of_schemas\" (and 1 more errors)", 46 - "v3": "extract error: unknown keyword \"array_of_schemas\" (and 1 more errors)" 45 + "v2": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/unknownKeyword/my_identifier.json:my_identifier\":\n generated.cue:1:8\n", 46 + "v3": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/unknownKeyword/my_identifier.json:my_identifier\":\n generated.cue:1:8\n" 47 47 }, 48 48 "tests": [ 49 49 {