From 16a113c6b23af735df7cd8154cc0a43f1a8bd2c3 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Wed, 12 Jun 2024 12:44:06 +0200 Subject: [PATCH] Fix schema evolution when switching component members (#627) * Add a schema evolution that triggers failure * Fix schema evolution script * Add tests for running the schema evolution script standalone --- python/podio_schema_evolution.py | 2 +- tests/schema_evolution/CMakeLists.txt | 16 ++++++++++++++++ tests/schema_evolution/datalayout_new.yaml | 7 ++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/python/podio_schema_evolution.py b/python/podio_schema_evolution.py index b3b498fa2..ea417ab3b 100755 --- a/python/podio_schema_evolution.py +++ b/python/podio_schema_evolution.py @@ -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): diff --git a/tests/schema_evolution/CMakeLists.txt b/tests/schema_evolution/CMakeLists.txt index a86963d82..c6eabb388 100644 --- a/tests/schema_evolution/CMakeLists.txt +++ b/tests/schema_evolution/CMakeLists.txt @@ -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) diff --git a/tests/schema_evolution/datalayout_new.yaml b/tests/schema_evolution/datalayout_new.yaml index e9938fd1c..8c08df933 100644 --- a/tests/schema_evolution/datalayout_new.yaml +++ b/tests/schema_evolution/datalayout_new.yaml @@ -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 @@ -191,7 +196,7 @@ datatypes : Members: - std::int16_t i16Val{42} // some int16 value - std::array 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