test: finish the temp-file cleanup (#14976)

Follow-up to #14785. Routes the tests that still hand-rolled temp paths through
the shared helpers and unifies the temp guards.

- Add ScopedTemporaryDir and a shared ScopedTemporaryPath base under it and
  ScopedTemporaryFile.
- Move test_3mf's round-trip .3mf output out of the TEST_DATA_DIR source tree
  (a fixed-name leak) and test_toolordering's fixed-name temp .gcode (a sharding
  collision) onto ScopedTemporaryFile.
- Move test_config, test_slicing_pipeline_bindings, the test_3mf backup dirs, and
  test_preset_bundle_loading onto the guards.
- Make slic3rutils ScopedDataDir compose ScopedTemporaryDir; dedupe
  test_network_versions' fixture and delete test_plugin_lifecycle's duplicate.
This commit is contained in:
Kris Austin
2026-08-07 11:33:37 -05:00
committed by GitHub
parent 8bff9aaf32
commit 74aed7a2bb
9 changed files with 106 additions and 153 deletions

View File

@@ -6,6 +6,8 @@
#include "libslic3r/Utils.hpp"
#include "slic3r/Utils/bambu_networking.hpp"
#include "plugin_test_utils.hpp"
using namespace Slic3r;
namespace fs = boost::filesystem;
@@ -25,27 +27,16 @@ static const char* PLUGIN_EXT = ".so";
struct PluginFolderFixture
{
fs::path root;
std::string previous_data_dir;
ScopedDataDir data{"netver"};
PluginFolderFixture()
{
previous_data_dir = data_dir();
root = fs::temp_directory_path() / fs::unique_path("orca-netver-%%%%%%%%");
fs::create_directories(root / "plugins");
set_data_dir(root.string());
}
~PluginFolderFixture()
{
set_data_dir(previous_data_dir);
boost::system::error_code ec;
fs::remove_all(root, ec);
fs::create_directories(data.dir / "plugins");
}
void add_plugin(const std::string& version)
{
boost::nowide::ofstream f((root / "plugins" / (PLUGIN_PREFIX + version + PLUGIN_EXT)).string());
boost::nowide::ofstream f((data.dir / "plugins" / (PLUGIN_PREFIX + version + PLUGIN_EXT)).string());
f << "stub";
}
};