Skip to content

Commit

Permalink
Fix shared library tests for Windows (#1074)
Browse files Browse the repository at this point in the history
Add copying of shared library to the output directory with a test binary.

[binary] removed using of non unsigned char as argument at
'std::isspace' function that was provokes undefined behavior.

[.github/workflows/build.yml] enabled run of test at the
'windows-latest' environment.
  • Loading branch information
TheVice authored Dec 15, 2021
1 parent 974349d commit d8d9419
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
cmake --build . --parallel 4
# tests are failing for unknown reasons
- if: matrix.os == 'ubuntu-latest'
- if: matrix.os != 'macos-latest'
name: Test shared
shell: bash
run: cd build && ctest --output-on-failure
Expand Down
2 changes: 1 addition & 1 deletion src/binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ std::vector<unsigned char> DecodeBase64(const std::string &input) {

unsigned value = 0;
for (std::size_t i = 0, cnt = 0; i < input.size(); i++) {
if (std::isspace(input[i])) {
if (std::isspace(static_cast<unsigned char>(input[i]))) {
// skip newlines
continue;
}
Expand Down
7 changes: 7 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ endif()


add_test(yaml-cpp::test yaml-cpp-tests)

if (build-windows-dll)
add_custom_command(
TARGET yaml-cpp-tests
POST_BUILD COMMAND ${CMAKE_COMMAND} -E
copy_if_different "$<TARGET_FILE:yaml-cpp>" "$<TARGET_FILE_DIR:yaml-cpp-tests>")
endif()

0 comments on commit d8d9419

Please sign in to comment.