This commit is contained in:
peachismomo
2026-07-12 17:01:45 +08:00
parent ce21a09cb1
commit 25d7abf81b
5 changed files with 620 additions and 24 deletions

View File

@@ -5,6 +5,8 @@
#include <slic3r/plugin/PluginDescriptor.hpp>
#include <slic3r/plugin/PythonFileUtils.hpp>
#include "plugin_test_utils.hpp"
#include <boost/filesystem.hpp>
#include <fstream>
@@ -15,30 +17,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 install_plugin() writes into a
// disposable 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 write_py_file(const fs::path& dir, const std::string& filename, const std::string& contents)
{
fs::create_directories(dir);