You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by fo...@apache.org on 2018/11/11 19:03:10 UTC
[avro] branch master updated: Fix for C++ tests to run on Docker
(#369)
This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new bb6a79e Fix for C++ tests to run on Docker (#369)
bb6a79e is described below
commit bb6a79ea79315037956c1665b83b8c80a3016c73
Author: Thiruvalluvan M G <th...@apache.org>
AuthorDate: Mon Nov 12 00:33:05 2018 +0530
Fix for C++ tests to run on Docker (#369)
* Made the C++ build work in Docker
* Modified docker to run all tests including C++ ones
* Re-enabled C++ build
---
build.sh | 2 +-
lang/c++/CMakeLists.txt | 2 +-
lang/c++/api/AvroTraits.hh | 9 +++++----
lang/c++/impl/Compiler.cc | 36 ------------------------------------
lang/c++/impl/DataFile.cc | 1 -
lang/c++/impl/NodeImpl.cc | 21 +++++++++++----------
lang/c++/test/CodecTests.cc | 3 +--
lang/c++/test/unittest.cc | 1 +
share/docker/run-tests.sh | 9 +--------
9 files changed, 21 insertions(+), 63 deletions(-)
diff --git a/build.sh b/build.sh
index 9ce4ae6..0dc4788 100755
--- a/build.sh
+++ b/build.sh
@@ -50,7 +50,7 @@ do
(cd lang/py; ./build.sh test)
(cd lang/py3; ./build.sh test)
(cd lang/c; ./build.sh test)
- #(cd lang/c++; ./build.sh test)
+ (cd lang/c++; ./build.sh test)
(cd lang/csharp; ./build.sh test)
(cd lang/js; ./build.sh test)
(cd lang/ruby; ./build.sh test)
diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt
index 8919fc3..4b96764 100644
--- a/lang/c++/CMakeLists.txt
+++ b/lang/c++/CMakeLists.txt
@@ -62,7 +62,7 @@ endif ()
find_package (Boost 1.38 REQUIRED
- COMPONENTS filesystem system program_options iostreams)
+ COMPONENTS filesystem iostreams program_options regex system)
find_package(Snappy)
if (SNAPPY_FOUND)
diff --git a/lang/c++/api/AvroTraits.hh b/lang/c++/api/AvroTraits.hh
index acf6ff7..01423cc 100644
--- a/lang/c++/api/AvroTraits.hh
+++ b/lang/c++/api/AvroTraits.hh
@@ -22,6 +22,7 @@
#include "Config.hh"
#include "Boost.hh"
#include "Types.hh"
+#include <stdint.h>
/** @file
*
@@ -58,9 +59,9 @@ struct is_defined {
typedef char no[2];
- template <class U> static yes& test(char(*)[sizeof(U)]) { };
+ template <class U> static yes& test(char(*)[sizeof(U)]) { throw 0; };
- template <class U> static no& test(...) { };
+ template <class U> static no& test(...) { throw 0; };
static const bool value = sizeof(test<T>(0)) == sizeof(yes);
};
@@ -78,9 +79,9 @@ struct is_not_defined {
typedef char no[2];
- template <class U> static yes& test(char(*)[sizeof(U)]) { };
+ template <class U> static yes& test(char(*)[sizeof(U)]) { throw 0; };
- template <class U> static no& test(...) { };
+ template <class U> static no& test(...) { throw 0; };
static const bool value = sizeof(test<T>(0)) == sizeof(no);
};
diff --git a/lang/c++/impl/Compiler.cc b/lang/c++/impl/Compiler.cc
index 58c3ef3..725136d 100644
--- a/lang/c++/impl/Compiler.cc
+++ b/lang/c++/impl/Compiler.cc
@@ -171,42 +171,6 @@ static vector<uint8_t> toBin(const std::string& s)
return result;
}
-static string nameof(const NodePtr& n)
-{
- Type t = n->type();
- switch (t) {
- case AVRO_STRING:
- return "string";
- case AVRO_BYTES:
- return "bytes";
- case AVRO_INT:
- return "int";
- case AVRO_LONG:
- return "long";
- case AVRO_FLOAT:
- return "float";
- case AVRO_DOUBLE:
- return "double";
- case AVRO_BOOL:
- return "boolean";
- case AVRO_NULL:
- return "null";
- case AVRO_RECORD:
- case AVRO_ENUM:
- case AVRO_FIXED:
- case AVRO_SYMBOLIC:
- return n->name().fullname();
- case AVRO_ARRAY:
- return "array";
- case AVRO_MAP:
- return "map";
- case AVRO_UNION:
- return "union";
- default:
- throw Exception(boost::format("Unknown type: %1%") % t);
- }
-}
-
static GenericDatum makeGenericDatum(NodePtr n,
const Entity& e, const SymbolTable& st)
{
diff --git a/lang/c++/impl/DataFile.cc b/lang/c++/impl/DataFile.cc
index 56ec619..a71860d 100644
--- a/lang/c++/impl/DataFile.cc
+++ b/lang/c++/impl/DataFile.cc
@@ -54,7 +54,6 @@ const string AVRO_SNAPPY_CODEC = "snappy";
const size_t minSyncInterval = 32;
const size_t maxSyncInterval = 1u << 30;
-const size_t defaultSyncInterval = 64 * 1024;
boost::iostreams::zlib_params get_zlib_params() {
boost::iostreams::zlib_params ret;
diff --git a/lang/c++/impl/NodeImpl.cc b/lang/c++/impl/NodeImpl.cc
index 1969406..50b7fba 100644
--- a/lang/c++/impl/NodeImpl.cc
+++ b/lang/c++/impl/NodeImpl.cc
@@ -21,12 +21,13 @@
#include "NodeImpl.hh"
+using std::string;
namespace avro {
namespace {
// Escape string for serialization.
-std::string escape(const std::string &unescaped) {
- std::string s;
+string escape(const string &unescaped) {
+ string s;
s.reserve(unescaped.length());
for (std::string::const_iterator it = unescaped.begin(); it != unescaped.end(); ++it) {
char c = *it;
@@ -79,7 +80,7 @@ struct indent {
/// ostream operator for indent
std::ostream& operator <<(std::ostream &os, indent x)
{
- static const std::string spaces(" ");
+ static const string spaces(" ");
while (x.d--) {
os << spaces;
}
@@ -242,11 +243,11 @@ NodeRecord::printJson(std::ostream &os, int depth) const
printName(os, nameAttribute_.get(), depth);
os << indent(depth) << "\"fields\": [";
- int fields = leafAttributes_.size();
+ size_t fields = leafAttributes_.size();
++depth;
// Serialize "default" field:
assert(defaultValues.empty() || (defaultValues.size() == fields));
- for (int i = 0; i < fields; ++i) {
+ for (size_t i = 0; i < fields; ++i) {
if (i > 0) {
os << ',';
}
@@ -296,15 +297,15 @@ void NodePrimitive::printDefaultToJson(const GenericDatum &g, std::ostream &os,
os << g.value<double>();
break;
case AVRO_STRING:
- os << "\"" << escape(g.value<std::string>()) << "\"";
+ os << "\"" << escape(g.value<string>()) << "\"";
break;
case AVRO_BYTES: {
// Convert to a string:
const std::vector<uint8_t> &vg = g.value<std::vector<uint8_t> >();
- std::string s;
+ string s;
s.resize(vg.size() * kByteStringSize);
for (unsigned int i = 0; i < vg.size(); i++) {
- std::string hex_string = intToHex(static_cast<int>(vg[i]));
+ string hex_string = intToHex(static_cast<int>(vg[i]));
s.replace(i*kByteStringSize, kByteStringSize, hex_string);
}
os << "\"" << s << "\"";
@@ -326,10 +327,10 @@ void NodeFixed::printDefaultToJson(const GenericDatum &g, std::ostream &os,
// ex: "\uOOff"
// Convert to a string
const std::vector<uint8_t> &vg = g.value<GenericFixed>().value();
- std::string s;
+ string s;
s.resize(vg.size() * kByteStringSize);
for (unsigned int i = 0; i < vg.size(); i++) {
- std::string hex_string = intToHex(static_cast<int>(vg[i]));
+ string hex_string = intToHex(static_cast<int>(vg[i]));
s.replace(i*kByteStringSize, kByteStringSize, hex_string);
}
os << "\"" << s << "\"";
diff --git a/lang/c++/test/CodecTests.cc b/lang/c++/test/CodecTests.cc
index 5fcfb61..57b546a 100644
--- a/lang/c++/test/CodecTests.cc
+++ b/lang/c++/test/CodecTests.cc
@@ -1425,8 +1425,7 @@ static const TestData4 data4BinaryOnly[] = {
// helper functions leads to names which compose 'testFunc', 'Factory', and
// 'data'.
template <typename Test, typename Data>
-Test testWithData(const Test &test, const Data &data) {
- boost::ignore_unused(data);
+Test testWithData(const Test &test, const Data &) {
return test;
}
#define ADD_TESTS(testSuite, Factory, testFunc, data) \
diff --git a/lang/c++/test/unittest.cc b/lang/c++/test/unittest.cc
index 8349314..55a33a0 100644
--- a/lang/c++/test/unittest.cc
+++ b/lang/c++/test/unittest.cc
@@ -20,6 +20,7 @@
#include <fstream>
#include <sstream>
#include <boost/test/included/unit_test_framework.hpp>
+#include <boost/make_shared.hpp>
#include "Zigzag.hh"
#include "Node.hh"
diff --git a/share/docker/run-tests.sh b/share/docker/run-tests.sh
index e9919a7..fd4b388 100755
--- a/share/docker/run-tests.sh
+++ b/share/docker/run-tests.sh
@@ -27,12 +27,5 @@ for lang in /avro/lang/*/
do
headline "Run tests: $lang"
cd "$lang"
-
- if [[ "$lang" = *"c++"* ]]; then
- # The current cpp tests are failing:
- # https://issues.apache.org/jira/projects/AVRO/issues/AVRO-2230
- ./build.sh test || true
- else
- ./build.sh test
- fi
+ ./build.sh test
done