22 #include <glog/logging.h> 30 const auto basename =
"nested_command_line_app_test_helper";
32 path.remove_filename() /= basename;
33 if (!fs::exists(path)) {
34 path = path.parent_path().parent_path() / basename / basename;
40 std::initializer_list<std::string> args,
41 int expectedExitCode = 0,
45 std::vector<std::string> allArgs;
46 allArgs.reserve(args.size() + 1);
47 allArgs.push_back(helperPath);
48 allArgs.insert(allArgs.end(), args.begin(), args.end());
50 Subprocess::Options options;
52 options.stdoutFd(stdoutFd);
59 auto p = proc.communicate();
60 EXPECT_EQ(expectedExitCode, proc.wait().exitStatus());
67 TEST(ProgramOptionsTest, Errors) {
69 callHelper({
"--wtf",
"foo"}, 1);
70 callHelper({
"qux"}, 1);
71 callHelper({
"--global-foo",
"x",
"foo"}, 1);
74 TEST(ProgramOptionsTest, Help) {
76 callHelper({
"--version"});
77 callHelper({
"--help"});
78 callHelper({
"--help",
"foo"});
79 callHelper({
"--help",
"bar"});
80 callHelper({
"--help",
"--",
"bar"});
82 callHelper({
"help",
"foo"});
83 callHelper({
"help",
"bar"});
86 callHelper({
"--help",
"qux"}, 1);
87 callHelper({
"help",
"qux"}, 1);
90 callHelper({
"--",
"help",
"bar"}, 1);
93 TEST(ProgramOptionsTest, DevFull) {
95 callHelper({
"--help"}, 1, full.
fd());
98 TEST(ProgramOptionsTest, CutArguments) {
102 "foo global-foo 43\n" 105 "foo arg --local-foo\n" 109 {
"foo",
"--global-foo",
"43",
"--",
"b",
"--local-foo",
"44",
"a"}));
112 TEST(ProgramOptionsTest, Success) {
115 "foo global-foo 42\n" 116 "foo local-foo 42\n",
117 callHelper({
"foo"}));
121 "foo global-foo 43\n" 125 callHelper({
"--global-foo",
"43",
"foo",
"--local-foo",
"44",
"a",
"b"}));
130 "foo global-foo 43\n" 134 callHelper({
"foo",
"--global-foo",
"43",
"--local-foo",
"44",
"a",
"b"}));
137 TEST(ProgramOptionsTest, Aliases) {
140 "foo global-foo 43\n" 144 callHelper({
"--global-foo",
"43",
"bar",
"--local-foo",
"44",
"a",
"b"}));
147 TEST(ProgramOptionsTest, BuiltinCommand) {
#define EXPECT_EQ(val1, val2)
—— Concurrent Priority Queue Implementation ——
static constexpr StringPiece const kVersionCommand
bool isBuiltinCommand(const std::string &name) const
TEST(ProgramOptionsTest, Errors)
#define ASSERT_FALSE(condition)
static constexpr StringPiece const kHelpCommand
#define ASSERT_TRUE(condition)