Skip to content

Commit fcdf00a

Browse files
authored
Move AlterSchema into this project (#695)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent ecf6fe1 commit fcdf00a

162 files changed

Lines changed: 94341 additions & 2606 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.

.github/workflows/website-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
-DBLAZE_COMPILER:BOOL=OFF
2020
-DBLAZE_EVALUATOR:BOOL=OFF
2121
-DBLAZE_OUTPUT:BOOL=OFF
22-
-DBLAZE_LINTER:BOOL=OFF
2322
-DBLAZE_TEST:BOOL=OFF
2423
-DBLAZE_CONFIGURATION:BOOL=OFF
24+
-DBLAZE_ALTERSCHEMA:BOOL=OFF
2525
-DBLAZE_TESTS:BOOL=OFF
2626
-DBLAZE_DOCS:BOOL=ON
2727
- run: cmake --build ./build --config Release --target doxygen

.github/workflows/website-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
-DBLAZE_COMPILER:BOOL=OFF
3131
-DBLAZE_EVALUATOR:BOOL=OFF
3232
-DBLAZE_OUTPUT:BOOL=OFF
33-
-DBLAZE_LINTER:BOOL=OFF
3433
-DBLAZE_TEST:BOOL=OFF
3534
-DBLAZE_CONFIGURATION:BOOL=OFF
35+
-DBLAZE_ALTERSCHEMA:BOOL=OFF
3636
-DBLAZE_TESTS:BOOL=OFF
3737
-DBLAZE_DOCS:BOOL=ON
3838
- run: cmake --build ./build --config Release --target doxygen

CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
88
option(BLAZE_COMPILER "Build the Blaze compiler library" ON)
99
option(BLAZE_EVALUATOR "Build the Blaze evaluator library" ON)
1010
option(BLAZE_OUTPUT "Build the Blaze output formats library" ON)
11-
option(BLAZE_LINTER "Build the Blaze linter rule library" ON)
1211
option(BLAZE_TEST "Build the Blaze test runner library" ON)
1312
option(BLAZE_CONFIGURATION "Build the Blaze configuration file library" ON)
13+
option(BLAZE_ALTERSCHEMA "Build the Blaze alterschema rule library" ON)
1414
option(BLAZE_TESTS "Build the Blaze tests" OFF)
1515
option(BLAZE_BENCHMARK "Build the Blaze benchmarks" OFF)
1616
option(BLAZE_CONTRIB "Build the Blaze contrib programs" OFF)
@@ -55,10 +55,6 @@ if(BLAZE_OUTPUT)
5555
add_subdirectory(src/output)
5656
endif()
5757

58-
if(BLAZE_LINTER)
59-
add_subdirectory(src/linter)
60-
endif()
61-
6258
if(BLAZE_TEST)
6359
add_subdirectory(src/test)
6460
endif()
@@ -67,6 +63,10 @@ if(BLAZE_CONFIGURATION)
6763
add_subdirectory(src/configuration)
6864
endif()
6965

66+
if(BLAZE_ALTERSCHEMA)
67+
add_subdirectory(src/alterschema)
68+
endif()
69+
7070
if(BLAZE_CONTRIB)
7171
add_subdirectory(contrib)
7272
endif()
@@ -106,10 +106,6 @@ if(BLAZE_TESTS)
106106
add_subdirectory(test/output)
107107
endif()
108108

109-
if(BLAZE_LINTER)
110-
add_subdirectory(test/linter)
111-
endif()
112-
113109
if(BLAZE_TEST)
114110
add_subdirectory(test/test)
115111
endif()
@@ -118,6 +114,10 @@ if(BLAZE_TESTS)
118114
add_subdirectory(test/configuration)
119115
endif()
120116

117+
if(BLAZE_ALTERSCHEMA)
118+
add_subdirectory(test/alterschema)
119+
endif()
120+
121121
if(PROJECT_IS_TOP_LEVEL)
122122
# Otherwise we need the child project to link
123123
# against the sanitizers too.

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 1dcbac42809cf87cb5b045106b863e17ad84ba02
2-
core https://github.com/sourcemeta/core 94b0c4860231adfb18bb8d16951089f95bc3cc4c
2+
core https://github.com/sourcemeta/core e97b758619b7d483c3940da88bc067705c5e649d
33
jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite 06481b143722c8c06671bd40dcde99b422ffd531

benchmark/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ if(BLAZE_COMPILER AND BLAZE_EVALUATOR AND BLAZE_OUTPUT)
1010
micro/2020_12.cc)
1111
endif()
1212

13+
if(BLAZE_ALTERSCHEMA)
14+
list(APPEND BENCHMARK_SOURCES alterschema.cc)
15+
endif()
16+
1317
if(BENCHMARK_SOURCES)
1418
sourcemeta_googlebenchmark(NAMESPACE sourcemeta PROJECT blaze
1519
FOLDER "Blaze" SOURCES ${BENCHMARK_SOURCES})
@@ -37,9 +41,9 @@ if(BENCHMARK_SOURCES)
3741
target_link_libraries(sourcemeta_blaze_benchmark
3842
PRIVATE sourcemeta::blaze::output)
3943
endif()
40-
if(BLAZE_LINTER)
44+
if(BLAZE_ALTERSCHEMA)
4145
target_link_libraries(sourcemeta_blaze_benchmark
42-
PRIVATE sourcemeta::blaze::linter)
46+
PRIVATE sourcemeta::blaze::alterschema)
4347
endif()
4448

