From 29d07f149601ff77eb430a446573e5688abbd466 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0torc?= <storcond@fit.cvut.cz>
Date: Wed, 29 Mar 2023 08:32:57 +0200
Subject: [PATCH] cli: Fix passing of path in aql

New parser does not support passing raw path, thus we need to have it
as a string
---
 tests/cppaql/approximateMatching.cpp          | 2 +-
 tests/cppaql/arbologyTest.cpp                 | 4 ++--
 tests/cppaql/conversionsTest.cpp              | 2 +-
 tests/cppaql/conversionsTest2.cpp             | 4 ++--
 tests/cppaql/determinizeTest.cpp              | 4 ++--
 tests/cppaql/exactMatching.cpp                | 4 ++--
 tests/cppaql/glushkovRteTest.cpp              | 6 +++---
 tests/cppaql/minimizeTest.cpp                 | 6 +++---
 tests/cppaql/normalizeTest.cpp                | 2 +-
 tests/cppaql/readerTest.cpp                   | 7 ++++---
 tests/cppaql/regexpDerivationIntegralTest.cpp | 4 ++--
 tests/cppaql/regexpOptimizeTest.cpp           | 2 +-
 tests/cppaql/treeNotationTest.cpp             | 2 +-
 tests/cppaql/treeRepeatsTest.cpp              | 2 +-
 tests/testing/AqlTest.hpp                     | 5 ++---
 15 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/tests/cppaql/approximateMatching.cpp b/tests/cppaql/approximateMatching.cpp
index 1da8695466..6832e69ed0 100644
--- a/tests/cppaql/approximateMatching.cpp
+++ b/tests/cppaql/approximateMatching.cpp
@@ -17,7 +17,7 @@ static std::string qSetError(const size_t error, const std::string& var)
 
 static std::string qPrepareString(const std::string& file, const std::string& var)
 {
-    return ext::concat("execute < ", file, " > $", var);
+    return ext::concat("execute < \"", file, "\" > $", var);
 }
 
 static std::string qExtendAlphabet(const std::string& s1, const std::string& s2)
