Skip to content
Permalink
Browse files
Added clang-format and clang-tidy files. Added clang-tidy to the buil…
…d. (#54)

* Added clang-format and clang-tidy files.  Added clang-tidy to the build.

* Added copyright to .clang-tidy

* Wrapped duplicated cmake code into helper function.  Got rid of defunct lint target
  • Loading branch information
westonpace committed Sep 1, 2021
1 parent 54d0272 commit 4f086b0f0c77dd0654bc8c626af92349dba5583e
Showing 5 changed files with 81 additions and 36 deletions.
@@ -0,0 +1,20 @@
# 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.
---
BasedOnStyle: Google
DerivePointerAlignment: false
ColumnLimit: 90
@@ -0,0 +1,21 @@
# 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.
---
Checks: '*,-llvmlibc*,-cert-err58-cpp,-modernize-use-trailing-return-type,-fuchsia-*,-cppcoreguidelines-*,
-readability-magic-numbers,-clang-analyzer-cplusplus.NewDelete,-clang-analyzer-cplusplus.NewDeleteLeaks'
WarningsAsErrors: '*'
FormatStyle: 'file'
@@ -6,9 +6,9 @@ set(CMAKE_CXX_STANDARD 17)
# Add googletest
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release-1.11.0
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release-1.11.0
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
@@ -17,31 +17,33 @@ FetchContent_MakeAvailable(googletest)
# Add Arrow
find_package(Arrow REQUIRED)

set(CMAKE_CXX_CLANG_TIDY "clang-tidy")

# Create test targets
enable_testing()

include(GoogleTest)
add_executable(
creating_arrow_objects
creating_arrow_objects.cc
common.cc
main.cc
)
target_link_libraries(
creating_arrow_objects
arrow_shared
gtest
)
gtest_discover_tests(creating_arrow_objects)

add_executable(
basic_arrow
basic_arrow.cc
common.cc
main.cc
)
target_link_libraries(
basic_arrow
arrow_shared
gtest
)
gtest_discover_tests(basic_arrow)
function(RECIPE TARGET)
add_executable(
${TARGET}
${TARGET}.cc
common.cc
main.cc
)
target_link_libraries(
${TARGET}
arrow_shared
gtest
)
if (MSVC)
target_compile_options(${TARGET} PRIVATE /W4 /WX)
else ()
target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif ()

gtest_discover_tests(${TARGET})
endfunction()

recipe(basic_arrow)
recipe(creating_arrow_objects)
@@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.

#include "common.h"

#include <sstream>
#include <unordered_map>

@@ -23,8 +25,6 @@
#include "arrow/ipc/api.h"
#include "gtest/gtest.h"

#include "common.h"

static arrow::StringBuilder test_names_builder;
static arrow::StringBuilder test_output_builder;
static std::string current_recipe;
@@ -121,13 +121,14 @@ void PopulateMap(const arrow::Table& table,
}

arrow::Result<std::shared_ptr<arrow::Table>> MergeRecipeTables(
std::shared_ptr<arrow::Table> old_table, std::shared_ptr<arrow::Table> new_table) {
const std::shared_ptr<arrow::Table>& old_table,
const std::shared_ptr<arrow::Table>& new_table) {
std::unordered_map<std::string, std::string> values;
PopulateMap(*old_table, &values);
PopulateMap(*new_table, &values);
arrow::StringBuilder names_builder;
arrow::StringBuilder outputs_builder;
for (auto pair : values) {
for (const auto& pair : values) {
ARROW_RETURN_NOT_OK(names_builder.Append(pair.first));
ARROW_RETURN_NOT_OK(outputs_builder.Append(pair.second));
}
@@ -18,19 +18,20 @@
#ifndef ARROW_COOKBOOK_COMMON_H
#define ARROW_COOKBOOK_COMMON_H

#include <sstream>
#include <string>

#include <arrow/result.h>
#include <arrow/status.h>

#include <sstream>
#include <string>

#define ARROW_STRINGIFY(x) #x
#define ARROW_CONCAT(x, y) x##y

#define ARROW_ASSIGN_OR_RAISE_NAME(x, y) ARROW_CONCAT(x, y)

#define ASSERT_OK(expr) \
for (::arrow::Status _st = ::arrow::internal::GenericToStatus((expr)); !_st.ok();) \
#define ASSERT_OK(expr) \
for (const ::arrow::Status& _st = ::arrow::internal::GenericToStatus((expr)); \
!_st.ok();) \
FAIL() << "'" ARROW_STRINGIFY(expr) "' failed with " << _st.ToString()

#define ASSIGN_OR_HANDLE_ERROR_IMPL(handle_error, status_name, lhs, rexpr) \

0 comments on commit 4f086b0

Please sign in to comment.