From d682f5358d5529097b00a4542213a2bb22be3af7 Mon Sep 17 00:00:00 2001 From: Radoslaw Cybulski Date: Thu, 25 Apr 2019 10:37:13 +0200 Subject: [PATCH] Fixes for batch mode Minor refactor and some fixes for batch mode. Change-Id: I109c0b9d0e5476f74ead6633dd4bd8fcc6b7c29e --- src/NavigationInterface.cpp | 3 +- src/batch/BatchRunner.cpp | 14 +- src/batch/Evaluator.cpp | 311 +++++++++++++++++-------------- src/batch/Evaluator.hpp | 75 ++++---- src/batch/batch_exec.sh | 5 +- src/batch/run-batch.sh | 3 +- src/main.cpp | 2 +- tests/no-ui-scenarios/BatchExecTests.cpp | 5 +- 8 files changed, 228 insertions(+), 190 deletions(-) diff --git a/src/NavigationInterface.cpp b/src/NavigationInterface.cpp index 2b3c7f5..67db80c 100644 --- a/src/NavigationInterface.cpp +++ b/src/NavigationInterface.cpp @@ -75,7 +75,8 @@ NavigationInterface::~NavigationInterface() NavigationInterface::CallbackHandleBase::~CallbackHandleBase() { - Singleton::instance().getNavigationInterface()->unregisterCb(this); + if (Singleton::instance().getNavigationInterface()) + Singleton::instance().getNavigationInterface()->unregisterCb(this); } void NavigationInterface::unregisterCb(CallbackHandleBase *cb) diff --git a/src/batch/BatchRunner.cpp b/src/batch/BatchRunner.cpp index 02b7453..fadd378 100644 --- a/src/batch/BatchRunner.cpp +++ b/src/batch/BatchRunner.cpp @@ -1021,13 +1021,13 @@ Optional runBatch(const std::array, (size_t)u output << "executing test '" << sourceName << "'\n"; if (arguments[static_cast(utils::Argument::WriteDebug)]) { - auto ptr = std::make_unique>(*outputPtr); - DebugEvaluatorInterface::setCurrentInterface(std::move(ptr)); - - std::ostringstream os; - result->printSelfInfo(os, 0); - *outputPtr << "Parsed source code:\n"; - *outputPtr << os.str() << "\n\n"; + auto &arg = *arguments[static_cast(utils::Argument::WriteDebug)]; + if (!arg.empty() && arg != "0" && arg != "no" && arg != "n" && arg != "nie") { + auto ptr = std::make_unique(*outputPtr); + DebugEvaluatorInterface::setCurrentInterface(std::move(ptr)); + } } + DebugEvaluator{} << "Parsed source code:"; + result->printSelfInfo(0); return std::thread { threadFunc, std::move(result), std::move(exec), std::move(outputPtr), std::move(dlog) }; } diff --git a/src/batch/Evaluator.cpp b/src/batch/Evaluator.cpp index 0221f7a..ab67e43 100644 --- a/src/batch/Evaluator.cpp +++ b/src/batch/Evaluator.cpp @@ -24,12 +24,36 @@ #include #include -std::ostringstream &Evaluator::printLocationAndIndent(std::ostringstream &os, const TokenLocation &loc, unsigned int depth) const +DebugEvaluator::DebugEvaluator() +{ + using namespace std::chrono; + static auto start = high_resolution_clock::now(); + + auto now = high_resolution_clock::now(); + auto df = now - start; + auto s = duration_cast(df); + df -= s; + auto ms = duration_cast(df); + (*tmp) << std::setw(2) << s.count() << "s " << std::setw(3) << ms.count() << "ms "; +} + +DebugEvaluator::~DebugEvaluator() +{ + if (tmp) { + auto q = tmp->str(); + DEBUG("%s", q.c_str()); + auto v = DebugEvaluatorInterface::getCurrentInterface(); + if (v) v->write_impl(q.c_str()); + } +} + +DebugEvaluator Evaluator::printLocationAndIndent(const TokenLocation &loc, unsigned int depth) const { std::string indent(static_cast(depth), ' '); - os << std::setw(4) << loc.lineNum() << ":" << std::setw(4) << loc.offsetNum() << - " debugId " << std::setw(4) << getDebugId() << " " << indent; - return os; + DebugEvaluator d{}; + d << std::setw(4) << loc.lineNum() << ":" << std::setw(4) << loc.offsetNum() << + " debugId " << std::setw(4) << getDebugId() << " " << indent; + return std::move(d); } Evaluator::Evaluator(TokenLocation tokenLocation) : tokenLocation(std::move(tokenLocation)) @@ -82,31 +106,23 @@ template static auto evaluateHelper(std::string debugId, TokenLocat } }; EvaluationDepthCountManager countManager; - if (!debugInterface) { - try { - return f(); - } catch (EvaluationFailure &ev) { - ev.setLocationIfMissing(loc); - throw; - } - } std::string indent(static_cast(evaluationDepth * 2), ' '); try { CallOnExit call{ [&]() { - debugInterface->write(indent + "leaving " + debugId); + DebugEvaluator{} << indent << "leaving " << debugId; } }; - debugInterface->write(indent + "entering " + debugId); + DebugEvaluator{} << indent << "entering " << debugId; return f(); } catch (EvaluationFailure &ev) { ev.setLocationIfMissing(loc); - debugInterface->write(indent + "exception " + debugId + " (" + ev.what() + "), leaving"); + DebugEvaluator{} << indent << "exception " << debugId << " (" << ev.what() << "), leaving"; throw; } catch (std::exception &ex) { - debugInterface->write(indent + "exception " + debugId + " (" + ex.what() + "), leaving"); + DebugEvaluator{} << indent << "exception " << debugId << " (" << ex.what() << "), leaving"; throw; } catch (...) { - debugInterface->write(indent + "exception " + debugId + ", leaving"); + DebugEvaluator{} << indent << "exception " << debugId << ", leaving"; throw; } } @@ -133,9 +149,9 @@ EvaluationValue IdentifierEvaluator::evaluateImpl() const return EvaluationContext::getCurrentEvaluationContext().getVariable(location(), identifier); } -void IdentifierEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void IdentifierEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "identifier " << identifier << "\n"; + printLocationAndIndent(location(), depth) << "identifier " << identifier << "\n"; } AttributeEvaluator::AttributeEvaluator(TokenLocation tokenLocation, ExprPtr self, std::string identifier) : @@ -146,11 +162,11 @@ EvaluationValue AttributeEvaluator::evaluateImpl() const return self->evaluate().attr_get(identifier); } -void AttributeEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void AttributeEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "attribute " << identifier << "\n"; - printLocationAndIndent(os, location(), depth) << "self is\n"; - self->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "attribute " << identifier << "\n"; + printLocationAndIndent(location(), depth) << "self is\n"; + self->printSelfInfo(depth + 1); } AttributeSetterEvaluator::AttributeSetterEvaluator(TokenLocation tokenLocation, ExprPtr self, std::string identifier, ExprPtr value) : @@ -162,13 +178,13 @@ EvaluationValue AttributeSetterEvaluator::evaluateImpl() const return self->evaluate().attr_set(identifier, std::move(val)); } -void AttributeSetterEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void AttributeSetterEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "attribute setter " << identifier << "\n"; - printLocationAndIndent(os, location(), depth) << "self is\n"; - self->printSelfInfo(os, depth + 1); - printLocationAndIndent(os, location(), depth) << "value to set is\n"; - value->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "attribute setter " << identifier << "\n"; + printLocationAndIndent(location(), depth) << "self is\n"; + self->printSelfInfo(depth + 1); + printLocationAndIndent(location(), depth) << "value to set is\n"; + value->printSelfInfo(depth + 1); } @@ -183,11 +199,11 @@ EvaluationValue SetterEvaluator::evaluateImpl() const return v; } -void SetterEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void SetterEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "setter " << identifier << "\n"; - printLocationAndIndent(os, location(), depth) << "value to set is\n"; - value->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "setter " << identifier << "\n"; + printLocationAndIndent(location(), depth) << "value to set is\n"; + value->printSelfInfo(depth + 1); } @@ -202,13 +218,13 @@ EvaluationValue PointEvaluator::evaluateImpl() const return EvaluationValuePoint{ static_cast(xInt), static_cast(yInt) }; } -void PointEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void PointEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "point\n"; - printLocationAndIndent(os, location(), depth) << "x is\n"; - x->printSelfInfo(os, depth + 1); - printLocationAndIndent(os, location(), depth) << "y is\n"; - y->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "point\n"; + printLocationAndIndent(location(), depth) << "x is\n"; + x->printSelfInfo(depth + 1); + printLocationAndIndent(location(), depth) << "y is\n"; + y->printSelfInfo(depth + 1); } @@ -221,9 +237,9 @@ EvaluationValue IntegerEvaluator::evaluateImpl() const return value; } -void IntegerEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void IntegerEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "integer " << value << "\n"; + printLocationAndIndent(location(), depth) << "integer " << value << "\n"; } @@ -236,9 +252,9 @@ EvaluationValue DoubleEvaluator::evaluateImpl() const return value; } -void DoubleEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void DoubleEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "double " << value << "\n"; + printLocationAndIndent(location(), depth) << "double " << value << "\n"; } @@ -251,9 +267,9 @@ EvaluationValue StringEvaluator::evaluateImpl() const return value; } -void StringEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void StringEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "string '" << value << "'\n"; + printLocationAndIndent(location(), depth) << "string '" << value << "'\n"; } @@ -285,31 +301,33 @@ EvaluationValue ArraySetDictEvaluator::evaluateImpl() const return std::move(tmp); } -void ArraySetDictEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void ArraySetDictEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth); - switch (kind) { - case Kind::SET: - os << "set\n"; - break; - case Kind::VECTOR: - os << "vector\n"; - break; - case Kind::DICT: - os << "dict\n"; - break; + { + auto os = printLocationAndIndent(location(), depth); + switch (kind) { + case Kind::SET: + os << "set\n"; + break; + case Kind::VECTOR: + os << "vector\n"; + break; + case Kind::DICT: + os << "dict\n"; + break; + } } if (kind == Kind::SET || kind == Kind::VECTOR) { for (auto i = 0u; i < values.size(); ++i) { - printLocationAndIndent(os, location(), depth) << "element " << (i + 1) << "\n"; - values[i]->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "element " << (i + 1) << "\n"; + values[i]->printSelfInfo(depth + 1); } } else { for (auto i = 0u; i < values.size(); i += 2) { - printLocationAndIndent(os, location(), depth) << "element " << (i / 2 + 1) << " key\n"; - values[i]->printSelfInfo(os, depth + 1); - printLocationAndIndent(os, location(), depth) << "element " << (i / 2 + 1) << " value\n"; - values[i + 1]->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "element " << (i / 2 + 1) << " key\n"; + values[i]->printSelfInfo(depth + 1); + printLocationAndIndent(location(), depth) << "element " << (i / 2 + 1) << " value\n"; + values[i + 1]->printSelfInfo(depth + 1); } } } @@ -345,32 +363,35 @@ EvaluationValue OperatorEvaluator::evaluateImpl() const throw EvaluationFailure{} << "unknown operator"; } -void OperatorEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void OperatorEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "operator "; - const char *desc = nullptr; - switch (kind) { - case Kind::IN: - desc = "in"; - break; - case Kind::NOT: - desc = "not"; - break; - case Kind::MINUS: - desc = "-"; - break; - case Kind::GET: - desc = "[]"; - break; - case Kind::SET: - desc = "[]="; - break; - } + { + auto os = printLocationAndIndent(location(), depth); + os << "operator "; + const char *desc = nullptr; + switch (kind) { + case Kind::IN: + desc = "in"; + break; + case Kind::NOT: + desc = "not"; + break; + case Kind::MINUS: + desc = "-"; + break; + case Kind::GET: + desc = "[]"; + break; + case Kind::SET: + desc = "[]="; + break; + } - os << desc << "\n"; + os << desc << "\n"; + } for (auto i = 0u; i < args.size(); ++i) { - printLocationAndIndent(os, location(), depth) << "element " << (i + 1) << " key\n"; - args[i]->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "element " << (i + 1) << " key\n"; + args[i]->printSelfInfo(depth + 1); } } @@ -408,38 +429,40 @@ EvaluationValue CompOperatorEvaluator::evaluateImpl() const return true; } -void CompOperatorEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void CompOperatorEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "operators"; - for (auto k : kinds) { - const char *desc = nullptr; - switch (k) { - case Kind::EQ: - desc = "=="; - break; - case Kind::NE: - desc = "!="; - break; - case Kind::GT: - desc = ">"; - break; - case Kind::LT: - desc = "<"; - break; - case Kind::GE: - desc = ">="; - break; - case Kind::LE: - desc = "<="; - break; + { + auto os = printLocationAndIndent(location(), depth); + os << "operators"; + for (auto k : kinds) { + const char *desc = nullptr; + switch (k) { + case Kind::EQ: + desc = "=="; + break; + case Kind::NE: + desc = "!="; + break; + case Kind::GT: + desc = ">"; + break; + case Kind::LT: + desc = "<"; + break; + case Kind::GE: + desc = ">="; + break; + case Kind::LE: + desc = "<="; + break; + } + os << " " << desc; } - os << " " << desc; } - os << "\n"; for (auto i = 0u; i < args.size(); ++i) { - printLocationAndIndent(os, location(), depth) << "argument " << (i + 1) << " key\n"; - args[i]->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "argument " << (i + 1) << " key\n"; + args[i]->printSelfInfo(depth + 1); } } @@ -453,9 +476,9 @@ EvaluationValue BooleanEvaluator::evaluateImpl() const return value; } -void BooleanEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void BooleanEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "boolean " << (value ? "true" : "false") << "\n"; + printLocationAndIndent(location(), depth) << "boolean " << (value ? "true" : "false") << "\n"; } @@ -480,13 +503,13 @@ EvaluationValue CallEvaluator::evaluateImpl() const return std::move(result); } -void CallEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void CallEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "function call\n"; - function->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "function call\n"; + function->printSelfInfo(depth + 1); for (auto i = 0u; i < args.size(); ++i) { - printLocationAndIndent(os, location(), depth) << "arg " << i << " is\n"; - args[i]->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "arg " << i << " is\n"; + args[i]->printSelfInfo(depth + 1); } } @@ -512,23 +535,25 @@ void FunctionEvaluator::evaluateImpl() const } try { + DebugEvaluator{} << getDebugId() << ": function is called, evaluating"; codeBlock->evaluate(); } catch (ReturnValue &r) { + DebugEvaluator{} << getDebugId() << ": got return value " << r.getResult(); return r.getResult(); } return {}; }}); } -void FunctionEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void FunctionEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "function definition " << functionName << "\n"; + printLocationAndIndent(location(), depth) << "function definition " << functionName << "\n"; for (auto i = 0u; i < argNames.size(); ++i) { - printLocationAndIndent(os, location(), depth) << "arg " << i << " is " << argNames[i] << "\n"; + printLocationAndIndent(location(), depth) << "arg " << i << " is " << argNames[i] << "\n"; } - printLocationAndIndent(os, location(), depth) << "body\n"; - codeBlock->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "body\n"; + codeBlock->printSelfInfo(depth + 1); } ReturnEvaluator::ReturnEvaluator(TokenLocation location_, ExprPtr result): @@ -537,13 +562,14 @@ ReturnEvaluator::ReturnEvaluator(TokenLocation location_, ExprPtr result): void ReturnEvaluator::evaluateImpl() const { auto v = result ? result->evaluate() : EvaluationValue{}; + DebugEvaluator{} << getDebugId() << ": returninng " << v; throw ReturnValue{v}; } -void ReturnEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void ReturnEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "return "; - result->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "return "; + result->printSelfInfo(depth + 1); } @@ -557,9 +583,9 @@ void ExpressionAsStatementEvaluator::evaluateImpl() const throw EvaluationFailure{} << "unsatisfied wait object is going out of scope, didn't you forget to apply -> to it"; } -void ExpressionAsStatementEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void ExpressionAsStatementEvaluator::printSelfInfo(unsigned int depth) const { - expr->printSelfInfo(os, depth); + expr->printSelfInfo(depth); } @@ -573,11 +599,11 @@ void BlockEvaluator::evaluateImpl() const b->evaluate(); } -void BlockEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void BlockEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "block\n"; + printLocationAndIndent(location(), depth) << "block\n"; for (auto &e : evals) - e->printSelfInfo(os, depth + 1); + e->printSelfInfo(depth + 1); } @@ -593,20 +619,23 @@ void WaitEvaluator::evaluateImpl() const auto r = w->evaluate(); waitsValues.push_back(r.convertToWait()); } - if (debugInterface) debugInterface->write("evaluating main block of wait clause"); + DebugEvaluator{} << getDebugId() << ": executing main block of wait clause"; exec->evaluate(); - if (debugInterface) debugInterface->write("joining waiters"); - for (auto &w : waitsValues) { + DebugEvaluator{} << getDebugId() << ": joining waiters (" << waits.size() << ")"; + for (auto i = 0u; i < waits.size(); ++i) { + DebugEvaluator{} << getDebugId() << ": joining waiter " << i << " from " << waits[i]->getDebugId(); + auto &w = waitsValues[i]; w.asWait()->join(); } + DebugEvaluator{} << getDebugId() << ": done"; } -void WaitEvaluator::printSelfInfo(std::ostringstream &os, unsigned int depth) const +void WaitEvaluator::printSelfInfo(unsigned int depth) const { - printLocationAndIndent(os, location(), depth) << "wait\n"; - exec->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "wait\n"; + exec->printSelfInfo(depth + 1); for (auto &w : waits) { - printLocationAndIndent(os, location(), depth) << "for\n"; - w->printSelfInfo(os, depth + 1); + printLocationAndIndent(location(), depth) << "for\n"; + w->printSelfInfo(depth + 1); } } diff --git a/src/batch/Evaluator.hpp b/src/batch/Evaluator.hpp index 99a6257..ef0e47d 100644 --- a/src/batch/Evaluator.hpp +++ b/src/batch/Evaluator.hpp @@ -23,17 +23,17 @@ #include #include #include +#include +#include class EvaluationValue; +class DebugEvaluator; /** * @brief Class for printing debug information, when evaluation batch */ struct DebugEvaluatorInterface { - /** - * @brief Single line of debug text, without end of line character - */ - virtual void write(const std::string &txt) = 0; + friend class DebugEvaluator; /** * @brief Sets current debug interface. @@ -45,22 +45,25 @@ struct DebugEvaluatorInterface { */ static void setCurrentInterface(std::unique_ptr inf = {}); static DebugEvaluatorInterface *getCurrentInterface(); +private: + /** + * @brief Single line of debug text, without end of line character + */ + virtual void write_impl(const std::string &txt) = 0; }; class DebugEvaluator { - std::ostringstream tmp; + std::unique_ptr tmp{ new std::ostringstream{} }; public: - DebugEvaluator() = default; - ~DebugEvaluator() - { - auto v = DebugEvaluatorInterface::getCurrentInterface(); - if (v) v->write(tmp.str()); - } + DebugEvaluator(); + DebugEvaluator(DebugEvaluator &&) = default; + DebugEvaluator &operator = (DebugEvaluator &&) = default; + ~DebugEvaluator(); template DebugEvaluator &operator << (T &&t) { - tmp << std::forward(t); + (*tmp) << std::forward(t); return *this; } }; @@ -68,16 +71,16 @@ public: /** * @brief Implementation of DebugEvaluatorInterface streaming in/out messages to stream */ -template struct StreamDebugEvaluatorInterface : public DebugEvaluatorInterface { +struct StreamDebugEvaluatorInterface : public DebugEvaluatorInterface { public: - StreamDebugEvaluatorInterface(T &stream) : stream(stream) { } + StreamDebugEvaluatorInterface(std::ostream &stream) : stream(stream) { } - void write(const std::string &txt) override + void write_impl(const std::string &txt) override { stream << txt << "\n"; } private: - T &stream; + std::ostream &stream; }; /** @@ -102,7 +105,7 @@ public: /** * @brief Virtual debug function, which will print contents of this element and all it's children */ - virtual void printSelfInfo(std::ostringstream &os, unsigned int depth) const = 0; + virtual void printSelfInfo(unsigned int depth) const = 0; /** * @brief Returns unique identifier for this object, for debug purposes @@ -114,7 +117,7 @@ protected: * * End of line (\n) isn't appended. Debug id is added. */ - std::ostringstream &printLocationAndIndent(std::ostringstream &os, const TokenLocation &loc, unsigned int depth) const; + DebugEvaluator printLocationAndIndent(const TokenLocation &loc, unsigned int depth) const; }; /** @@ -191,7 +194,7 @@ protected: public: IdentifierEvaluator(TokenLocation location_, std::string identifier); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -210,7 +213,7 @@ protected: public: AttributeEvaluator(TokenLocation location_, ExprPtr self, std::string identifier); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -229,7 +232,7 @@ protected: public: AttributeSetterEvaluator(TokenLocation location_, ExprPtr self, std::string identifier, ExprPtr value); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -247,7 +250,7 @@ protected: public: SetterEvaluator(TokenLocation location_, std::string identifier, ExprPtr value); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -264,7 +267,7 @@ protected: public: PointEvaluator(TokenLocation location_, ExprPtr x, ExprPtr y); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -278,7 +281,7 @@ protected: public: IntegerEvaluator(TokenLocation location_, int64_t value); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -292,7 +295,7 @@ protected: public: DoubleEvaluator(TokenLocation location_, double value); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -306,7 +309,7 @@ protected: public: BooleanEvaluator(TokenLocation location_, bool value); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -320,7 +323,7 @@ protected: public: StringEvaluator(TokenLocation location_, std::string value); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -340,7 +343,7 @@ public: }; ArraySetDictEvaluator(TokenLocation location_, ExprPtrs values, Kind kind); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; private: ExprPtrs values; Kind kind; @@ -363,7 +366,7 @@ protected: public: CallEvaluator(TokenLocation location_, ExprPtr function, ExprPtrs args, ExprMapPtrs keywordArgs); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -383,7 +386,7 @@ public: }; OperatorEvaluator(TokenLocation location_, ExprPtrs args, Kind kind); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; private: ExprPtrs args; Kind kind; @@ -408,7 +411,7 @@ public: }; CompOperatorEvaluator(TokenLocation location_, ExprPtrs args, std::vector kinds, std::vector locations); - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; private: ExprPtrs args; std::vector kinds; @@ -425,7 +428,7 @@ public: ExpressionAsStatementEvaluator(TokenLocation location_, ExprPtr expr); void evaluateImpl() const override; - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -438,7 +441,7 @@ public: BlockEvaluator(TokenLocation location_, StatPtrs evals); void evaluateImpl() const override; - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -457,7 +460,7 @@ public: WaitEvaluator(TokenLocation location_, StatPtr exec, ExprPtrs waits); void evaluateImpl() const override; - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -472,7 +475,7 @@ public: FunctionEvaluator(TokenLocation location_, std::string functionName, std::vector argNames, StatPtr codeBlock); protected: void evaluateImpl() const override; - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; /** @@ -485,7 +488,7 @@ public: ReturnEvaluator(TokenLocation location_, ExprPtr result); protected: void evaluateImpl() const override; - void printSelfInfo(std::ostringstream &os, unsigned int depth) const override; + void printSelfInfo(unsigned int depth) const override; }; #endif diff --git a/src/batch/batch_exec.sh b/src/batch/batch_exec.sh index c8cff9f..ff938c6 100755 --- a/src/batch/batch_exec.sh +++ b/src/batch/batch_exec.sh @@ -38,7 +38,7 @@ function runTest() { rm -f $OUTPUT app_launcher -t org.tizen.universal-switch - STATUS=$(app_launcher -s org.tizen.universal-switch TESTS_PATH $BATCH_FILE TESTS_OUTPUT $OUTPUT) + STATUS=$(app_launcher -s org.tizen.universal-switch TESTS_PATH $BATCH_FILE TESTS_OUTPUT $OUTPUT TESTS_DEBUG $DEBUG) STATUS2=${STATUS#*successfully launched pid = } PID=${STATUS2% with debug*} @@ -46,6 +46,9 @@ function runTest() cat "$OUTPUT" } +DEBUG=0 +(( "$3" > 1 )) 2>/dev/null && DEBUG="$3" + REPEAT=1 (( "$2" > 1 )) 2>/dev/null && REPEAT="$2" diff --git a/src/batch/run-batch.sh b/src/batch/run-batch.sh index c03be41..88a3cba 100755 --- a/src/batch/run-batch.sh +++ b/src/batch/run-batch.sh @@ -8,6 +8,7 @@ SCRIPT_DIRNAME=$(dirname "$SCRIPT") BATCH_PATTERN='*.rdl' PERMISSIONS=User::Pkg::org.tizen.universal-switch::RO REPEAT="$2" +DEBUG="$3" TMP=$(mktemp -d) echo "tmp dir: $TMP" @@ -25,7 +26,7 @@ cd $(dirname "$SCRIPT") cd ../.. ./project-tool -j -sdb shell "cd $TMP; /bin/bash batch_exec.sh $TMP/$BATCH_BASENAME $REPEAT ; echo done" +sdb shell "cd $TMP; /bin/bash batch_exec.sh $TMP/$BATCH_BASENAME $REPEAT $DEBUG ; echo done" rm -r "$TMP" sdb shell "rm -r $TMP" \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index c6fb0bb..156ba92 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -91,6 +91,6 @@ int main(int argc, char *argv[]) ui_app_add_event_handler(&handler, APP_EVENT_LANGUAGE_CHANGED, _setting_time_lang_changed, nullptr); auto result = ui_app_main(argc, argv, &event_callback, &data); - DEBUG("main function done"); + DEBUG("main function done (%d)", result); return result; } diff --git a/tests/no-ui-scenarios/BatchExecTests.cpp b/tests/no-ui-scenarios/BatchExecTests.cpp index acd3152..a203b73 100644 --- a/tests/no-ui-scenarios/BatchExecTests.cpp +++ b/tests/no-ui-scenarios/BatchExecTests.cpp @@ -205,8 +205,9 @@ protected: if (!errors.empty()) { if (printException) { std::ostringstream tmp; - result->printSelfInfo(tmp, 0); - std::cout << tmp.str(); + DebugEvaluatorInterface::setCurrentInterface(std::make_unique(std::cout)); + result->printSelfInfo(0); + DebugEvaluatorInterface::setCurrentInterface(nullptr); for (auto &e : errors) { std::cout << e << "\n"; } -- 2.7.4