Skip to content

Commit

Permalink
IT WORKS
Browse files Browse the repository at this point in the history
  • Loading branch information
lf- committed Feb 26, 2024
1 parent 93d56c0 commit 6d05cdf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/functional/repl_characterization/repl_characterization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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());
}
Expand All @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit 6d05cdf

Please sign in to comment.