35 explicit Command(std::string program);
41 Command&
Args(
const std::vector<std::string>& args);
47 Command&
Env(
const std::string& key,
const std::string& val);
51 void RunCommand(
const std::string& desc)
const;
55 std::vector<std::string> args_;
56 std::filesystem::path cwd_;
57 std::map<std::string, std::string> env_vars_;
60 std::string FormatArgs()
const;
A shell command builder and executor for tests.
Definition cmd_util.h:33
Command & Args(const std::vector< std::string > &args)
Add multiple arguments at once.
Definition cmd_util.cc:42
Command & Arg(std::string arg)
Add a single argument.
Definition cmd_util.cc:37
Command & Env(const std::string &key, const std::string &val)
Set an environment variable for the command.
Definition cmd_util.cc:52
void RunCommand(const std::string &desc) const
Execute the command and print logs.
Definition cmd_util.cc:57
Command & CurrentDir(const std::filesystem::path &path)
Set the current working directory for the command.
Definition cmd_util.cc:47