Merge pull request #4461 from hummeltech/MapnikTestsTempDir

Use `temp_directory_path` rather than hard-coded `/tmp` for `image io` tests
This commit is contained in:
Artem Pavlenko 2024-06-14 12:45:19 +01:00 committed by GitHub
commit ffcf059556
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,11 +23,6 @@ MAPNIK_DISABLE_WARNING_POP
#include <mapnik/filesystem.hpp> #include <mapnik/filesystem.hpp>
#include <mapnik/util/mapped_memory_file.hpp> #include <mapnik/util/mapped_memory_file.hpp>
inline void make_directory(std::string const& dir)
{
mapnik::fs::create_directories(dir);
}
namespace { namespace {
template<typename T> template<typename T>
void check_tiny_png_image_quantising(T const& im) void check_tiny_png_image_quantising(T const& im)
@ -182,8 +177,9 @@ TEST_CASE("image io")
supported_types.push_back(std::make_tuple("webp", "webp")); supported_types.push_back(std::make_tuple("webp", "webp"));
#endif #endif
std::string directory_name("/tmp/mapnik-tests/"); std::string directory_name = mapnik::fs::path(mapnik::fs::temp_directory_path() / "mapnik-tests").string();
make_directory(directory_name);
mapnik::fs::create_directories(directory_name);
REQUIRE(mapnik::util::exists(directory_name)); REQUIRE(mapnik::util::exists(directory_name));
for (auto const& info : supported_types) for (auto const& info : supported_types)
@ -191,7 +187,7 @@ TEST_CASE("image io")
std::string extension; std::string extension;
std::string format; std::string format;
std::tie(extension, format) = info; std::tie(extension, format) = info;
std::string filename = (boost::format(directory_name + "mapnik-%1%.%2%") % named_color % extension).str(); std::string filename = (boost::format(directory_name + "/mapnik-%1%.%2%") % named_color % extension).str();
mapnik::save_to_file(im, filename); mapnik::save_to_file(im, filename);
std::string str = mapnik::save_to_string(im, format); std::string str = mapnik::save_to_string(im, format);
std::ostringstream ss; std::ostringstream ss;