summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGereon Kremer <nafur42@gmail.com>2021-07-28 14:41:22 -0700
committerGitHub <noreply@github.com>2021-07-28 21:41:22 +0000
commit25e124deb3c69256b35641cd1055b5328b309bf6 (patch)
treef07ca2e0a23768ad44425495a39fe2a48b07680b /test
parent6bc9f09c09defa673bf0562684f9112fa94a9cfc (diff)
Only use libedit on tty inputs (#6946)
This PR improves the check when we use libedit: only when the input is an interactive terminal. This is motivated by a change to the unit test for the interactive mode that now properly redirects standard input (and output).
Diffstat (limited to 'test')
-rw-r--r--test/unit/main/interactive_shell_black.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/unit/main/interactive_shell_black.cpp b/test/unit/main/interactive_shell_black.cpp
index 9a1a46da4..9c842adac 100644
--- a/test/unit/main/interactive_shell_black.cpp
+++ b/test/unit/main/interactive_shell_black.cpp
@@ -35,10 +35,15 @@ class TestMainBlackInteractiveShell : public TestInternal
void SetUp() override
{
TestInternal::SetUp();
- d_sin.reset(new std::stringstream);
- d_sout.reset(new std::stringstream);
- d_options.base.in = d_sin.get();
- d_options.base.out = d_sout.get();
+
+ d_sin = std::make_unique<std::stringstream>();
+ d_stdin = std::cin.rdbuf();
+ std::cin.rdbuf(d_sin->rdbuf());
+
+ d_sout = std::make_unique<std::stringstream>();
+ d_stdout = std::cout.rdbuf();
+ std::cout.rdbuf(d_sout->rdbuf());
+
d_options.base.inputLanguage = language::input::LANG_CVC;
d_solver.reset(new cvc5::api::Solver(&d_options));
d_symman.reset(new SymbolManager(d_solver.get()));
@@ -46,7 +51,9 @@ class TestMainBlackInteractiveShell : public TestInternal
void TearDown() override
{
+ std::cin.rdbuf(d_stdin);
d_sin.reset(nullptr);
+ std::cout.rdbuf(d_stdout);
d_sout.reset(nullptr);
// ensure that symbol manager is destroyed before solver
d_symman.reset(nullptr);
@@ -81,6 +88,9 @@ class TestMainBlackInteractiveShell : public TestInternal
std::unique_ptr<SymbolManager> d_symman;
std::unique_ptr<cvc5::api::Solver> d_solver;
Options d_options;
+
+ std::streambuf* d_stdin;
+ std::streambuf* d_stdout;
};
TEST_F(TestMainBlackInteractiveShell, assert_true)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback