mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-08 18:48:04 +00:00
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:
@@ -6,6 +6,8 @@
|
||||
#include <slic3r/plugin/PluginFsUtils.hpp>
|
||||
#include <slic3r/plugin/PythonInterpreter.hpp>
|
||||
|
||||
#include "plugin_test_utils.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -25,32 +27,6 @@ namespace fs = boost::filesystem;
|
||||
|
||||
namespace {
|
||||
|
||||
// Point data_dir() at a throwaway directory for the lifetime of a test and restore the previous
|
||||
// value afterwards, so discovery scans a disposable {data_dir}/orca_plugins tree and tests don't
|
||||
// leak state into each other.
|
||||
struct ScopedDataDir
|
||||
{
|
||||
std::string previous;
|
||||
fs::path dir;
|
||||
|
||||
explicit ScopedDataDir(const std::string& tag)
|
||||
{
|
||||
previous = data_dir();
|
||||
dir = fs::temp_directory_path() / fs::unique_path("orca-" + tag + "-%%%%-%%%%");
|
||||
fs::create_directories(dir);
|
||||
set_data_dir(dir.string());
|
||||
}
|
||||
|
||||
~ScopedDataDir()
|
||||
{
|
||||
set_data_dir(previous);
|
||||
boost::system::error_code ec;
|
||||
fs::remove_all(dir, ec);
|
||||
}
|
||||
|
||||
fs::path plugins_dir() const { return dir / "orca_plugins"; }
|
||||
};
|
||||
|
||||
// Brings the plugin system up, and tears it down explicitly at the end of the test.
|
||||
//
|
||||
// Shutting the interpreter down here, rather than leaving it to PythonInterpreter's static
|
||||
|
||||
Reference in New Issue
Block a user