Skip to content

Commit 8a1c473

Browse files
authored
Upgrade Core to 1f23fc7df56f41ceb140719bbcf94ee6f4d6f066 (#498)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 177e566 commit 8a1c473

90 files changed

Lines changed: 1617 additions & 1120 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DEPENDENCIES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4
2-
core https://github.com/sourcemeta/core 1e83e267f00bd5686d9546fb20877bf6e4b20dc5
2+
core https://github.com/sourcemeta/core 1f23fc7df56f41ceb140719bbcf94ee6f4d6f066
33
jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite 15e4505bf689de5d30c29d50782bb48fa465c93f

src/linter/include/sourcemeta/blaze/linter.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class SOURCEMETA_BLAZE_LINTER_EXPORT ValidExamples final
3535
const sourcemeta::core::SchemaWalker &,
3636
const sourcemeta::core::SchemaResolver &) const
3737
-> sourcemeta::core::SchemaTransformRule::Result override;
38-
auto transform(sourcemeta::core::JSON &) const -> void override;
38+
auto transform(sourcemeta::core::JSON &,
39+
const sourcemeta::core::SchemaTransformRule::Result &) const
40+
-> void override;
3941

4042
private:
4143
// Exporting symbols that depends on the standard C++ library is considered
@@ -66,7 +68,9 @@ class SOURCEMETA_BLAZE_LINTER_EXPORT ValidDefault final
6668
const sourcemeta::core::SchemaWalker &,
6769
const sourcemeta::core::SchemaResolver &) const
6870
-> sourcemeta::core::SchemaTransformRule::Result override;
69-
auto transform(sourcemeta::core::JSON &) const -> void override;
71+
auto transform(sourcemeta::core::JSON &,
72+
const sourcemeta::core::SchemaTransformRule::Result &) const
73+
-> void override;
7074

7175
private:
7276
// Exporting symbols that depends on the standard C++ library is considered

src/linter/valid_default.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ auto ValidDefault::condition(
7575

7676
std::ostringstream message;
7777
output.stacktrace(message);
78-
return message.str();
78+
return {{{"default"}}, std::move(message).str()};
7979
}
8080

