Skip to content

Commit

Permalink
Fix schema evolution when switching component members (#627)
Browse files Browse the repository at this point in the history
* Add a schema evolution that triggers failure

* Fix schema evolution script

* Add tests for running the schema evolution script standalone
  • Loading branch information
tmadlener authored Jun 12, 2024
1 parent a716c01 commit 16a113c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/podio_schema_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AddedComponent(SchemaChange):
def __init__(self, component, name):
self.component = component
self.name = name
super().__init__(f"'{self.component.name}' has been added")
super().__init__(f"'{self.name}' has been added")


class DroppedComponent(SchemaChange):
Expand Down
16 changes: 16 additions & 0 deletions tests/schema_evolution/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,20 @@ function(PODIO_CREATE_READ_NEW_DATA_TEST sourcefile additional_libs)
)
endfunction()

add_test(
NAME schema-evolution-script
COMMAND ${PROJECT_SOURCE_DIR}/python/podio_schema_evolution.py
${CMAKE_CURRENT_SOURCE_DIR}/datalayout_new.yaml
${PROJECT_SOURCE_DIR}/tests/datalayout.yaml
)

add_test(
NAME schema-evolution-script-with-evol
COMMAND
${PROJECT_SOURCE_DIR}/python/podio_schema_evolution.py
--evo ${CMAKE_CURRENT_SOURCE_DIR}/schema_evolution.yaml
${CMAKE_CURRENT_SOURCE_DIR}/datalayout_new.yaml
${PROJECT_SOURCE_DIR}/tests/datalayout.yaml
)

add_subdirectory(root_io)
7 changes: 6 additions & 1 deletion tests/schema_evolution/datalayout_new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ components :
- int x
- int y_new

ex2::NamespaceStructLong:
Members:
- int64_t x
- int64_t y_new

ex2::NamespaceInNamespaceStruct:
Members:
- ex2::NamespaceStruct data
Expand Down Expand Up @@ -191,7 +196,7 @@ datatypes :
Members:
- std::int16_t i16Val{42} // some int16 value
- std::array<float, 2> floats {3.14f, 1.23f} // some float values
- ex2::NamespaceStruct s{10, 11} // one that we happen to know works
- ex2::NamespaceStructLong s{10, 11} // one that we happen to know works
- double d{9.876e5} // double val
- CompWithInit comp // To make sure that the default initializer of the component does what it should

Expand Down

0 comments on commit 16a113c

Please sign in to comment.