forked from lix-project/lix
Make repl_characterization.cc
constants string_view
s
Change-Id: I96455ee365799ae87d9ab433cf102c691616a45e
This commit is contained in:
parent
ea10fe7ab0
commit
84018e1264
|
@ -16,10 +16,10 @@ using namespace std::string_literals;
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
static constexpr const char * REPL_PROMPT = "nix-repl> ";
|
static constexpr const std::string_view REPL_PROMPT = "nix-repl> ";
|
||||||
|
|
||||||
// ASCII ENQ character
|
// 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)
|
static std::string_view trimOutLog(std::string_view outLog)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ public:
|
||||||
|
|
||||||
void runReplTest(std::string_view const & content, std::vector<std::string> extraArgs = {}) const
|
void runReplTest(std::string_view const & content, std::vector<std::string> 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
|
// FIXME: why does this need two --quiets
|
||||||
// show-trace is on by default due to test configuration, but is not a standard
|
// 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 nixBin = canonPath(getEnvNonEmpty("NIX_BIN_DIR").value_or(NIX_BIN_DIR));
|
||||||
|
|
||||||
auto process = RunningProcess::start(nixBin + "/nix", args);
|
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) {
|
for (auto & bit : syntax) {
|
||||||
if (bit.kind != CLILiterateParser::NodeKind::COMMAND) {
|
if (bit.kind != CLILiterateParser::NodeKind::COMMAND) {
|
||||||
|
@ -72,7 +72,7 @@ public:
|
||||||
auto replacedOutLog = boost::algorithm::replace_all_copy(session.outLog, unitTestData, "TEST_DATA");
|
auto replacedOutLog = boost::algorithm::replace_all_copy(session.outLog, unitTestData, "TEST_DATA");
|
||||||
auto cleanedOutLog = trimOutLog(replacedOutLog);
|
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));
|
parsedOutLog = CLILiterateParser::tidyOutputForComparison(std::move(parsedOutLog));
|
||||||
syntax = CLILiterateParser::tidyOutputForComparison(std::move(syntax));
|
syntax = CLILiterateParser::tidyOutputForComparison(std::move(syntax));
|
||||||
|
@ -85,7 +85,7 @@ TEST_F(ReplSessionTest, parses)
|
||||||
{
|
{
|
||||||
writeTest("basic.ast", [this]() {
|
writeTest("basic.ast", [this]() {
|
||||||
const std::string content = readFile(goldenMaster("basic.test"));
|
const std::string content = readFile(goldenMaster("basic.test"));
|
||||||
auto parser = CLILiterateParser{REPL_PROMPT};
|
auto parser = CLILiterateParser{std::string(REPL_PROMPT)};
|
||||||
parser.feed(content);
|
parser.feed(content);
|
||||||
|
|
||||||
std::ostringstream out{};
|
std::ostringstream out{};
|
||||||
|
@ -97,7 +97,7 @@ TEST_F(ReplSessionTest, parses)
|
||||||
|
|
||||||
writeTest("basic_tidied.ast", [this]() {
|
writeTest("basic_tidied.ast", [this]() {
|
||||||
const std::string content = readFile(goldenMaster("basic.test"));
|
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));
|
syntax = CLILiterateParser::tidyOutputForComparison(std::move(syntax));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue