From 117a1389c3683bd1ed78c3556d0d2558adeae52d Mon Sep 17 00:00:00 2001 From: Yannick Daveluy Date: Sun, 7 Jul 2024 11:06:15 +0200 Subject: [PATCH] update pybind11 & GoogleTest dependencies --- .github/workflows/build.yml | 42 +++++++++-------------------- .github/workflows/sonarcloud.yml | 10 +++---- CMakeLists.txt | 4 +-- src/Xsmp/Publication/Field.cpp | 21 +++++++++++---- src/Xsmp/Services/XsmpScheduler.cpp | 2 +- src/python/ecss_smp.cpp | 6 ++--- 6 files changed, 36 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index abf48ee..5e8daa8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,12 +47,8 @@ jobs: run: | cmake --build build --config Release -j 2 - name: Run tests - uses: nick-fields/retry@v3 - with: - max_attempts: 3 - retry_on: error - timeout_minutes: 1 - command: cd build && ctest -C Release --output-on-failure + run: | + cd build && ctest -C Release --output-on-failure gcc: name: '${{matrix.os}} :: GCC ${{matrix.gcc}}' runs-on: ${{matrix.os}} @@ -83,12 +79,8 @@ jobs: run: | cmake --build build --config Release -j 2 - name: Run tests - uses: nick-fields/retry@v3 - with: - max_attempts: 3 - retry_on: error - timeout_minutes: 1 - command: cd build && ctest -C Release --output-on-failure + run: | + cd build && ctest -C Release --output-on-failure clang: name: '${{matrix.os}} :: Clang ${{matrix.clang}}' runs-on: ${{matrix.os}} @@ -125,12 +117,8 @@ jobs: run: | cmake --build build --config Release -j 2 - name: Run tests - uses: nick-fields/retry@v3 - with: - max_attempts: 3 - retry_on: error - timeout_minutes: 1 - command: cd build && ctest -C Release --output-on-failure + run: | + cd build && ctest -C Release --output-on-failure windows: name: '${{matrix.os}}' runs-on: ${{matrix.os}} @@ -157,12 +145,8 @@ jobs: run: | cmake --build build --config Release -j 2 - name: Run tests - uses: nick-fields/retry@v3 - with: - max_attempts: 3 - retry_on: error - timeout_minutes: 1 - command: cd build ; ctest -C Release --output-on-failure -E "XsmpSchedulerTest" + run: | + cd build && ctest -C Release --output-on-failure -E "XsmpSchedulerTest" python: name: '${{matrix.os}} :: Python ${{matrix.python-version}}' runs-on: ${{matrix.os}} @@ -179,18 +163,16 @@ jobs: - '3.10' - '3.11' - '3.12' + - '3.13' steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: ${{matrix.python-version}} + allow-prereleases: true - name: Install Python bindings using pip run: | python -m pip install .[test] -v - name: Run Python tests - uses: nick-fields/retry@v3 - with: - max_attempts: 3 - retry_on: error - timeout_minutes: 1 - command: python -m pytest python -v + run: | + python -m pytest python -v diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 4e3dba4..c85587b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -35,18 +35,14 @@ jobs: uses: SonarSource/sonarcloud-github-c-cpp@v3 - name: Configure cmake run: | - #extract project version + #configure and extract project version echo "PROJECT_VERSION=$(cmake -B build -DCMAKE_BUILD_TYPE=Debug -DXSMP_ENABLE_CODECOVERAGE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S ${{github.workspace}} | grep -oP 'xsmp-sdk v\K[^ ]+')" >> $GITHUB_ENV - name: Build run: | cmake --build build --config Debug -j 2 - name: Run tests - uses: nick-fields/retry@v3 - with: - max_attempts: 3 - retry_on: error - timeout_minutes: 1 - command: cd build && ctest -C ${{env.BUILD_TYPE}} --output-on-failure + run: | + cd build && ctest -C Debug --output-on-failure - name: Collect coverage into one XML report run: | gcovr --sonarqube coverage.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 8804c07..83b3467 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,7 +290,7 @@ if(XSMP_BUILD_PYTHON_BINDINGS) FetchContent_Declare( pybind11 GIT_REPOSITORY https://github.com/pybind/pybind11.git - GIT_TAG v2.12.0 + GIT_TAG v2.13.1 ) FetchContent_MakeAvailable(pybind11) @@ -538,7 +538,7 @@ if(XSMP_BUILD_TESTS) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG e1a38bc3707741d249fa22d2064552a08e37555b + GIT_TAG 34ad51b3dc4f922d8ab622491dd44fc2c39afee9 ) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) diff --git a/src/Xsmp/Publication/Field.cpp b/src/Xsmp/Publication/Field.cpp index a4b3bea..b16106c 100644 --- a/src/Xsmp/Publication/Field.cpp +++ b/src/Xsmp/Publication/Field.cpp @@ -637,13 +637,21 @@ SimpleField::SimpleField(::Smp::String8 name, ::Smp::String8 description, } void SimpleField::Restore(::Smp::IStorageReader *reader) { if (IsState()) { - reader->Restore(GetAddress(), GetSize()); + try { + reader->Restore(GetAddress(), GetSize()); + } catch (const Smp::Exception &e) { + ::Xsmp::Exception::throwCannotRestore(this, e.GetMessage()); + } } } void SimpleField::Store(::Smp::IStorageWriter *writer) { if (IsState()) { - writer->Store(GetAddress(), GetSize()); + try { + writer->Store(GetAddress(), GetSize()); + } catch (const Smp::Exception &e) { + ::Xsmp::Exception::throwCannotStore(this, e.GetMessage()); + } } } @@ -677,9 +685,12 @@ ::Smp::UInt64 SimpleField::GetSize() const { case ::Smp::PrimitiveTypeKind::PTK_Float64: return sizeof(::Smp::Float64); case ::Smp::PrimitiveTypeKind::PTK_String8: - return dynamic_cast(GetType()) - ->GetLength() + - 1; + if (const auto *stringType = + dynamic_cast(GetType())) { + return stringType->GetLength() + 1; + } else { + ::Xsmp::Exception::throwInvalidFieldType(this, GetType()); + } default: ::Xsmp::Exception::throwInvalidPrimitiveType(this, "void", kind); } diff --git a/src/Xsmp/Services/XsmpScheduler.cpp b/src/Xsmp/Services/XsmpScheduler.cpp index 8889ee9..0bf6670 100644 --- a/src/Xsmp/Services/XsmpScheduler.cpp +++ b/src/Xsmp/Services/XsmpScheduler.cpp @@ -73,7 +73,7 @@ XsmpScheduler::XsmpScheduler(::Smp::String8 name, ::Smp::String8 description, : XsmpSchedulerGen::XsmpSchedulerGen(name, description, parent, simulator) { // post an event to Hold the simulation at the maximal duration - constexpr ::Smp::Services::EventId holdId = -2; + static constexpr ::Smp::Services::EventId holdId = -2; _events.try_emplace(holdId, Event{&HoldEvent, MaxDuration, MaxDuration, 0, 0, ::Smp::Services::TimeKind::TK_SimulationTime}); diff --git a/src/python/ecss_smp.cpp b/src/python/ecss_smp.cpp index 819ec1e..181067c 100644 --- a/src/python/ecss_smp.cpp +++ b/src/python/ecss_smp.cpp @@ -433,6 +433,8 @@ py::object convert(const ::Smp::AnySimple &value) { case ::Smp::PrimitiveTypeKind::PTK_Int32: return py::cast(value.operator ::Smp::Int32()); case ::Smp::PrimitiveTypeKind::PTK_Int64: + case ::Smp::PrimitiveTypeKind::PTK_DateTime: + case ::Smp::PrimitiveTypeKind::PTK_Duration: return py::cast(value.operator ::Smp::Int64()); case ::Smp::PrimitiveTypeKind::PTK_UInt8: return py::cast(value.operator ::Smp::UInt8()); @@ -442,10 +444,6 @@ py::object convert(const ::Smp::AnySimple &value) { return py::cast(value.operator ::Smp::UInt32()); case ::Smp::PrimitiveTypeKind::PTK_UInt64: return py::cast(value.operator ::Smp::UInt64()); - case ::Smp::PrimitiveTypeKind::PTK_DateTime: - return py::cast(value.operator ::Smp::DateTime()); - case ::Smp::PrimitiveTypeKind::PTK_Duration: - return py::cast(value.operator ::Smp::Duration()); case ::Smp::PrimitiveTypeKind::PTK_Float32: return py::cast(value.operator ::Smp::Float32()); case ::Smp::PrimitiveTypeKind::PTK_Float64: