aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-03-09 23:59:50 -0800
committerJade Lovelace <lix@jade.fyi>2024-03-15 12:31:16 -0700
commit78513b1fc8366ade7bd2315f24e08ede5141c0a9 (patch)
treeacdebb8b00827a3fcc1b16e4265ed180651b1715
parent8a8715af89c0223e441772d38be6363b86452705 (diff)
repl_characterization: eat newlines after commands and source-dir paths
This is because they are unrepresentable in the source files with commentary but not in the output, so we should just eat them in normalization. It's ok. Change-Id: I2cb7e8b3fc7b00874885bb287cbaa200b41cb16b
-rw-r--r--tests/functional/repl_characterization/data/basic.ast6
-rw-r--r--tests/functional/repl_characterization/data/basic.test6
-rw-r--r--tests/functional/repl_characterization/data/basic_tidied.ast10
-rw-r--r--tests/functional/repl_characterization/repl_characterization.cc19
4 files changed, 40 insertions, 1 deletions
diff --git a/tests/functional/repl_characterization/data/basic.ast b/tests/functional/repl_characterization/data/basic.ast
index d494b00aa..af70e149b 100644
--- a/tests/functional/repl_characterization/data/basic.ast
+++ b/tests/functional/repl_characterization/data/basic.ast
@@ -9,3 +9,9 @@ Command "command two"
Output "output output output"
Commentary "commentary"
Output "output output output"
+Output ""
+Commentary "the blank below should be chomped"
+Command "command three"
+Commentary ""
+Output "meow output"
+Output ""
diff --git a/tests/functional/repl_characterization/data/basic.test b/tests/functional/repl_characterization/data/basic.test
index d6b8427b4..d62bacbbc 100644
--- a/tests/functional/repl_characterization/data/basic.test
+++ b/tests/functional/repl_characterization/data/basic.test
@@ -9,3 +9,9 @@ meow meow
output output output
commentary
output output output
+
+the blank below should be chomped
+ nix-repl> command three
+
+ meow output
+
diff --git a/tests/functional/repl_characterization/data/basic_tidied.ast b/tests/functional/repl_characterization/data/basic_tidied.ast
new file mode 100644
index 000000000..878065a5c
--- /dev/null
+++ b/tests/functional/repl_characterization/data/basic_tidied.ast
@@ -0,0 +1,10 @@
+Command "command"
+Output "output output one"
+Output ""
+Output ""
+Output "output output two"
+Command "command two"
+Output "output output output"
+Output "output output output"
+Command "command three"
+Output "meow output"
diff --git a/tests/functional/repl_characterization/repl_characterization.cc b/tests/functional/repl_characterization/repl_characterization.cc
index 200eda1ee..1d497fe13 100644
--- a/tests/functional/repl_characterization/repl_characterization.cc
+++ b/tests/functional/repl_characterization/repl_characterization.cc
@@ -4,6 +4,7 @@
#include <string_view>
#include <optional>
#include <unistd.h>
+#include <boost/algorithm/string/replace.hpp>
#include "test-session.hh"
#include "util.hh"
@@ -68,7 +69,10 @@ public:
}
session.close();
- auto parsedOutLog = CLILiterateParser::parse(AUTOMATION_PROMPT, trimOutLog(session.outLog), 0);
+ auto replacedOutLog = boost::algorithm::replace_all_copy(session.outLog, unitTestData, "TEST_DATA");
+ auto cleanedOutLog = trimOutLog(replacedOutLog);
+
+ auto parsedOutLog = CLILiterateParser::parse(AUTOMATION_PROMPT, cleanedOutLog, 0);
parsedOutLog = CLILiterateParser::tidyOutputForComparison(std::move(parsedOutLog));
syntax = CLILiterateParser::tidyOutputForComparison(std::move(syntax));
@@ -90,6 +94,19 @@ TEST_F(ReplSessionTest, parses)
}
return out.str();
});
+
+ writeTest("basic_tidied.ast", [this]() {
+ const std::string content = readFile(goldenMaster("basic.test"));
+ auto syntax = CLILiterateParser::parse(REPL_PROMPT, content);
+
+ syntax = CLILiterateParser::tidyOutputForComparison(std::move(syntax));
+
+ std::ostringstream out{};
+ for (auto & bit : syntax) {
+ out << bit.print() << "\n";
+ }
+ return out.str();
+ });
}
TEST_F(ReplSessionTest, repl_basic)