From 6d05cdf65e459f140365f92b49dc70d3036f4a83 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Mon, 26 Feb 2024 01:10:49 -0800 Subject: [PATCH] IT WORKS --- .../repl_characterization/repl_characterization.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/functional/repl_characterization/repl_characterization.cc b/tests/functional/repl_characterization/repl_characterization.cc index 8aae7d9c106..ac3370a4896 100644 --- a/tests/functional/repl_characterization/repl_characterization.cc +++ b/tests/functional/repl_characterization/repl_characterization.cc @@ -17,7 +17,9 @@ using namespace std::string_literals; namespace nix { constexpr const char * REPL_PROMPT = "nix-repl> "; -constexpr const char * REPL_PROMPT_STRIP = "nix-repl>"; + +// ASCII ENQ character +constexpr const char * AUTOMATION_PROMPT = "\x05"; struct RunningProcess { @@ -198,12 +200,14 @@ void TestSession::runCommand(std::string command) if (DEBUG_REPL_PARSER) std::cerr << "runCommand " << command << "\n"; command += "\n"; + // Echo is disabled, so we have to make our own + outLog.append(command); writeFull(proc.procStdin.writeSide.get(), command, false); } static std::string_view trimOutLog(std::string_view outLog) { - const std::string trailer = "\n"s + REPL_PROMPT; + const std::string trailer = "\n"s + AUTOMATION_PROMPT; if (outLog.ends_with(trailer)) { outLog.remove_suffix(trailer.length()); } @@ -225,8 +229,8 @@ class ReplSessionTest : public CharacterizationTest auto syntax = CLILiterateParser::parse(REPL_PROMPT, content); // TODO: why the fuck does this need two --quiets - auto process = RunningProcess::start("nix", {"--quiet", "repl", "--quiet"}); - auto session = TestSession{REPL_PROMPT_STRIP, std::move(process)}; + auto process = RunningProcess::start("nix", {"--quiet", "repl", "--quiet", "--extra-experimental-features", "repl-automation"}); + auto session = TestSession{AUTOMATION_PROMPT, std::move(process)}; const auto expectedOutput = CLILiterateParser::unparse(REPL_PROMPT, syntax, 0); @@ -245,7 +249,7 @@ class ReplSessionTest : public CharacterizationTest } session.close(); - auto parsedOutLog = CLILiterateParser::parse(REPL_PROMPT, trimOutLog(session.outLog), 0); + auto parsedOutLog = CLILiterateParser::parse(AUTOMATION_PROMPT, trimOutLog(session.outLog), 0); CLILiterateParser::tidyOutputForComparison(parsedOutLog); CLILiterateParser::tidyOutputForComparison(syntax);