Skip to content

Commit

Permalink
update pybind11 & GoogleTest dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ydaveluy committed Jul 7, 2024
1 parent 54de1ae commit 117a138
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 49 deletions.
42 changes: 12 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}
Expand All @@ -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}}
Expand All @@ -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
10 changes: 3 additions & 7 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
21 changes: 16 additions & 5 deletions src/Xsmp/Publication/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

Expand Down Expand Up @@ -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<const ::Xsmp::Publication::StringType *>(GetType())
->GetLength() +
1;
if (const auto *stringType =
dynamic_cast<const ::Xsmp::Publication::StringType *>(GetType())) {
return stringType->GetLength() + 1;
} else {
::Xsmp::Exception::throwInvalidFieldType(this, GetType());
}
default:
::Xsmp::Exception::throwInvalidPrimitiveType(this, "void", kind);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Xsmp/Services/XsmpScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
6 changes: 2 additions & 4 deletions src/python/ecss_smp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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:
Expand Down

0 comments on commit 117a138

Please sign in to comment.