mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 13:04:15 -04:00
test: some tools_test cleanups
This commit is contained in:
parent
ff0aa79254
commit
c14e884188
@ -23,6 +23,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <concepts>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <future>
|
#include <future>
|
||||||
@ -103,7 +104,7 @@ class scoped_no_leak_check {
|
|||||||
} else {
|
} else {
|
||||||
new_asan_options.assign(kNoLeakCheck);
|
new_asan_options.assign(kNoLeakCheck);
|
||||||
}
|
}
|
||||||
::setenv("ASAN_OPTIONS", new_asan_options.c_str(), 1);
|
::setenv(kEnvVar, new_asan_options.c_str(), 1);
|
||||||
unset_asan_ = true;
|
unset_asan_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,9 +367,14 @@ void ignore_sigpipe() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept subprocess_arg = std::convertible_to<T, std::string> ||
|
||||||
|
std::convertible_to<T, std::vector<std::string>> ||
|
||||||
|
std::convertible_to<T, fs::path>;
|
||||||
|
|
||||||
class subprocess {
|
class subprocess {
|
||||||
public:
|
public:
|
||||||
template <typename... Args>
|
template <subprocess_arg... Args>
|
||||||
subprocess(std::filesystem::path const& prog, Args&&... args)
|
subprocess(std::filesystem::path const& prog, Args&&... args)
|
||||||
: prog_{prog} {
|
: prog_{prog} {
|
||||||
(append_arg(cmdline_, std::forward<Args>(args)), ...);
|
(append_arg(cmdline_, std::forward<Args>(args)), ...);
|
||||||
@ -477,7 +483,7 @@ class subprocess {
|
|||||||
args.insert(args.end(), more.begin(), more.end());
|
args.insert(args.end(), more.begin(), more.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <std::convertible_to<std::string> T>
|
||||||
static void append_arg(std::vector<std::string>& args, T const& arg) {
|
static void append_arg(std::vector<std::string>& args, T const& arg) {
|
||||||
args.emplace_back(arg);
|
args.emplace_back(arg);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user