Skip to content
Snippets Groups Projects
Commit 29d07f14 authored by Ondřej Štorc's avatar Ondřej Štorc
Browse files

cli: Fix passing of path in aql

New parser does not support passing raw path, thus we need to have it
as a string
parent e6412fbc
No related branches found
No related tags found
1 merge request!256Parser replacement with ANTLR
Showing with 28 additions and 28 deletions
......@@ -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)
......
......@@ -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)",
......
......@@ -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);
}
......
......@@ -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"),
......
......@@ -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);
......
......@@ -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))
......
......@@ -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",
};
......
......@@ -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);
}
......
......@@ -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"),
......
......@@ -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);
......
......@@ -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, " )")};
 
......
......@@ -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);
}
......
......@@ -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",
};
......
......@@ -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",
......
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment