Skip to content

Commit 5041c09

Browse files
committed
Merge branch 'lm_catch_and_prepared'
2 parents d33a277 + 6dda300 commit 5041c09

File tree

8 files changed

+44
-29
lines changed

8 files changed

+44
-29
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ jobs:
9191
shell: bash
9292
run: python -m build --wheel
9393

94-
- uses: actions/upload-artifact@v3 # upload test results
94+
- uses: actions/upload-artifact@v4 # upload test results
9595
if: success() || failure() # run this step even if previous step failed
9696
with:
97-
name: test-results
97+
name: test-results-linux
9898
path: ${{github.workspace}}/build/**/result-junit-linux.xml
9999

100-
- uses: actions/upload-artifact@v3 # upload python module
100+
- uses: actions/upload-artifact@v4 # upload python module
101101
name: Saving Python artifacts
102102
if: success()
103103
with:
@@ -180,13 +180,13 @@ jobs:
180180
emcmake cmake .. -DBGCODE_AS_SUBPROJECT=ON -DLibBGCode_BUILD_TESTS=OFF -DCMAKE_FIND_ROOT_PATH=$(pwd)/../../deps/build-wasm/destdir/usr/local
181181
cmake --build .
182182
183-
- uses: actions/upload-artifact@v3 # upload test results
183+
- uses: actions/upload-artifact@v4 # upload test results
184184
if: success() || failure() # run this step even if previous step failed
185185
with:
186-
name: test-results
186+
name: test-results-wasm
187187
path: ${{github.workspace}}/build/**/result-junit-wasm.xml
188188

189-
- uses: actions/upload-artifact@v3 # upload wasm module
189+
- uses: actions/upload-artifact@v4 # upload wasm module
190190
name: Saving WebAssembly artifacts
191191
if: success()
192192
with:
@@ -278,13 +278,13 @@ jobs:
278278
working-directory: ${{github.workspace}}
279279
run: python -m build --wheel
280280

281-
- uses: actions/upload-artifact@v3 # upload test results
281+
- uses: actions/upload-artifact@v4 # upload test results
282282
if: success() || failure() # run this step even if previous step failed
283283
with:
284284
name: test-results-msvc
285285
path: ${{github.workspace}}\build\**\result-junit-msvc.xml
286286

287-
- uses: actions/upload-artifact@v3 # upload python module
287+
- uses: actions/upload-artifact@v4 # upload python module
288288
name: Saving Python artifacts
289289
if: success()
290290
with:
@@ -381,13 +381,13 @@ jobs:
381381
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DBGCODE_AS_SUBPROJECT=ON -DLibBGCode_BUILD_TESTS=OFF -DCMAKE_PREFIX_PATH=${{github.workspace}}/deps/build-python-module/destdir/usr/local
382382
cmake --build .
383383
384-
- uses: actions/upload-artifact@v3 # upload test results
384+
- uses: actions/upload-artifact@v4 # upload test results
385385
if: success() || failure() # run this step even if previous step failed
386386
with:
387-
name: test-results
387+
name: test-results-mac
388388
path: ${{github.workspace}}/build/**/result-junit-mac.xml
389389

390-
- uses: actions/upload-artifact@v3 # upload python module
390+
- uses: actions/upload-artifact@v4 # upload python module
391391
name: Saving Python artifacts
392392
if: success()
393393
with:

deps/Catch2/Catch2.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_cmake_project(Catch2
2-
URL "https://github.com/catchorg/Catch2/archive/refs/tags/v2.13.10.zip"
3-
URL_HASH SHA256=121e7488912c2ce887bfe4699ebfb983d0f2e0d68bcd60434cdfd6bb0cf78b43
2+
URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.0.zip"
3+
URL_HASH SHA256=bffd2c45a84e5a4b0c17e695798e8d2f65931cbaf5c7556d40388d1d8d04eb83
44
CMAKE_ARGS
55
-DCATCH_BUILD_TESTING:BOOL=OFF
6+
-DCMAKE_CXX_STANDARD=17
67
)

