Skip to content

Commit

Permalink
test: remove folly dependency from test_helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mhx committed Aug 10, 2024
1 parent f9d8168 commit a9a2e1b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions test/test_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@

#include <fmt/format.h>

#include <folly/FileUtil.h>
#include <folly/String.h>
#include <folly/portability/Unistd.h>

#include <dwarfs/file_util.h>
#include <dwarfs/match.h>
#include <dwarfs/os_access_generic.h>
#include <dwarfs/string.h>
#include <dwarfs/util.h>

#include "loremipsum.h"
Expand Down Expand Up @@ -327,9 +325,11 @@ void os_access_mock::add_local_files(fs::path const& base_path) {
st.gid = 100;
st.size = p.file_size();
add(relpath, st, [path = p.path().string()] {
std::string rv;
if (!folly::readFile(path.c_str(), rv)) {
throw std::runtime_error(fmt::format("failed to read file {}", path));
std::error_code ec;
auto rv = read_file(path, ec);
if (ec) {
throw std::runtime_error(
fmt::format("failed to read file {}: {}", path, ec.message()));
}
return rv;
});
Expand Down Expand Up @@ -562,9 +562,7 @@ std::optional<fs::path> find_binary(std::string_view name) {
}

std::vector<std::string> parse_args(std::string_view args) {
std::vector<std::string> rv;
folly::split(' ', args, rv);
return rv;
return split_to<std::vector<std::string>>(args, ' ');
}

std::string create_random_string(size_t size, uint8_t min, uint8_t max,
Expand Down

0 comments on commit a9a2e1b

Please sign in to comment.