diff --git a/tests/cppaql/arbologyTest.cpp b/tests/cppaql/arbologyTest.cpp
index 1a498b311c..50babb06c2 100644
--- a/tests/cppaql/arbologyTest.cpp
+++ b/tests/cppaql/arbologyTest.cpp
@@ -129,8 +129,8 @@ static std::vector<std::pair<std::string, std::string>> pair_pattern_subject(con
 void runTest(const std::string& exactPipeline, const std::string& pipeline, const std::string& pFile, const std::string& sFile)
 {
     ext::vector<std::string> qs = {
-        ext::concat("execute < ", pFile, " > $pattern"),
-        ext::concat("execute < ", sFile, " > $subject"),
+        ext::concat("execute < \"", pFile, "\" > $pattern"),
+        ext::concat("execute < \"", sFile, "\" > $subject"),
         ext::concat("execute ", exactPipeline, " > $res1"),
         ext::concat("execute ", pipeline, " > $res2"),
         "quit compare::IsSame <(stats::SizeStat $res1) <(stats::SizeStat $res2)",
diff --git a/tests/cppaql/conversionsTest.cpp b/tests/cppaql/conversionsTest.cpp
index ea8c6f8c49..2ce333c6bd 100644
--- a/tests/cppaql/conversionsTest.cpp
+++ b/tests/cppaql/conversionsTest.cpp
@@ -22,7 +22,7 @@ void fileTest(const std::string& pipeline)
 {
     for (const std::string& inputFile : TestFiles::Get("/automaton/aconversion.test.*.xml$")) {
         ext::vector<std::string> qs = {
-            ext::concat("execute < ", inputFile, " > $gen"),
+            ext::concat("execute < \"", inputFile, "\" > $gen"),
             ext::concat("quit compare::AutomatonCompare <( $gen | ", qMinimize, " ) <( $gen | ", pipeline, " | ", qMinimize, ")")};
         TimeoutAqlTest(10s, qs);
     }
diff --git a/tests/cppaql/conversionsTest2.cpp b/tests/cppaql/conversionsTest2.cpp
index 1427c64554..40af53f35b 100644
--- a/tests/cppaql/conversionsTest2.cpp
+++ b/tests/cppaql/conversionsTest2.cpp
@@ -29,7 +29,7 @@ TEST_CASE("FTA-RTE conversions test", "[integration]")
     {
         for (const std::string& inputFile : TestFiles::Get("/rte/rte*.xml$")) {
             ext::vector<std::string> qs = {
-                ext::concat("execute < ", inputFile, " | rte::convert::ToFTAGlushkov - > $gen"),
+                ext::concat("execute < \"", inputFile, "\" | rte::convert::ToFTAGlushkov - > $gen"),
                 ext::concat("quit compare::AutomatonCompare <( $gen | ", qMinimize, " ) <( $gen | automaton::convert::ToRTEStateElimination - | rte::convert::ToFTAGlushkov - | ", qMinimize, ")")};
 
             TimeoutAqlTest(10s, qs);
@@ -57,7 +57,7 @@ TEST_CASE("FTA-RTE conversions test", "[integration]")
 
         for (const std::string& file : files) {
             ext::vector<std::string> qs = {
-                ext::concat("execute < ", file, " > $fta1"),
+                ext::concat("execute < \"", file, "\" > $fta1"),
                 "execute $fta1 | automaton::convert::ToRTEStateElimination - | rte::convert::ToFTAGlushkov - > $fta2",
                 ext::concat("execute $fta1 | ", qMinimize, " > $m1"),
                 ext::concat("execute $fta2 | ", qMinimize, " > $m2"),
diff --git a/tests/cppaql/determinizeTest.cpp b/tests/cppaql/determinizeTest.cpp
index 68651110e8..4b2d55a04b 100644
--- a/tests/cppaql/determinizeTest.cpp
+++ b/tests/cppaql/determinizeTest.cpp
@@ -22,8 +22,8 @@ TEST_CASE("Determinization", "[integration]")
                                std::make_tuple("automaton::determinize::Determinize - | automaton::simplify::Normalize -", TestFiles::GetOne("/automaton/NPDA1.xml$"), TestFiles::GetOne("/automaton/NPDA1.DET.xml$")));
 
     ext::vector<std::string> qs = {
-        ext::concat("execute < ", std::get<1>(definition), " > $input"),
-        ext::concat("execute < ", std::get<2>(definition), " > $expected"),
+        ext::concat("execute < \"", std::get<1>(definition), "\" > $input"),
+        ext::concat("execute < \"", std::get<2>(definition), "\" > $expected"),
         ext::concat("quit compare::AutomatonCompare <( $input | ", std::get<0>(definition), " ) $expected")};
 
     TimeoutAqlTest(2s, qs);
diff --git a/tests/cppaql/exactMatching.cpp b/tests/cppaql/exactMatching.cpp
index 9d6c33eff4..dde7012c41 100644
--- a/tests/cppaql/exactMatching.cpp
+++ b/tests/cppaql/exactMatching.cpp
@@ -55,8 +55,8 @@ TEST_CASE("ExactMatching", "[integration]")
             subjectFile.replace(pos, s.size(), s);
 
             ext::vector<std::string> qs = {
-                ext::concat("execute < ", patternFile, " > $pattern"),
-                ext::concat("execute < ", subjectFile, " > $subject"),
+                ext::concat("execute < \"", patternFile, "\" > $pattern"),
+                ext::concat("execute < \"", subjectFile, "\" > $subject"),
                 "execute stringology::exact::ExactFactorMatch $subject $pattern > $res1"};
 
             if (std::get<2>(definition))
diff --git a/tests/cppaql/glushkovRteTest.cpp b/tests/cppaql/glushkovRteTest.cpp
index a37ece7015..3531fb3c4d 100644
--- a/tests/cppaql/glushkovRteTest.cpp
+++ b/tests/cppaql/glushkovRteTest.cpp
@@ -39,7 +39,7 @@ TEST_CASE("GlushkovRTE", "[integration]")
             try {
                 for (size_t i = 0; i < TESTCASES; i++) {
                     ext::vector<std::string> qs = {
-                        ext::concat("execute < ", file, " | rte::convert::ToPostfixPushdownAutomatonGlushkov - | automaton::determinize::Determinize - > $pda"),
+                        ext::concat("execute < \"", file, "\" | rte::convert::ToPostfixPushdownAutomatonGlushkov - | automaton::determinize::Determinize - > $pda"),
                         ext::concat("execute \"", m_Generators.at(base)->generate(), "\" | Move - | string::Parse @tree::Tree - | "
                                                                                      "string::transform::StringConcatenate ( PostfixRankedTree ) - <(string::Parse @string::String \"\\\"#$\\\"\") > $string"),
                         "quit automaton::run::Accept $pda $string",
@@ -63,7 +63,7 @@ TEST_CASE("GlushkovRTE", "[integration]")
             try {
                 for (size_t i = 0; i < TESTCASES; i++) {
                     ext::vector<std::string> qs = {
-                        ext::concat("execute < ", file, " | rte::convert::ToFTAGlushkov - | automaton::determinize::Determinize - > $fta"),
+                        ext::concat("execute < \"", file, "\" | rte::convert::ToFTAGlushkov - | automaton::determinize::Determinize - > $fta"),
                         ext::concat("execute \"", m_Generators.at(base)->generate(), "\" | Move - | string::Parse @tree::Tree - > $input"),
                         "quit automaton::run::Accept $fta (PostfixRankedTree)$input",
                     };
@@ -86,7 +86,7 @@ TEST_CASE("GlushkovRTE", "[integration]")
             try {
                 for (size_t i = 0; i < TESTCASES; i++) {
                     ext::vector<std::string> qs = {
-                        ext::concat("execute < ", file, " | rte::convert::ToFTAThompson - | automaton::simplify::EpsilonRemoverOutgoing - | automaton::determinize::Determinize - > $fta"),
+                        ext::concat("execute < \"", file, "\" | rte::convert::ToFTAThompson - | automaton::simplify::EpsilonRemoverOutgoing - | automaton::determinize::Determinize - > $fta"),
                         ext::concat("execute \"", m_Generators.at(base)->generate(), "\" | Move - | string::Parse @tree::Tree - > $input"),
                         "quit automaton::run::Accept $fta (PostfixRankedTree)$input",
                     };
diff --git a/tests/cppaql/minimizeTest.cpp b/tests/cppaql/minimizeTest.cpp
index 7fa3450bf8..8876e656e9 100644
--- a/tests/cppaql/minimizeTest.cpp
+++ b/tests/cppaql/minimizeTest.cpp
@@ -30,17 +30,17 @@ TEST_CASE("Minimization FA test", "[integration]")
             ext::vector<std::string> qs;
 
             qs = {
-                ext::concat("execute < ", inputFile, " > $gen"),
+                ext::concat("execute < \"", inputFile, "\" > $gen"),
                 ext::concat("quit compare::AutomatonCompare <( $gen | ", qMinimizeHop, " ) <( $gen | ", qMinimizeBrz, ")")};
             TimeoutAqlTest(2s, qs);
 
             qs = {
-                ext::concat("execute < ", inputFile, " > $gen"),
+                ext::concat("execute < \"", inputFile, "\" > $gen"),
                 ext::concat("quit compare::AutomatonCompare <( $gen | ", qMinimizeHop, " ) <( $gen | ", qMinimizeDis, ")")};
             TimeoutAqlTest(2s, qs);
 
             qs = {
-                ext::concat("execute < ", inputFile, " > $gen"),
+                ext::concat("execute < \"", inputFile, "\" > $gen"),
                 ext::concat("quit compare::AutomatonCompare <( $gen | ", qMinimizeHop, " ) <( $gen | ", qMinimizeUnd, ")")};
             TimeoutAqlTest(2s, qs);
         }
diff --git a/tests/cppaql/normalizeTest.cpp b/tests/cppaql/normalizeTest.cpp
index d2afe698fa..eaefc4eef6 100644
--- a/tests/cppaql/normalizeTest.cpp
+++ b/tests/cppaql/normalizeTest.cpp
@@ -25,7 +25,7 @@ TEST_CASE("Normalize test", "[integration]")
     {
         for (const std::string& file : TestFiles::Get("/grammar/anormalization.test.*.xml$")) {
             ext::vector<std::string> qs = {
-                ext::concat("execute < ", file, " > $cfg"),
+                ext::concat("execute < \"", file, "\" > $cfg"),
                 ext::concat("execute ", algorithm, " $cfg > $cfg2"),
                 ext::concat("execute grammar::generate::GenerateUpToLength $cfg ", STRING_LENGTHS, " > $str"),
                 ext::concat("execute grammar::generate::GenerateUpToLength $cfg2 ", STRING_LENGTHS, " > $str2"),
diff --git a/tests/cppaql/readerTest.cpp b/tests/cppaql/readerTest.cpp
index 7262e3f8f5..e3b855d05f 100644
--- a/tests/cppaql/readerTest.cpp
+++ b/tests/cppaql/readerTest.cpp
@@ -11,10 +11,11 @@ TEST_CASE("ReaderTest | Xml", "[integration]")
 
     for (const std::string& file : TestFiles::Get(regexp)) {
         ext::vector<std::string> qs = {
-            ext::concat("execute < ", file, " > $object"),
-            "execute $object > /dev/null",
+            ext::concat("execute < \"", file, "\" > $object"),
+            "execute $object > \"/dev/null\"",
         };
 
+
         TimeoutAqlTest(1s, qs);
     }
 }
@@ -30,7 +31,7 @@ TEST_CASE("ReaderTest | Txt ", "[integration]")
     for (const std::string& file : TestFiles::Get(def.second)) {
         ext::vector<std::string> qs = {
             ext::concat("execute cli::builtin::ReadFile \"", file, "\" | Move - | string::Parse @", def.first, " -  > $object"),
-            "execute $object > /dev/null",
+            "execute $object > \"/dev/null\"",
         };
 
         TimeoutAqlTest(1s, qs);
diff --git a/tests/cppaql/regexpDerivationIntegralTest.cpp b/tests/cppaql/regexpDerivationIntegralTest.cpp
index 1837f73345..359d7efad0 100644
--- a/tests/cppaql/regexpDerivationIntegralTest.cpp
+++ b/tests/cppaql/regexpDerivationIntegralTest.cpp
@@ -26,8 +26,8 @@ TEST_CASE("RegExp Derivation/Integral test", "[integration]")
                                std::make_tuple(Op::INTEGRAL, TestFiles::GetOne("/regexp/Melichar2-94.xml"), TestFiles::GetOne("/regexp/Melichar2-94.i1.xml"), "1"));
 
     std::vector<std::string> qs = {
-        ext::concat("execute < ", std::get<1>(definition), " > $regexp"),
-        ext::concat("execute < ", std::get<2>(definition), " > $result"),
+        ext::concat("execute < \"", std::get<1>(definition), "\" > $regexp"),
+        ext::concat("execute < \"", std::get<2>(definition), "\" > $result"),
         ext::concat("execute \"\\\"", std::get<3>(definition), "\\\"\" | Move - | string::Parse @string::String - > $string"),
         ext::concat("quit compare::AutomatonCompare <( $result | ", mdfa, " ) <( regexp::transform::RegExp", std::get<0>(definition) == Op::DERIVATION ? "Derivation" : "Integral", " $regexp $string | ", mdfa, " )")};
 
diff --git a/tests/cppaql/regexpOptimizeTest.cpp b/tests/cppaql/regexpOptimizeTest.cpp
index 8f121d23d0..a371c7389d 100644
--- a/tests/cppaql/regexpOptimizeTest.cpp
+++ b/tests/cppaql/regexpOptimizeTest.cpp
@@ -28,7 +28,7 @@ TEST_CASE("RE optimize test", "[integration]")
         for (size_t i = 0; i < ITERATIONS; i++) {
             ext::vector<std::string> qs = {
                 ext::concat(qGenRE(), " > $gen"),
-                "execute string::Compose $gen > /tmp/file",
+                "execute string::Compose $gen > \"/tmp/file\"",
                 ext::concat("quit compare::AutomatonCompare <( $gen | regexp::convert::ToAutomaton - | ", qMinimize1, " ) <( $gen | regexp::simplify::RegExpOptimize - | regexp::convert::ToAutomaton - | ", qMinimize2, ")")};
             TimeoutAqlTest(10s, qs);
         }
diff --git a/tests/cppaql/treeNotationTest.cpp b/tests/cppaql/treeNotationTest.cpp
index 5c052b8e2c..cc7b681e2a 100644
--- a/tests/cppaql/treeNotationTest.cpp
+++ b/tests/cppaql/treeNotationTest.cpp
@@ -19,7 +19,7 @@ TEST_CASE("TreeNotation tests | Files", "[integration]")
     {
         for (const std::string& file : TestFiles::Get("/tree/repeats.*.xml")) {
             ext::vector<std::string> qs = {
-                ext::concat("execute < ", file, " > $res1"),
+                ext::concat("execute < \"", file, "\" > $res1"),
                 ext::concat("execute (RankedTree)", casts, "$res1 > $res2"),
                 "quit compare::IsSame $res1 $res2",
             };
diff --git a/tests/cppaql/treeRepeatsTest.cpp b/tests/cppaql/treeRepeatsTest.cpp
index 29f410732a..f3c906e48f 100644
--- a/tests/cppaql/treeRepeatsTest.cpp
+++ b/tests/cppaql/treeRepeatsTest.cpp
@@ -22,7 +22,7 @@ TEST_CASE("TreeRepeats", "[integration]")
     {
         for (const std::string& file : TestFiles::Get("/tree/repeats.*.xml")) {
             ext::vector<std::string> qs = {
-                ext::concat("execute < ", file, " > $tree"),
+                ext::concat("execute < \"", file, "\" > $tree"),
                 "execute tree::properties::ExactSubtreeRepeatsNaive $tree | tree::simplify::NormalizeTreeLabels - > $res1", // naive
                 ext::concat("execute ", pipeline, " > $res2"),
                 "quit compare::IsSame $res1 $res2",
diff --git a/tests/testing/AqlTest.hpp b/tests/testing/AqlTest.hpp
index 8833635752..8ee8cdda22 100644
--- a/tests/testing/AqlTest.hpp
+++ b/tests/testing/AqlTest.hpp
@@ -32,10 +32,9 @@ AqlTestResult AqlTest(Stream& is, unsigned seed)
         common::Streams::err = ext::reference_wrapper<ext::ostream>(oss);
 
         // seed cli, run test file
-        auto testSeed = std::make_shared<cli::StringLineInterface>("set seed " + ext::to_string(seed));
-        auto testFile = std::make_shared<cli::IstreamLineInterface<Stream&>>(is);
+        auto testSeed = "set seed " + ext::to_string(seed);
         result = environment.execute(testSeed);
-        result = environment.execute(testFile);
+        result = environment.execute(is);
 
         int returnValue;
         if (result == cli::CommandResult::QUIT || result == cli::CommandResult::RETURN) {
-- 
GitLab