From 84018e126405caed68097b52392bee648bf1b17e Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 28 Mar 2024 16:26:42 -0700 Subject: [PATCH] Make `repl_characterization.cc` constants `string_view`s Change-Id: I96455ee365799ae87d9ab433cf102c691616a45e --- .../repl_characterization/repl_characterization.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/functional/repl_characterization/repl_characterization.cc b/tests/functional/repl_characterization/repl_characterization.cc index d46f09553..68a66b2f3 100644 --- a/tests/functional/repl_characterization/repl_characterization.cc +++ b/tests/functional/repl_characterization/repl_characterization.cc @@ -16,10 +16,10 @@ using namespace std::string_literals; namespace nix { -static constexpr const char * REPL_PROMPT = "nix-repl> "; +static constexpr const std::string_view REPL_PROMPT = "nix-repl> "; // ASCII ENQ character -static constexpr const char * AUTOMATION_PROMPT = "\x05"; +static constexpr const std::string_view AUTOMATION_PROMPT = "\x05"; static std::string_view trimOutLog(std::string_view outLog) { @@ -42,7 +42,7 @@ public: void runReplTest(std::string_view const & content, std::vector extraArgs = {}) const { - auto syntax = CLILiterateParser::parse(REPL_PROMPT, content); + auto syntax = CLILiterateParser::parse(std::string(REPL_PROMPT), content); // FIXME: why does this need two --quiets // show-trace is on by default due to test configuration, but is not a standard @@ -52,7 +52,7 @@ public: auto nixBin = canonPath(getEnvNonEmpty("NIX_BIN_DIR").value_or(NIX_BIN_DIR)); auto process = RunningProcess::start(nixBin + "/nix", args); - auto session = TestSession{AUTOMATION_PROMPT, std::move(process)}; + auto session = TestSession{std::string(AUTOMATION_PROMPT), std::move(process)}; for (auto & bit : syntax) { if (bit.kind != CLILiterateParser::NodeKind::COMMAND) { @@ -72,7 +72,7 @@ public: auto replacedOutLog = boost::algorithm::replace_all_copy(session.outLog, unitTestData, "TEST_DATA"); auto cleanedOutLog = trimOutLog(replacedOutLog); - auto parsedOutLog = CLILiterateParser::parse(AUTOMATION_PROMPT, cleanedOutLog, 0); + auto parsedOutLog = CLILiterateParser::parse(std::string(AUTOMATION_PROMPT), cleanedOutLog, 0); parsedOutLog = CLILiterateParser::tidyOutputForComparison(std::move(parsedOutLog)); syntax = CLILiterateParser::tidyOutputForComparison(std::move(syntax)); @@ -85,7 +85,7 @@ TEST_F(ReplSessionTest, parses) { writeTest("basic.ast", [this]() { const std::string content = readFile(goldenMaster("basic.test")); - auto parser = CLILiterateParser{REPL_PROMPT}; + auto parser = CLILiterateParser{std::string(REPL_PROMPT)}; parser.feed(content); std::ostringstream out{}; @@ -97,7 +97,7 @@ TEST_F(ReplSessionTest, parses) writeTest("basic_tidied.ast", [this]() { const std::string content = readFile(goldenMaster("basic.test")); - auto syntax = CLILiterateParser::parse(REPL_PROMPT, content); + auto syntax = CLILiterateParser::parse(std::string(REPL_PROMPT), content); syntax = CLILiterateParser::tidyOutputForComparison(std::move(syntax));