Skip to content

Commit

Permalink
Add expectations to subprocess test (#155)
Browse files Browse the repository at this point in the history
This adds expectations to the subprocess test instead
of just checking that cout/cerr are not empty. It also
adds streaming of variable values if expectations fail.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Co-authored-by: Michael Carroll <mjcarroll@intrinsic.ai>
  • Loading branch information
scpeters and mjcarroll authored Oct 16, 2024
1 parent 961f5d4 commit 10b3946
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/integration/subprocess_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ TEST(Subprocess, CreateInvalidSpaces)
auto cout = proc.Stdout();
auto cerr = proc.Stdout();

EXPECT_TRUE(cout.empty());
EXPECT_TRUE(cerr.empty());
EXPECT_TRUE(cout.empty()) << cout;
EXPECT_TRUE(cerr.empty()) << cerr;
}

/////////////////////////////////////////////////
Expand All @@ -71,7 +71,7 @@ TEST(Subprocess, CreateValid)
auto cerr = proc.Stdout();

EXPECT_FALSE(cout.empty());
EXPECT_TRUE(cerr.empty());
EXPECT_TRUE(cerr.empty()) << cerr;
}

/////////////////////////////////////////////////
Expand All @@ -91,7 +91,8 @@ TEST(Subprocess, Cout)
auto cout = proc.Stdout();
auto cerr = proc.Stderr();
EXPECT_FALSE(cout.empty());
EXPECT_TRUE(cerr.empty());
EXPECT_NE(std::string::npos, cout.find("Iteration: ")) << cout;
EXPECT_TRUE(cerr.empty()) << cerr;
}

/////////////////////////////////////////////////
Expand All @@ -110,8 +111,9 @@ TEST(Subprocess, Cerr)
EXPECT_FALSE(proc.Alive());
auto cout = proc.Stdout();
auto cerr = proc.Stderr();
EXPECT_TRUE(cout.empty());
EXPECT_TRUE(cout.empty()) << cout;
EXPECT_FALSE(cerr.empty());
EXPECT_NE(std::string::npos, cerr.find("Iteration: ")) << cerr;
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit 10b3946

Please sign in to comment.