diff options
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | src/buildtool/main/serve.cpp | 3 | ||||
-rw-r--r-- | test/buildtool/storage/large_object_cas.test.cpp | 51 | ||||
-rw-r--r-- | test/other_tools/git_operations/git_config_run.test.cpp | 2 |
4 files changed, 29 insertions, 28 deletions
diff --git a/.clang-tidy b/.clang-tidy index 9f13baa6..2b866f78 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,6 +6,7 @@ WarningsAsErrors: >- clang-analyzer-*,-clang-analyzer-cplusplus.NewDeleteLeaks, clang-diagnostic-*,-clang-diagnostic-unused-command-line-argument, concurrency-*, -concurrency-mt-unsafe, + google-*, hicpp-*, modernize-*,-modernize-return-braced-init-list, performance-*,-performance-avoid-endl, diff --git a/src/buildtool/main/serve.cpp b/src/buildtool/main/serve.cpp index 29bff253..1ee80349 100644 --- a/src/buildtool/main/serve.cpp +++ b/src/buildtool/main/serve.cpp @@ -467,7 +467,8 @@ void ReadJustServeConfig(gsl::not_null<CommandLineArguments*> const& clargs) { std::exit(kExitFailure); } clargs->build.timeout = - std::size_t(timeout->Number()) * std::chrono::seconds{1}; + static_cast<std::size_t>(timeout->Number()) * + std::chrono::seconds{1}; } // read target-cache writing strategy auto strategy = build_args->Get("target-cache write strategy", diff --git a/test/buildtool/storage/large_object_cas.test.cpp b/test/buildtool/storage/large_object_cas.test.cpp index a7dff9a7..ab4d0715 100644 --- a/test/buildtool/storage/large_object_cas.test.cpp +++ b/test/buildtool/storage/large_object_cas.test.cpp @@ -45,14 +45,14 @@ namespace LargeTestUtils { template <bool IsExecutable> class Blob final { public: - static constexpr auto kLargeId = std::string_view("bl_8Mb"); - static constexpr auto kLargeSize = std::uintmax_t(8UL * 1024 * 1024); + static constexpr auto kLargeId = "bl_8Mb"; + static constexpr std::uintmax_t kLargeSize = 8UL * 1024 * 1024; - static constexpr auto kSmallId = std::string_view("bl_1kB"); - static constexpr auto kSmallSize = std::uintmax_t(1024); + static constexpr auto kSmallId = "bl_1kB"; + static constexpr std::uintmax_t kSmallSize = 1024; - static constexpr auto kEmptyId = std::string_view("bl_0"); - static constexpr auto kEmptySize = std::uintmax_t(0); + static constexpr auto kEmptyId = "bl_0"; + static constexpr std::uintmax_t kEmptySize = 0; [[nodiscard]] static auto Create( LocalCAS<kDefaultDoGlobalUplink> const& cas, @@ -69,14 +69,14 @@ using File = Blob<false>; class Tree final { public: - static constexpr auto kLargeId = std::string_view("tree_4096"); - static constexpr auto kLargeSize = std::uintmax_t(4096); + static constexpr auto kLargeId = "tree_4096"; + static constexpr std::uintmax_t kLargeSize = 4096; - static constexpr auto kSmallId = std::string_view("tree_1"); - static constexpr auto kSmallSize = std::uintmax_t(1); + static constexpr auto kSmallId = "tree_1"; + static constexpr std::uintmax_t kSmallSize = 1; - static constexpr auto kEmptyId = std::string_view("tree_0"); - static constexpr auto kEmptySize = std::uintmax_t(0); + static constexpr auto kEmptyId = "tree_0"; + static constexpr std::uintmax_t kEmptySize = 0; [[nodiscard]] static auto Create( LocalCAS<kDefaultDoGlobalUplink> const& cas, @@ -105,8 +105,7 @@ TEST_CASE("LargeObjectCAS: split a small tree", "[storage]") { // Create a small tree: using LargeTestUtils::Tree; - auto small = - Tree::Create(cas, std::string(Tree::kSmallId), Tree::kSmallSize); + auto small = Tree::Create(cas, Tree::kSmallId, Tree::kSmallSize); REQUIRE(small); auto const& [digest, path] = *small; @@ -137,8 +136,8 @@ static void TestLarge(StorageConfig const& storage_config, auto const& cas = storage.CAS(); // Create a large object: - auto object = TestType::Create( - cas, std::string(TestType::kLargeId), TestType::kLargeSize); + auto object = + TestType::Create(cas, TestType::kLargeId, TestType::kLargeSize); CHECK(object); auto const& [digest, path] = *object; @@ -224,8 +223,8 @@ static void TestSmall(Storage const& storage) noexcept { auto const& cas = storage.CAS(); // Create a small object: - auto object = TestType::Create( - cas, std::string(TestType::kSmallId), TestType::kSmallSize); + auto object = + TestType::Create(cas, TestType::kSmallId, TestType::kSmallSize); CHECK(object); auto const& [digest, path] = *object; @@ -279,7 +278,7 @@ static void TestEmpty(Storage const& storage) noexcept { // Create an empty file: auto temp_path = LargeTestUtils::Blob</*kIsExec=*/false>::Generate( - std::string(TestType::kEmptyId), TestType::kEmptySize); + TestType::kEmptyId, TestType::kEmptySize); REQUIRE(temp_path); auto const& cas = storage.CAS(); @@ -336,8 +335,8 @@ static void TestExternal(StorageConfig const& storage_config, auto const& cas = storage.CAS(); // Create a large object: - auto object = TestType::Create( - cas, std::string(TestType::kLargeId), TestType::kLargeSize); + auto object = + TestType::Create(cas, TestType::kLargeId, TestType::kLargeSize); CHECK(object); auto const& [digest, path] = *object; @@ -383,8 +382,8 @@ static void TestExternal(StorageConfig const& storage_config, REQUIRE(*implicit_splice == path); // Randomize one more object to simulate invalidation: - auto small = TestType::Create( - cas, std::string(TestType::kSmallId), TestType::kSmallSize); + auto small = + TestType::Create(cas, TestType::kSmallId, TestType::kSmallSize); REQUIRE(small); auto const& [small_digest, small_path] = *small; @@ -437,8 +436,8 @@ static void TestCompactification(StorageConfig const& storage_config, auto const& cas = storage.CAS(); // Create a large object and split it: - auto object = TestType::Create( - cas, std::string(TestType::kLargeId), TestType::kLargeSize); + auto object = + TestType::Create(cas, TestType::kLargeId, TestType::kLargeSize); REQUIRE(object); auto& [digest, path] = *object; auto result = kIsTree ? cas.SplitTree(digest) : cas.SplitBlob(digest); @@ -543,7 +542,7 @@ TEST_CASE("LargeObjectCAS: uplink nested large objects", "[storage]") { // Randomize a large directory: auto tree_path = LargeTestUtils::Tree::Generate( - std::string("nested_tree"), LargeTestUtils::Tree::kLargeSize); + "nested_tree", LargeTestUtils::Tree::kLargeSize); REQUIRE(tree_path); // Randomize a large nested tree: diff --git a/test/other_tools/git_operations/git_config_run.test.cpp b/test/other_tools/git_operations/git_config_run.test.cpp index 1e72c7da..57380280 100644 --- a/test/other_tools/git_operations/git_config_run.test.cpp +++ b/test/other_tools/git_operations/git_config_run.test.cpp @@ -60,7 +60,7 @@ auto main(int argc, char* argv[]) -> int { argc); return 1; } - auto args = std::span(argv, size_t(argc)); + auto args = std::span(argv, static_cast<std::size_t>(argc)); std::string test_type{args[1]}; // type of test std::string test_url{args[2]}; // remote URL to test |