4549
add_custom_target(benchmark_all

benchmark/alterschema.cc

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#include <benchmark/benchmark.h>
2+
3+
#include <cassert> // assert
4+
#include <cstddef> // std::size_t
5+
#include <filesystem> // std::filesystem
6+
7+
#include <sourcemeta/blaze/alterschema.h>
8+
#include <sourcemeta/blaze/compiler.h>
9+
#include <sourcemeta/core/json.h>
10+
#include <sourcemeta/core/jsonschema.h>
11+
12+
static void
13+
Alterschema_Check_Readibility_ISO_Language_Set_3(benchmark::State &state) {
14+
const auto schema{sourcemeta::core::read_json(
15+
std::filesystem::path{CURRENT_DIRECTORY} / "files" /
16+
"2020_12_iso_language_2023_set_3.json")};
17+
18+
sourcemeta::core::SchemaTransformer bundle;
19+
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);
20+
21+
for (auto _ : state) {
22+
auto result = bundle.check(schema, sourcemeta::core::schema_walker,
23+
sourcemeta::core::schema_resolver,
24+
[](const auto &, const auto &, const auto &,
25+
const auto &, const auto &) {});
26+
assert(result.first);
27+
assert(result.second == 100);
28+
benchmark::DoNotOptimize(result);
29+
}
30+
}
31+
32+
static void Alterschema_Check_Readibility_OMC(benchmark::State &state) {
33+
const auto schema{
34+
sourcemeta::core::read_json(std::filesystem::path{CURRENT_DIRECTORY} /
35+
"files" / "2019_09_omc_json_v2.json")};
36+
37+
sourcemeta::core::SchemaTransformer bundle;
38+
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);
39+
40+
for (auto _ : state) {
41+
auto result = bundle.check(schema, sourcemeta::core::schema_walker,
42+
sourcemeta::core::schema_resolver,
43+
[](const auto &, const auto &, const auto &,
44+
const auto &, const auto &) {});
45+
assert(!result.first);
46+
benchmark::DoNotOptimize(result);
47+
}
48+
}
49+
50+
static void Alterschema_Check_Readibility_KrakenD(benchmark::State &state) {
51+
const auto schema{
52+
sourcemeta::core::read_json(std::filesystem::path{CURRENT_DIRECTORY} /
53+
"files" / "2019_09_krakend.json")};
54+
55+
sourcemeta::core::SchemaTransformer bundle;
56+
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);
57+
58+
for (auto _ : state) {
59+
auto result{bundle.check(schema, sourcemeta::core::schema_walker,
60+
sourcemeta::core::schema_resolver,
61+
[](const auto &, const auto &, const auto &,
62+
const auto &, const auto &) {})};
63+
benchmark::DoNotOptimize(result);
64+
}
65+
}
66+
67+
static void Alterschema_Apply_Readibility_KrakenD(benchmark::State &state) {
68+
sourcemeta::core::SchemaTransformer bundle;
69+
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);
70+
71+
const auto schema{
72+
sourcemeta::core::read_json(std::filesystem::path{CURRENT_DIRECTORY} /
73+
"files" / "2019_09_krakend.json")};
74+
75+
for (auto _ : state) {
76+
state.PauseTiming();
77+
auto copy = schema;
78+
state.ResumeTiming();
79+
auto result = bundle.apply(copy, sourcemeta::core::schema_walker,
80+
sourcemeta::core::schema_resolver,
81+
[](const auto &, const auto &, const auto &,
82+
const auto &, const auto &) {});
83+
assert(!result.first);
84+
benchmark::DoNotOptimize(result);
85+
}
86+
}
87+
88+
static void Alterschema_Check_Invalid_External_Refs(benchmark::State &state) {
89+
const auto schema{sourcemeta::core::read_json(
90+
std::filesystem::path{CURRENT_DIRECTORY} / "files" /
91+
"2020_12_many_invalid_external_refs.json")};
92+
93+
sourcemeta::core::SchemaTransformer bundle;
94+
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);
95+
96+
for (auto _ : state) {
97+
std::size_t trace_count{0};
98+
auto result = bundle.check(
99+
schema, sourcemeta::core::schema_walker,
100+
sourcemeta::core::schema_resolver,
101+
[&trace_count](const auto &, [[maybe_unused]] const auto &name,
102+
const auto &, const auto &, const auto &) {
103+
assert(name == "invalid_external_ref");
104+
trace_count++;
105+
});
106+
assert(!result.first);
107+
assert(trace_count == 1024);
108+
benchmark::DoNotOptimize(result);
109+
}
110+
}
111+
112+
BENCHMARK(Alterschema_Check_Readibility_ISO_Language_Set_3);
113+
BENCHMARK(Alterschema_Check_Readibility_OMC);
114+
BENCHMARK(Alterschema_Check_Readibility_KrakenD);
115+
BENCHMARK(Alterschema_Apply_Readibility_KrakenD);
116+
BENCHMARK(Alterschema_Check_Invalid_External_Refs);
File renamed without changes.

0 commit comments

Comments
 (0)