src/LibBGCode/convert/convert.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ BGCODE_CONVERT_EXPORT EResult from_ascii_to_binary(FILE& src_file, FILE& dst_fil
183183
{
184184
using namespace std::literals;
185185
static constexpr const std::string_view GeneratedByPrusaSlicer = "generated by PrusaSlicer"sv;
186+
static constexpr const std::string_view PreparedBy = "prepared by"sv;
186187

187188
static constexpr const std::string_view PrinterModel = "printer_model"sv;
188189
static constexpr const std::string_view FilamentType = "filament_type"sv;
@@ -318,6 +319,15 @@ BGCODE_CONVERT_EXPORT EResult from_ascii_to_binary(FILE& src_file, FILE& dst_fil
318319
return;
319320
}
320321

322+
pos = sv_line.find(PreparedBy);
323+
if (lines_counter < 5 && pos != std::string_view::npos) {
324+
std::string_view prep = trim(sv_line.substr(pos + PreparedBy.size()));
325+
if (! prep.empty())
326+
binary_data.file_metadata.raw_data.emplace_back("Prepared by", prep);
327+
processed_lines.emplace_back(lines_counter++);
328+
return;
329+
}
330+
321331
// collect print + printer metadata
322332
// to keep the proper order they will be set into binary_data later
323333
auto collect_metadata = [&](const std::string_view& key, std::string& value, bool shared_in_config = false) {
@@ -646,16 +656,20 @@ BGCODE_CONVERT_EXPORT EResult from_binary_to_ascii(FILE& src_file, FILE& dst_fil
646656

647657
auto producer_it = std::find_if(file_metadata_block.raw_data.begin(), file_metadata_block.raw_data.end(),
648658
[](const std::pair<std::string, std::string>& item) { return item.first == "Producer"; });
649-
std::string producer_str = (producer_it != file_metadata_block.raw_data.end()) ? producer_it->second : "Unknown";
650-
651-
659+
auto prepared_it = std::find_if(file_metadata_block.raw_data.begin(), file_metadata_block.raw_data.end(),
660+
[](const std::pair<std::string, std::string>& item) { return item.first == "Prepared by"; });
652661
auto produced_on_it = std::find_if(file_metadata_block.raw_data.begin(), file_metadata_block.raw_data.end(),
653662
[](const auto& item) { return item.first == "Produced on"; });
663+
664+
std::string producer_str = (producer_it != file_metadata_block.raw_data.end()) ? producer_it->second : "Unknown";
654665
if (produced_on_it != file_metadata_block.raw_data.end())
655666
producer_str += " on " + produced_on_it->second;
667+
if (prepared_it != file_metadata_block.raw_data.end())
668+
producer_str += "\n; prepared by " + prepared_it->second;
656669

657670
if (!write_line("; generated by " + producer_str + "\n\n\n"))
658671
return EResult::WriteError;
672+
659673
res = read_next_block_header(src_file, file_header, block_header, checksum_buffer.data(), checksum_buffer.size());
660674
if (res != EResult::Success)
661675
// propagate error

tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
find_package(Catch2 2.9 REQUIRED)
1+
find_package(Catch2 3.8 REQUIRED)
22

33
include(Catch)
44

@@ -16,7 +16,7 @@ file(TO_NATIVE_PATH "${TEST_DATA_DIR}" TEST_DATA_DIR)
1616
add_library(test_common INTERFACE)
1717
target_include_directories(test_common INTERFACE ${CMAKE_CURRENT_LIST_DIR})
1818
target_compile_definitions(test_common INTERFACE TEST_DATA_DIR=R"\(${TEST_DATA_DIR}\)" CATCH_CONFIG_FAST_COMPILE)
19-
target_link_libraries(test_common INTERFACE Catch2::Catch2 Boost::nowide)
19+
target_link_libraries(test_common INTERFACE Catch2::Catch2WithMain Boost::nowide)
2020

2121
if (EMSCRIPTEN)
2222
target_link_libraries(test_common INTERFACE nodefs.js noderawfs.js)

tests/binarize/binarize_tests.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
#include <catch_main.hpp>
1+
#include <catch2/catch_test_macros.hpp>
22

33
#include "binarize/binarize.hpp"
44

5+
TEST_CASE("Dummy", "[Binarize]")
6+
{
7+
REQUIRE(true);
8+
}
9+

tests/catch_main.hpp

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/convert/convert_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#include <catch_main.hpp>
1+
#include <catch2/catch_test_macros.hpp>
22

33
#include "convert/convert.hpp"
44

55
#include <fstream>
6+
#include <iostream>
67

78
#include <boost/nowide/cstdio.hpp>
89

tests/core/core_tests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
#include <catch_main.hpp>
1+
#include <catch2/catch_test_macros.hpp>
22

33
#include "core/core.hpp"
44

55
#include <boost/nowide/cstdio.hpp>
66

7+
#include <iostream>
8+
79
using namespace bgcode::core;
810

911
class ScopedFile

0 commit comments

Comments
 (0)