parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [parquet-cpp] branch master updated: PARQUET-1255: Fix error message when PARQUET_TEST_DATA isn't defined
Date Wed, 28 Mar 2018 16:20:07 GMT
This is an automated email from the ASF dual-hosted git repository.

uwe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-cpp.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e7ef12  PARQUET-1255: Fix error message when PARQUET_TEST_DATA isn't defined
4e7ef12 is described below

commit 4e7ef12dccb250074370376dc31a4963e1010447
Author: Antoine Pitrou <antoine@python.org>
AuthorDate: Wed Mar 28 18:19:53 2018 +0200

    PARQUET-1255: Fix error message when PARQUET_TEST_DATA isn't defined
    
    Author: Antoine Pitrou <antoine@python.org>
    
    Closes #448 from pitrou/PARQUET-1255 and squashes the following commits:
    
    b162511 [Antoine Pitrou] PARQUET-1255: Fix error message when PARQUET_TEST_DATA isn't
defined
---
 src/parquet/arrow/arrow-reader-writer-test.cc |  7 ++++---
 src/parquet/reader-test.cc                    |  9 ++++-----
 src/parquet/util/test-common.h                | 15 +++++++++++++++
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/parquet/arrow/arrow-reader-writer-test.cc b/src/parquet/arrow/arrow-reader-writer-test.cc
index 46218be..79a393f 100644
--- a/src/parquet/arrow/arrow-reader-writer-test.cc
+++ b/src/parquet/arrow/arrow-reader-writer-test.cc
@@ -39,6 +39,8 @@
 
 #include "parquet/file_writer.h"
 
+#include "parquet/util/test-common.h"
+
 #include "arrow/api.h"
 #include "arrow/test-util.h"
 #include "arrow/type_traits.h"
@@ -2100,8 +2102,7 @@ TEST(TestImpalaConversion, NanosecondToImpala) {
 
 TEST(TestArrowReaderAdHoc, Int96BadMemoryAccess) {
   // PARQUET-995
-  const char* data_dir = std::getenv("PARQUET_TEST_DATA");
-  std::string dir_string(data_dir);
+  std::string dir_string(test::get_data_dir());
   std::stringstream ss;
   ss << dir_string << "/"
      << "alltypes_plain.parquet";
@@ -2121,7 +2122,7 @@ class TestArrowReaderAdHocSpark
           std::tuple<std::string, std::shared_ptr<::DataType>>> {};
 
 TEST_P(TestArrowReaderAdHocSpark, ReadDecimals) {
-  std::string path(std::getenv("PARQUET_TEST_DATA"));
+  std::string path(test::get_data_dir());
 
   std::string filename;
   std::shared_ptr<::DataType> decimal_type;
diff --git a/src/parquet/reader-test.cc b/src/parquet/reader-test.cc
index c536fdc..d628f47 100644
--- a/src/parquet/reader-test.cc
+++ b/src/parquet/reader-test.cc
@@ -30,6 +30,7 @@
 #include "parquet/file_reader.h"
 #include "parquet/printer.h"
 #include "parquet/util/memory.h"
+#include "parquet/util/test-common.h"
 
 using std::string;
 
@@ -37,10 +38,8 @@ namespace parquet {
 
 using ReadableFile = ::arrow::io::ReadableFile;
 
-const char* data_dir = std::getenv("PARQUET_TEST_DATA");
-
 std::string alltypes_plain() {
-  std::string dir_string(data_dir);
+  std::string dir_string(test::get_data_dir());
   std::stringstream ss;
   ss << dir_string << "/"
      << "alltypes_plain.parquet";
@@ -48,7 +47,7 @@ std::string alltypes_plain() {
 }
 
 std::string nation_dict_truncated_data_page() {
-  std::string dir_string(data_dir);
+  std::string dir_string(test::get_data_dir());
   std::stringstream ss;
   ss << dir_string << "/"
      << "nation.dict-malformed.parquet";
@@ -171,7 +170,7 @@ TEST_F(TestAllTypesPlain, ColumnSelectionOutOfRange) {
 class TestLocalFile : public ::testing::Test {
  public:
   void SetUp() {
-    std::string dir_string(data_dir);
+    std::string dir_string(test::get_data_dir());
 
     std::stringstream ss;
     ss << dir_string << "/"
diff --git a/src/parquet/util/test-common.h b/src/parquet/util/test-common.h
index ebf4851..22b748e 100644
--- a/src/parquet/util/test-common.h
+++ b/src/parquet/util/test-common.h
@@ -23,6 +23,7 @@
 #include <random>
 #include <vector>
 
+#include "parquet/exception.h"
 #include "parquet/types.h"
 
 using std::vector;
@@ -35,6 +36,20 @@ typedef ::testing::Types<BooleanType, Int32Type, Int64Type, Int96Type,
FloatType
                          DoubleType, ByteArrayType, FLBAType>
     ParquetTypes;
 
+class ParquetTestException : public parquet::ParquetException {
+  using ParquetException::ParquetException;
+};
+
+const char* get_data_dir() {
+  const auto result = std::getenv("PARQUET_TEST_DATA");
+  if (!result || !result[0]) {
+    throw ParquetTestException(
+        "Please point the PARQUET_TEST_DATA environment "
+        "variable to the test data directory");
+  }
+  return result;
+}
+
 template <typename T>
 static inline void assert_vector_equal(const vector<T>& left, const vector<T>&
right) {
   ASSERT_EQ(left.size(), right.size());

-- 
To stop receiving notification emails like this one, please contact
uwe@apache.org.

Mime
View raw message