github-actions[bot] commented on code in PR #18009: URL: https://github.com/apache/doris/pull/18009#discussion_r1144227434
########## be/src/io/fs/file_system.h: ########## @@ -29,6 +29,23 @@ namespace doris { namespace io { +#ifndef FILESYSTEM_M +#define FILESYSTEM_M(stmt) \ Review Comment: warning: macro is not used [clang-diagnostic-unused-macros] ```cpp #define FILESYSTEM_M(stmt) \ ^ ``` ########## be/test/io/fs/local_file_system_test.cpp: ########## @@ -0,0 +1,460 @@ +// 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 "io/fs/local_file_system.h" + +#include <algorithm> +#include <filesystem> +#include <fstream> +#include <set> +#include <vector> + +#include "common/status.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "io/fs/file_reader.h" +#include "io/fs/file_writer.h" + +namespace doris { + +class LocalFileSystemTest : public testing::Test { +public: + virtual void SetUp() { + EXPECT_TRUE( + io::global_local_filesystem()->delete_and_create_directory(_s_test_data_path).ok()); + } + + Status save_string_file(const std::filesystem::path& filename, const std::string& content) { + io::FileWriterPtr file_writer; + RETURN_IF_ERROR(io::global_local_filesystem()->create_file(filename, &file_writer)); + RETURN_IF_ERROR(file_writer->append(content)); + return file_writer->close(); + } + + bool check_exists(const std::string& file) { + bool exists = true; + EXPECT_TRUE(io::global_local_filesystem()->exists(file, &exists).ok()); + return exists; + } + + bool is_dir(const std::string& path) { + bool is_dir = true; + EXPECT_TRUE(io::global_local_filesystem()->is_directory(path, &is_dir).ok()); + return is_dir; + } + + Status list_dirs_files(const std::string& path, std::vector<std::string>* dirs, + std::vector<std::string>* files) { + bool only_file = true; + if (dirs != nullptr) { + only_file = false; + } + std::vector<io::FileInfo> file_infos; + bool exists = true; + RETURN_IF_ERROR(io::global_local_filesystem()->list(path, only_file, &file_infos, &exists)); + for (auto& file_info : file_infos) { + if (file_info.is_file && files != nullptr) { + files->push_back(file_info.file_name); + } + if (!file_info.is_file && dirs != nullptr) { + dirs->push_back(file_info.file_name); + } + } + return Status::OK(); + } + + Status delete_file_paths(const std::vector<std::string>& ps) { + for (auto& p : ps) { + bool exists = true; + RETURN_IF_ERROR(io::global_local_filesystem()->exists(p, &exists)); + if (!exists) { + continue; + } + bool is_dir = true; + RETURN_IF_ERROR(io::global_local_filesystem()->is_directory(p, &is_dir)); + if (is_dir) { + RETURN_IF_ERROR(io::global_local_filesystem()->delete_directory(p)); + } else { + RETURN_IF_ERROR(io::global_local_filesystem()->delete_file(p)); + } + } + return Status::OK(); + } + + // delete the mock cgroup folder Review Comment: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override] ```suggestion void TearDown() override { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org