81-
auto ValidDefault::transform(sourcemeta::core::JSON &schema) const -> void {
81+
auto ValidDefault::transform(
82+
sourcemeta::core::JSON &schema,
83+
const sourcemeta::core::SchemaTransformRule::Result &) const -> void {
8284
schema.erase("default");
8385
}
8486

src/linter/valid_examples.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ auto ValidExamples::condition(
8282
std::ostringstream message;
8383
message << "Invalid example instance at index " << cursor << "\n";
8484
output.stacktrace(message, " ");
85-
return message.str();
85+
return {{{"examples", cursor}}, std::move(message).str()};
8686
}
8787

8888
cursor += 1;
@@ -91,7 +91,9 @@ auto ValidExamples::condition(
9191
return false;
9292
}
9393

94-
auto ValidExamples::transform(sourcemeta::core::JSON &schema) const -> void {
94+
auto ValidExamples::transform(
95+
sourcemeta::core::JSON &schema,
96+
const sourcemeta::core::SchemaTransformRule::Result &) const -> void {
9597
schema.erase("examples");
9698
}
9799

test/linter/linter_valid_default_test.cc

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include <sourcemeta/core/json.h>
66
#include <sourcemeta/core/jsonschema.h>
77

8-
static auto transformer_callback_error(const sourcemeta::core::Pointer &,
9-
const std::string_view,
10-
const std::string_view,
11-
const std::string_view) -> void {
8+
static auto transformer_callback_error(
9+
const sourcemeta::core::Pointer &, const std::string_view,
10+
const std::string_view,
11+
const sourcemeta::core::SchemaTransformRule::Result &) -> void {
1212
throw std::runtime_error("The transform callback must not be called");
1313
}
1414

@@ -28,14 +28,14 @@ TEST(Linter, valid_default_error_message_without_id_nested) {
2828
})JSON")};
2929

3030
std::vector<std::tuple<sourcemeta::core::Pointer, std::string, std::string,
31-
std::string>>
31+
sourcemeta::core::SchemaTransformRule::Result>>
3232
entries;
3333
const auto result =
3434
bundle.check(schema, sourcemeta::core::schema_official_walker,
3535
sourcemeta::core::schema_official_resolver,
3636
[&entries](const auto &pointer, const auto &name,
37-
const auto &message, const auto &description) {
38-
entries.emplace_back(pointer, name, message, description);
37+
const auto &message, const auto &outcome) {
38+
entries.emplace_back(pointer, name, message, outcome);
3939
});
4040

4141
EXPECT_FALSE(result.first);
@@ -46,12 +46,18 @@ TEST(Linter, valid_default_error_message_without_id_nested) {
4646
EXPECT_EQ(std::get<1>(entries.at(0)), "blaze/valid_default");
4747
EXPECT_EQ(std::get<2>(entries.at(0)),
4848
"Only set a `default` value that validates against the schema");
49+
EXPECT_TRUE(std::get<3>(entries.at(0)).description.has_value());
4950
EXPECT_EQ(
50-
std::get<3>(entries.at(0)),
51+
std::get<3>(entries.at(0)).description.value(),
5152
R"TXT(The value was expected to be of type string but it was of type integer
5253
at instance location ""
5354
at evaluate path "/type"
5455
)TXT");
56+
57+
EXPECT_EQ(std::get<3>(entries.at(0)).locations.size(), 1);
58+
EXPECT_EQ(
59+
sourcemeta::core::to_string(std::get<3>(entries.at(0)).locations.at(0)),
60+
"/default");
5561
}
5662

5763
TEST(Linter, valid_default_error_message_without_id_flat) {
@@ -66,14 +72,14 @@ TEST(Linter, valid_default_error_message_without_id_flat) {
6672
})JSON")};
6773

6874
std::vector<std::tuple<sourcemeta::core::Pointer, std::string, std::string,
69-
std::string>>
75+
sourcemeta::core::SchemaTransformRule::Result>>
7076
entries;
7177
const auto result =
7278
bundle.check(schema, sourcemeta::core::schema_official_walker,
7379
sourcemeta::core::schema_official_resolver,
7480
[&entries](const auto &pointer, const auto &name,
75-
const auto &message, const auto &description) {
76-
entries.emplace_back(pointer, name, message, description);
81+
const auto &message, const auto &outcome) {
82+
entries.emplace_back(pointer, name, message, outcome);
7783
});
7884

7985
EXPECT_FALSE(result.first);
@@ -83,12 +89,18 @@ TEST(Linter, valid_default_error_message_without_id_flat) {
8389
EXPECT_EQ(std::get<1>(entries.at(0)), "blaze/valid_default");
8490
EXPECT_EQ(std::get<2>(entries.at(0)),
8591
"Only set a `default` value that validates against the schema");
92+
EXPECT_TRUE(std::get<3>(entries.at(0)).description.has_value());
8693
EXPECT_EQ(
87-
std::get<3>(entries.at(0)),
94+
std::get<3>(entries.at(0)).description.value(),
8895
R"TXT(The value was expected to be of type string but it was of type integer
8996
at instance location ""
9097
at evaluate path "/type"
9198
)TXT");
99+
100+
EXPECT_EQ(std::get<3>(entries.at(0)).locations.size(), 1);
101+
EXPECT_EQ(
102+
sourcemeta::core::to_string(std::get<3>(entries.at(0)).locations.at(0)),
103+
"/default");
92104
}
93105

94106
TEST(Linter, valid_default_error_message_with_id_nested) {
@@ -108,14 +120,14 @@ TEST(Linter, valid_default_error_message_with_id_nested) {
108120
})JSON")};
109121

110122
std::vector<std::tuple<sourcemeta::core::Pointer, std::string, std::string,
111-
std::string>>
123+
sourcemeta::core::SchemaTransformRule::Result>>
112124
entries;
113125
const auto result =
114126
bundle.check(schema, sourcemeta::core::schema_official_walker,
115127
sourcemeta::core::schema_official_resolver,
116128
[&entries](const auto &pointer, const auto &name,
117-
const auto &message, const auto &description) {
118-
entries.emplace_back(pointer, name, message, description);
129+
const auto &message, const auto &outcome) {
130+
entries.emplace_back(pointer, name, message, outcome);
119131
});
120132

121133
EXPECT_FALSE(result.first);
@@ -126,12 +138,18 @@ TEST(Linter, valid_default_error_message_with_id_nested) {
126138
EXPECT_EQ(std::get<1>(entries.at(0)), "blaze/valid_default");
127139
EXPECT_EQ(std::get<2>(entries.at(0)),
128140
"Only set a `default` value that validates against the schema");
141+
EXPECT_TRUE(std::get<3>(entries.at(0)).description.has_value());
129142
EXPECT_EQ(
130-
std::get<3>(entries.at(0)),
143+
std::get<3>(entries.at(0)).description.value(),
131144
R"TXT(The value was expected to be of type string but it was of type integer
132145
at instance location ""
133146
at evaluate path "/type"
134147
)TXT");
148+
149+
EXPECT_EQ(std::get<3>(entries.at(0)).locations.size(), 1);
150+
EXPECT_EQ(
151+
sourcemeta::core::to_string(std::get<3>(entries.at(0)).locations.at(0)),
152+
"/default");
135153
}
136154

137155
TEST(Linter, valid_default_error_message_with_id_flat) {
@@ -147,14 +165,14 @@ TEST(Linter, valid_default_error_message_with_id_flat) {
147165
})JSON")};
148166

149167
std::vector<std::tuple<sourcemeta::core::Pointer, std::string, std::string,
150-
std::string>>
168+
sourcemeta::core::SchemaTransformRule::Result>>
151169
entries;
152170
const auto result =
153171
bundle.check(schema, sourcemeta::core::schema_official_walker,
154172
sourcemeta::core::schema_official_resolver,
155173
[&entries](const auto &pointer, const auto &name,
156-
const auto &message, const auto &description) {
157-
entries.emplace_back(pointer, name, message, description);
174+
const auto &message, const auto &outcome) {
175+
entries.emplace_back(pointer, name, message, outcome);
158176
});
159177

160178
EXPECT_FALSE(result.first);
@@ -164,12 +182,18 @@ TEST(Linter, valid_default_error_message_with_id_flat) {
164182
EXPECT_EQ(std::get<1>(entries.at(0)), "blaze/valid_default");
165183
EXPECT_EQ(std::get<2>(entries.at(0)),
166184
"Only set a `default` value that validates against the schema");
185+
EXPECT_TRUE(std::get<3>(entries.at(0)).description.has_value());
167186
EXPECT_EQ(
168-
std::get<3>(entries.at(0)),
187+
std::get<3>(entries.at(0)).description.value(),
169188
R"TXT(The value was expected to be of type string but it was of type integer
170189
at instance location ""
171190
at evaluate path "/type"
172191
)TXT");
192+
193+
EXPECT_EQ(std::get<3>(entries.at(0)).locations.size(), 1);
194+
EXPECT_EQ(
195+
sourcemeta::core::to_string(std::get<3>(entries.at(0)).locations.at(0)),
196+
"/default");
173197
}
174198

175199
TEST(Linter, valid_default_1) {

test/linter/linter_valid_examples_test.cc

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include <sourcemeta/core/json.h>
66
#include <sourcemeta/core/jsonschema.h>
77

8-
static auto transformer_callback_error(const sourcemeta::core::Pointer &,
9-
const std::string_view,
10-
const std::string_view,
11-
const std::string_view) -> void {
8+
static auto transformer_callback_error(
9+
const sourcemeta::core::Pointer &, const std::string_view,
10+
const std::string_view,
11+
const sourcemeta::core::SchemaTransformRule::Result &) -> void {
1212
throw std::runtime_error("The transform callback must not be called");
1313
}
1414

@@ -28,14 +28,14 @@ TEST(Linter, valid_examples_error_message_without_id_nested) {
2828
})JSON")};
2929

3030
std::vector<std::tuple<sourcemeta::core::Pointer, std::string, std::string,
31-
std::string>>
31+
sourcemeta::core::SchemaTransformRule::Result>>
3232
entries;
3333
const auto result =
3434
bundle.check(schema, sourcemeta::core::schema_official_walker,
3535
sourcemeta::core::schema_official_resolver,
3636
[&entries](const auto &pointer, const auto &name,
37-
const auto &message, const auto &description) {
38-
entries.emplace_back(pointer, name, message, description);
37+
const auto &message, const auto &outcome) {
38+
entries.emplace_back(pointer, name, message, outcome);
3939
});
4040

4141
EXPECT_FALSE(result.first);
@@ -47,12 +47,18 @@ TEST(Linter, valid_examples_error_message_without_id_nested) {
4747
EXPECT_EQ(std::get<2>(entries.at(0)),
4848
"Only include instances in the `examples` array that validate "
4949
"against the schema");
50-
EXPECT_EQ(std::get<3>(entries.at(0)),
50+
EXPECT_TRUE(std::get<3>(entries.at(0)).description.has_value());
51+
EXPECT_EQ(std::get<3>(entries.at(0)).description.value(),
5152
R"TXT(Invalid example instance at index 0
5253
The value was expected to be of type string but it was of type integer
5354
at instance location ""
5455
at evaluate path "/type"
5556
)TXT");
57+
58+
EXPECT_EQ(std::get<3>(entries.at(0)).locations.size(), 1);
59+
EXPECT_EQ(
60+
sourcemeta::core::to_string(std::get<3>(entries.at(0)).locations.at(0)),
61+
"/examples/0");
5662
}
5763

5864
TEST(Linter, valid_examples_error_message_without_id_flat) {
@@ -67,14 +73,14 @@ TEST(Linter, valid_examples_error_message_without_id_flat) {
6773
})JSON")};
6874

6975
std::vector<std::tuple<sourcemeta::core::Pointer, std::string, std::string,
70-
std::string>>
76+
sourcemeta::core::SchemaTransformRule::Result>>
7177
entries;
7278
const auto result =
7379
bundle.check(schema, sourcemeta::core::schema_official_walker,
7480
sourcemeta::core::schema_official_resolver,
7581
[&entries](const auto &pointer, const auto &name,
76-
const auto &message, const auto &description) {
77-
entries.emplace_back(pointer, name, message, description);
82+
const auto &message, const auto &outcome) {
83+
entries.emplace_back(pointer, name, message, outcome);
7884
});
7985

8086
EXPECT_FALSE(result.first);
@@ -85,12 +91,18 @@ TEST(Linter, valid_examples_error_message_without_id_flat) {
8591
EXPECT_EQ(std::get<2>(entries.at(0)),
8692
"Only include instances in the `examples` array that validate "
8793
"against the schema");
88-
EXPECT_EQ(std::get<3>(entries.at(0)),
94+
EXPECT_TRUE(std::get<3>(entries.at(0)).description.has_value());
95+
EXPECT_EQ(std::get<3>(entries.at(0)).description.value(),
8996
R"TXT(Invalid example instance at index 0
9097
The value was expected to be of type string but it was of type integer
9198
at instance location ""
9299
at evaluate path "/type"
93100
)TXT");
101+
102+
EXPECT_EQ(std::get<3>(entries.at(0)).locations.size(), 1);
103+
EXPECT_EQ(
104+
sourcemeta::core::to_string(std::get<3>(entries.at(0)).locations.at(0)),
105+
"/examples/0");
94106
}
95107

96108
TEST(Linter, valid_examples_error_message_with_id_nested) {
@@ -110,14 +122,14 @@ TEST(Linter, valid_examples_error_message_with_id_nested) {
110122
})JSON")};
111123

112124
std::vector<std::tuple<sourcemeta::core::Pointer, std::string, std::string,
113-
std::string>>
125+
sourcemeta::core::SchemaTransformRule::Result>>
114126
entries;
115127
const auto result =
116128
bundle.check(schema, sourcemeta::core::schema_official_walker,
117129
sourcemeta::core::schema_official_resolver,
118130
[&entries](const auto &pointer, const auto &name,
119-
const auto &message, const auto &description) {
120-
entries.emplace_back(pointer, name, message, description);
131+
const auto &message, const auto &outcome) {
132+
entries.emplace_back(pointer, name, message, outcome);
121133
});
122134

123135
EXPECT_FALSE(result.first);
@@ -129,12 +141,18 @@ TEST(Linter, valid_examples_error_message_with_id_nested) {
129141
EXPECT_EQ(std::get<2>(entries.at(0)),
130142
"Only include instances in the `examples` array that validate "
131143
"against the schema");
132-
EXPECT_EQ(std::get<3>(entries.at(0)),
144+
EXPECT_TRUE(std::get<3>(entries.at(0)).description.has_value());
145+
EXPECT_EQ(std::get<3>(entries.at(0)).description.value(),
133146
R"TXT(Invalid example instance at index 0
134147
The value was expected to be of type string but it was of type integer
135148
at instance location ""
136149
at evaluate path "/type"
137150
)TXT");
151+
152+
EXPECT_EQ(std::get<3>(entries.at(0)).locations.size(), 1);
153+
EXPECT_EQ(
154+
sourcemeta::core::to_string(std::get<3>(entries.at(0)).locations.at(0)),
155+
"/examples/0");
138156
}
139157

140158
TEST(Linter, valid_examples_error_message_with_id_flat) {
@@ -150,14 +168,14 @@ TEST(Linter, valid_examples_error_message_with_id_flat) {
150168
})JSON")};
151169

152170
std::vector<std::tuple<sourcemeta::core::Pointer, std::string, std::string,
153-
std::string>>
171+
sourcemeta::core::SchemaTransformRule::Result>>
154172
entries;
155173
const auto result =
156174
bundle.check(schema, sourcemeta::core::schema_official_walker,
157175
sourcemeta::core::schema_official_resolver,
158176
[&entries](const auto &pointer, const auto &name,
159-
const auto &message, const auto &description) {
160-
entries.emplace_back(pointer, name, message, description);
177+
const auto &message, const auto &outcome) {
178+
entries.emplace_back(pointer, name, message, outcome);
161179
});
162180

163181
EXPECT_FALSE(result.first);
@@ -168,12 +186,18 @@ TEST(Linter, valid_examples_error_message_with_id_flat) {
168186
EXPECT_EQ(std::get<2>(entries.at(0)),
169187
"Only include instances in the `examples` array that validate "
170188
"against the schema");
171-
EXPECT_EQ(std::get<3>(entries.at(0)),
189+
EXPECT_TRUE(std::get<3>(entries.at(0)).description.has_value());
190+
EXPECT_EQ(std::get<3>(entries.at(0)).description.value(),
172191
R"TXT(Invalid example instance at index 0
173192
The value was expected to be of type string but it was of type integer
174193
at instance location ""
175194
at evaluate path "/type"
176195
)TXT");
196+
197+
EXPECT_EQ(std::get<3>(entries.at(0)).locations.size(), 1);
198+
EXPECT_EQ(
199+
sourcemeta::core::to_string(std::get<3>(entries.at(0)).locations.at(0)),
200+
"/examples/0");
177201
}
178202

179203
TEST(Linter, valid_examples_1) {

0 commit comments

Comments
 (0)