From eaf5a4152b992ad191adc7f6539572c25f5ca715 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 24 May 2017 08:59:39 +0300 Subject: [PATCH] MXS-1196: Handle eol-comments Eol-comments need to be followed by a newline as otherwise the rest of a test-statement will be excluded. --- query_classifier/test/testreader.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/query_classifier/test/testreader.cc b/query_classifier/test/testreader.cc index 36a0101a4..4de222539 100644 --- a/query_classifier/test/testreader.cc +++ b/query_classifier/test/testreader.cc @@ -290,6 +290,28 @@ TestReader::result_t TestReader::get_statement(std::string& stmt) stmt += line; + // Look for a ';'. If we are dealing with a one line test statment + // the delimiter will in practice be ';' and if it is a multi-line + // test statement then the test-script delimiter will be something + // else than ';' and ';' will be the delimiter used in the multi-line + // statement. + string::size_type i = line.find(";"); + + if (i != string::npos) + { + // Is there a "-- " or "#" after the delimiter? + if ((line.find("-- ", i) != string::npos) || + (line.find("#", i) != string::npos)) + { + // If so, add a newline. Otherwise the rest of the + // statement would be included in the comment. + stmt += "\n"; + } + + // This is somewhat fragile as a ";", "#" or "-- " inside a + // string will trigger this behaviour... + } + string c; if (line.length() >= m_delimiter.length())