From 10b39467c800bab4f6c05c7ed31a5d2b4ab8c01f Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Wed, 16 Oct 2024 21:30:11 +0200 Subject: [PATCH] Add expectations to subprocess test (#155) 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 Co-authored-by: Michael Carroll --- test/integration/subprocess_TEST.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/integration/subprocess_TEST.cc b/test/integration/subprocess_TEST.cc index 47c8976..d412f2f 100644 --- a/test/integration/subprocess_TEST.cc +++ b/test/integration/subprocess_TEST.cc @@ -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; } ///////////////////////////////////////////////// @@ -71,7 +71,7 @@ TEST(Subprocess, CreateValid) auto cerr = proc.Stdout(); EXPECT_FALSE(cout.empty()); - EXPECT_TRUE(cerr.empty()); + EXPECT_TRUE(cerr.empty()) << cerr; } ///////////////////////////////////////////////// @@ -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; } ///////////////////////////////////////////////// @@ -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; } /////////////////////////////////////////////////