forked from weaselab/weaseljson
ci: register schemagen regression tests with ctest
Remove the standalone "Run schemagen tests" workflow step and instead add the big-schema regression test to contrib/schemagen/CMakeLists.txt so ctest picks it up alongside schemagen_example. Update README to document both `ctest` and the convenience `./run_tests.sh`. Closes #3
This commit is contained in:
@@ -12,6 +12,8 @@ add_test(
|
||||
set(SCHEMAGEN_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/weaseljson_schemagen.py)
|
||||
set(EXAMPLE_SCHEMA ${CMAKE_CURRENT_SOURCE_DIR}/example.schema.json)
|
||||
set(GEN_H ${CMAKE_CURRENT_BINARY_DIR}/gen.h)
|
||||
set(BIG_SCHEMA ${CMAKE_CURRENT_SOURCE_DIR}/big.schema.json)
|
||||
set(BIG_H ${CMAKE_CURRENT_BINARY_DIR}/big.h)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_H}
|
||||
@@ -20,7 +22,15 @@ add_custom_command(
|
||||
DEPENDS ${SCHEMAGEN_SCRIPT} ${EXAMPLE_SCHEMA}
|
||||
COMMENT "Generating gen.h from example.schema.json")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${BIG_H}
|
||||
COMMAND ${Python3_EXECUTABLE} ${SCHEMAGEN_SCRIPT} ${BIG_SCHEMA} -o ${BIG_H}
|
||||
--namespace big_schema
|
||||
DEPENDS ${SCHEMAGEN_SCRIPT} ${BIG_SCHEMA}
|
||||
COMMENT "Generating big.h from big.schema.json")
|
||||
|
||||
add_custom_target(schemagen_gen_h DEPENDS ${GEN_H})
|
||||
add_custom_target(schemagen_big_h DEPENDS ${BIG_H})
|
||||
|
||||
add_executable(schemagen_example ${CMAKE_CURRENT_SOURCE_DIR}/test_gen.cpp)
|
||||
target_include_directories(schemagen_example
|
||||
@@ -29,7 +39,19 @@ target_link_libraries(schemagen_example PRIVATE ${PROJECT_NAME})
|
||||
target_compile_options(schemagen_example PRIVATE -Wno-switch-enum)
|
||||
add_dependencies(schemagen_example schemagen_gen_h)
|
||||
|
||||
add_executable(schemagen_big ${CMAKE_CURRENT_SOURCE_DIR}/test_big.cpp)
|
||||
target_include_directories(schemagen_big PRIVATE include
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(schemagen_big PRIVATE ${PROJECT_NAME})
|
||||
target_compile_options(schemagen_big PRIVATE -Wno-switch-enum)
|
||||
add_dependencies(schemagen_big schemagen_big_h)
|
||||
|
||||
add_test(
|
||||
NAME schemagen_example
|
||||
COMMAND schemagen_example
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_test(
|
||||
NAME schemagen_big
|
||||
COMMAND schemagen_big
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@@ -76,15 +76,25 @@ union `type` lists other than `["T", "null"]`, non-string enums, and remote
|
||||
|
||||
## Testing
|
||||
|
||||
After building weaseljson (e.g. `cmake -S . -B build && make -C build`), run:
|
||||
The schemagen tests are registered with CTest and run as part of the default
|
||||
`ctest` invocation from the build directory:
|
||||
|
||||
```sh
|
||||
cmake -S . -B build
|
||||
make -C build -j "$(nproc)"
|
||||
cd build
|
||||
ctest --output-on-failure
|
||||
```
|
||||
|
||||
For local development you can also use the convenience script:
|
||||
|
||||
```sh
|
||||
cd contrib/schemagen
|
||||
./run_tests.sh
|
||||
```
|
||||
|
||||
This regenerates the example parser (`gen.h`) and a regression parser with 40
|
||||
required properties (`big.h`), compiles `test_gen.cpp` and `test_big.cpp`, and
|
||||
runs both. `test_big.cpp` specifically covers issue #3: it checks that a
|
||||
40-property object accepts all fields, rejects a missing field at index 32, and
|
||||
rejects duplicate keys around the 32-bit boundary.
|
||||
Both regenerate the example parser (`gen.h`) and a regression parser with 40
|
||||
required properties (`big.h`), compile `test_gen.cpp` and `test_big.cpp`, and run
|
||||
them. `test_big.cpp` specifically covers issue #3: it checks that a 40-property
|
||||
object accepts all fields, rejects a missing field at index 32, and rejects
|
||||
duplicate keys around the 32-bit boundary.
|
||||
|
||||
Reference in New Issue
Block a user