Skip to content

Commit

Permalink
PARQUET-437: Add googletest setup and ADD_PARQUET_TEST helper
Browse files Browse the repository at this point in the history
I adapted this functionality from Apache Kudu (incubating). There are no real unit tests, yet, but you can now run `ctest` after building to run all tests that have been created with `ADD_PARQUET_TEST`.

Author: Wes McKinney <wes@cloudera.com>

Closes apache#19 from wesm/googletest-infra and squashes the following commits:

758328f [Wes McKinney] BLD: disable fixed OSX deployment target. Compile gtest with -fPIC
61cc5bb [Wes McKinney] Remove 'set -e' from setup_build_env.sh
6435970 [Wes McKinney] Fix setup_build_env.sh script
a54a219 [Wes McKinney] Add googletest to thirdparty and add ADD_PARQUET_TEST cmake helper and support scripts for using ctest after make

Change-Id: I7e86dfc9ae2590d8053ffe3dc687f78008faf3b2
  • Loading branch information
wesm authored and nongli committed Jan 26, 2016
1 parent 5f91b2a commit 21ec900
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 11 deletions.
27 changes: 16 additions & 11 deletions cpp/src/parquet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Copyright 2015 Cloudera Inc.
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Headers: top level
install(FILES
parquet.h
DESTINATION include/parquet)

ADD_PARQUET_TEST(reader-test)
26 changes: 26 additions & 0 deletions cpp/src/parquet/reader-test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

#include <gtest/gtest.h>

namespace parquet {

TEST(TestReader, ItWorks) {
ASSERT_TRUE(true);
}

} // namespace parquet
17 changes: 17 additions & 0 deletions cpp/src/parquet/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,20 @@ install(FILES
rle-encoding.h
stopwatch.h
DESTINATION include/parquet/util)

add_library(parquet_test_main
test_main.cc)

if (APPLE)
target_link_libraries(parquet_test_main
gtest
dl)
set_target_properties(parquet_test_main
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
target_link_libraries(parquet_test_main
dl
gtest
pthread
)
endif()
26 changes: 26 additions & 0 deletions cpp/src/parquet/util/test_main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

#include <gtest/gtest.h>

int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);

int ret = RUN_ALL_TESTS();

return ret;
}

0 comments on commit 21ec900

Please sign in to comment.