From 6bf350c8f5e784cf34bd6cd6776fc8c66babe8c5 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Mon, 21 Jul 2025 13:17:26 +0200 Subject: [PATCH] chore: Finalize renaming of namespaces to lowercase --- CONTRIBUTING.md | 3 +- src/ccache/argprocessing.cpp | 4 +- src/ccache/ccache.cpp | 40 +++---- src/ccache/core/cacheentry.cpp | 4 +- src/ccache/core/mainoptions.cpp | 4 +- src/ccache/core/result.cpp | 12 +-- src/ccache/core/result.hpp | 6 +- src/ccache/core/resultextractor.cpp | 12 +-- src/ccache/core/resultextractor.hpp | 8 +- src/ccache/core/resultinspector.cpp | 12 +-- src/ccache/core/resultinspector.hpp | 10 +- src/ccache/core/resultretriever.cpp | 12 +-- src/ccache/core/resultretriever.hpp | 10 +- src/ccache/depfile.cpp | 6 +- src/ccache/depfile.hpp | 6 +- src/ccache/storage/local/localstorage.cpp | 2 +- src/ccache/storage/local/localstorage.hpp | 4 +- unittest/test_depfile.cpp | 126 +++++++++++----------- 18 files changed, 140 insertions(+), 141 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0b679df4..f77dce99 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -94,8 +94,7 @@ Please follow these conventions: * Use `UpperCamelCase` for types (e.g. classes and structs). * Use `UPPER_CASE` names for macros and (non-class) enum values. * Use `snake_case` for other names (namespaces, functions, variables, enum class - values, etc.). (Namespaces used to be in `UpperCamelCase`; transition is work - in progress.) + values, etc.). * Use an `m_` prefix for non-public member variables. * Use a `g_` prefix for global mutable variables. * Use a `k_` prefix for global constants. diff --git a/src/ccache/argprocessing.cpp b/src/ccache/argprocessing.cpp index 7122d294..fcb2b8de 100644 --- a/src/ccache/argprocessing.cpp +++ b/src/ccache/argprocessing.cpp @@ -865,7 +865,7 @@ process_option_arg(const Context& ctx, args_info.dependency_target = ""; } *args_info.dependency_target += - is_mq ? Depfile::escape_filename(dep_target) : dep_target; + is_mq ? depfile::escape_filename(dep_target) : dep_target; return Statistic::none; } @@ -1612,7 +1612,7 @@ process_args(Context& ctx) } args_info.dependency_target = - Depfile::escape_filename(util::pstr(dep_target).str()); + depfile::escape_filename(util::pstr(dep_target).str()); } } diff --git a/src/ccache/ccache.cpp b/src/ccache/ccache.cpp index 1dce4eda..4ab2eacc 100644 --- a/src/ccache/ccache.cpp +++ b/src/ccache/ccache.cpp @@ -713,7 +713,7 @@ result_key_from_depfile(Context& ctx, Hash& hash) } bool seen_colon = false; - for (std::string_view token : Depfile::tokenize(*file_content)) { + for (std::string_view token : depfile::tokenize(*file_content)) { if (token.empty()) { seen_colon = false; continue; @@ -936,8 +936,8 @@ find_coverage_file(const Context& ctx) // (in CWD) if -fprofile-dir=DIR is present (regardless of DIR) instead of the // traditional /dir/to/example.gcno. - fs::path mangled_form = core::Result::gcno_file_in_mangled_form(ctx); - fs::path unmangled_form = core::Result::gcno_file_in_unmangled_form(ctx); + fs::path mangled_form = core::result::gcno_file_in_mangled_form(ctx); + fs::path unmangled_form = core::result::gcno_file_in_unmangled_form(ctx); fs::path found_file; if (DirEntry(mangled_form).is_regular_file()) { LOG("Found coverage file {}", mangled_form); @@ -966,29 +966,29 @@ write_result(Context& ctx, const util::Bytes& stdout_data, const util::Bytes& stderr_data) { - core::Result::Serializer serializer(ctx.config); + core::result::Serializer serializer(ctx.config); if (!stderr_data.empty()) { - serializer.add_data(core::Result::FileType::stderr_output, stderr_data); + serializer.add_data(core::result::FileType::stderr_output, stderr_data); } // Write stdout only after stderr (better with MSVC), as ResultRetriever // will later print process them in the order they are read. if (!stdout_data.empty()) { - serializer.add_data(core::Result::FileType::stdout_output, stdout_data); + serializer.add_data(core::result::FileType::stdout_output, stdout_data); } if (ctx.args_info.expect_output_obj - && !serializer.add_file(core::Result::FileType::object, + && !serializer.add_file(core::result::FileType::object, ctx.args_info.output_obj)) { LOG("Object file {} missing", ctx.args_info.output_obj); return false; } if (ctx.args_info.generating_pch - && !serializer.add_file(core::Result::FileType::included_pch_file, + && !serializer.add_file(core::result::FileType::included_pch_file, ctx.args_info.included_pch_file)) { LOG("PCH file {} missing", ctx.args_info.included_pch_file); } if (ctx.args_info.generating_dependencies - && !serializer.add_file(core::Result::FileType::dependency, + && !serializer.add_file(core::result::FileType::dependency, ctx.args_info.output_dep)) { LOG("Dependency file {} missing", ctx.args_info.output_dep); return false; @@ -1000,33 +1000,33 @@ write_result(Context& ctx, return false; } if (!serializer.add_file(coverage_file.mangled - ? core::Result::FileType::coverage_mangled - : core::Result::FileType::coverage_unmangled, + ? core::result::FileType::coverage_mangled + : core::result::FileType::coverage_unmangled, coverage_file.path)) { LOG("Coverage file {} missing", coverage_file.path); return false; } } if (ctx.args_info.generating_stackusage - && !serializer.add_file(core::Result::FileType::stackusage, + && !serializer.add_file(core::result::FileType::stackusage, ctx.args_info.output_su)) { LOG("Stack usage file {} missing", ctx.args_info.output_su); return false; } if (ctx.args_info.generating_callgraphinfo - && !serializer.add_file(core::Result::FileType::callgraph_info, + && !serializer.add_file(core::result::FileType::callgraph_info, ctx.args_info.output_ci)) { LOG("Callgraph info file {} missing", ctx.args_info.output_ci); return false; } if (ctx.args_info.generating_ipa_clones - && !serializer.add_file(core::Result::FileType::ipa_clones, + && !serializer.add_file(core::result::FileType::ipa_clones, ctx.args_info.output_ipa)) { LOG("IPA clones file {} missing", ctx.args_info.output_ipa); return false; } if (ctx.args_info.generating_diagnostics - && !serializer.add_file(core::Result::FileType::diagnostic, + && !serializer.add_file(core::result::FileType::diagnostic, ctx.args_info.output_dia)) { LOG("Diagnostics file {} missing", ctx.args_info.output_dia); return false; @@ -1035,13 +1035,13 @@ write_result(Context& ctx, // Only store .dwo file if it was created by the compiler (GCC and Clang // behave differently e.g. for "-gsplit-dwarf -g1"). && DirEntry(ctx.args_info.output_dwo).is_regular_file() - && !serializer.add_file(core::Result::FileType::dwarf_object, + && !serializer.add_file(core::result::FileType::dwarf_object, ctx.args_info.output_dwo)) { LOG("Split dwarf file {} missing", ctx.args_info.output_dwo); return false; } if (!ctx.args_info.output_al.empty() - && !serializer.add_file(core::Result::FileType::assembler_listing, + && !serializer.add_file(core::result::FileType::assembler_listing, ctx.args_info.output_al)) { LOG("Assembler listing file {} missing", ctx.args_info.output_al); return false; @@ -1289,7 +1289,7 @@ to_cache(Context& ctx, } if (ctx.args_info.generating_dependencies) { - Depfile::make_paths_relative_in_output_dep(ctx); + depfile::make_paths_relative_in_output_dep(ctx); } if (!ctx.args_info.expect_output_obj) { @@ -2251,7 +2251,7 @@ calculate_result_and_manifest_key(Context& ctx, hash.hash(core::CacheEntry::k_format_version); hash.hash_delimiter("result version"); - hash.hash(core::Result::k_format_version); + hash.hash(core::result::k_format_version); if (direct_mode) { hash.hash_delimiter("manifest version"); @@ -2384,7 +2384,7 @@ from_cache(Context& ctx, FromCacheCallMode mode, const Hash::Digest& result_key) try { core::CacheEntry cache_entry(cache_entry_data); cache_entry.verify_checksum(); - core::Result::Deserializer deserializer(cache_entry.payload()); + core::result::Deserializer deserializer(cache_entry.payload()); core::ResultRetriever result_retriever(ctx, result_key); util::UmaskScope umask_scope(ctx.original_umask); deserializer.visit(result_retriever); diff --git a/src/ccache/core/cacheentry.cpp b/src/ccache/core/cacheentry.cpp index 805fd8ab..c64cdca1 100644 --- a/src/ccache/core/cacheentry.cpp +++ b/src/ccache/core/cacheentry.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2022-2024 Joel Rosdahl and other contributors +// Copyright (C) 2022-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -91,7 +91,7 @@ CacheEntry::Header::Header(const Config& config, compression_type(compression_type_from_config(config)), compression_level(compression_level_from_config(config)), self_contained(entry_type != CacheEntryType::result - || !core::Result::Serializer::use_raw_files(config)), + || !core::result::Serializer::use_raw_files(config)), creation_time(util::TimePoint::now().sec()), ccache_version(CCACHE_VERSION), namespace_(config.namespace_()), diff --git a/src/ccache/core/mainoptions.cpp b/src/ccache/core/mainoptions.cpp index d0d2a5f9..e4507e87 100644 --- a/src/ccache/core/mainoptions.cpp +++ b/src/ccache/core/mainoptions.cpp @@ -238,7 +238,7 @@ inspect_path(const fs::path& path) break; } case core::CacheEntryType::result: - Result::Deserializer result_deserializer(payload); + result::Deserializer result_deserializer(payload); ResultInspector result_inspector(stdout); result_deserializer.visit(result_inspector); break; @@ -651,7 +651,7 @@ process_main_options(int argc, const char* const* argv) core::CacheEntry cache_entry(*cache_entry_data); const auto payload = cache_entry.payload(); - Result::Deserializer result_deserializer(payload); + result::Deserializer result_deserializer(payload); result_deserializer.visit(result_extractor); cache_entry.verify_checksum(); return EXIT_SUCCESS; diff --git a/src/ccache/core/result.cpp b/src/ccache/core/result.cpp index bd046069..344f0bf9 100644 --- a/src/ccache/core/result.cpp +++ b/src/ccache/core/result.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Joel Rosdahl and other contributors +// Copyright (C) 2019-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -81,9 +81,9 @@ const uint8_t k_raw_file_marker = 1; const uint8_t k_max_raw_file_entries = 10; bool -should_store_raw_file(const Config& config, core::Result::FileType type) +should_store_raw_file(const Config& config, core::result::FileType type) { - if (!core::Result::Serializer::use_raw_files(config)) { + if (!core::result::Serializer::use_raw_files(config)) { return false; } @@ -103,12 +103,12 @@ should_store_raw_file(const Config& config, core::Result::FileType type) // files that become large enough that it's of interest to clone or hard link // them, so we keep things simple for now. This will also save i-nodes in the // cache. - return type == core::Result::FileType::object; + return type == core::result::FileType::object; } } // namespace -namespace core::Result { +namespace core::result { const uint8_t k_format_version = 0; @@ -338,4 +338,4 @@ Serializer::get_raw_files() const return m_raw_files; } -} // namespace core::Result +} // namespace core::result diff --git a/src/ccache/core/result.hpp b/src/ccache/core/result.hpp index 2bf94222..9e577da1 100644 --- a/src/ccache/core/result.hpp +++ b/src/ccache/core/result.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Joel Rosdahl and other contributors +// Copyright (C) 2019-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -36,7 +36,7 @@ namespace core { class CacheEntryDataParser; -namespace Result { +namespace result { extern const uint8_t k_format_version; @@ -186,6 +186,6 @@ private: std::vector m_raw_files; }; -} // namespace Result +} // namespace result } // namespace core diff --git a/src/ccache/core/resultextractor.cpp b/src/ccache/core/resultextractor.cpp index ed2cafaf..afb71627 100644 --- a/src/ccache/core/resultextractor.cpp +++ b/src/ccache/core/resultextractor.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -49,13 +49,13 @@ ResultExtractor::ResultExtractor( void ResultExtractor::on_embedded_file(uint8_t /*file_number*/, - Result::FileType file_type, + result::FileType file_type, nonstd::span data) { - std::string suffix = Result::file_type_to_string(file_type); - if (suffix == Result::k_unknown_file_type) { + std::string suffix = result::file_type_to_string(file_type); + if (suffix == result::k_unknown_file_type) { suffix = - FMT(".type_{}", static_cast(file_type)); + FMT(".type_{}", static_cast(file_type)); } else if (suffix[0] == '<') { suffix[0] = '.'; suffix.resize(suffix.length() - 1); @@ -68,7 +68,7 @@ ResultExtractor::on_embedded_file(uint8_t /*file_number*/, void ResultExtractor::on_raw_file(uint8_t file_number, - Result::FileType file_type, + result::FileType file_type, uint64_t file_size) { if (!m_get_raw_file_path) { diff --git a/src/ccache/core/resultextractor.hpp b/src/ccache/core/resultextractor.hpp index 5be41a05..f99e8972 100644 --- a/src/ccache/core/resultextractor.hpp +++ b/src/ccache/core/resultextractor.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -31,7 +31,7 @@ namespace core { // This class extracts the parts of a result entry to a directory. -class ResultExtractor : public Result::Deserializer::Visitor +class ResultExtractor : public result::Deserializer::Visitor { public: using GetRawFilePathFunction = std::function; @@ -43,10 +43,10 @@ public: std::optional get_raw_file_path = std::nullopt); void on_embedded_file(uint8_t file_number, - Result::FileType file_type, + result::FileType file_type, nonstd::span data) override; void on_raw_file(uint8_t file_number, - Result::FileType file_type, + result::FileType file_type, uint64_t file_size) override; private: diff --git a/src/ccache/core/resultinspector.cpp b/src/ccache/core/resultinspector.cpp index ab810360..f636c869 100644 --- a/src/ccache/core/resultinspector.cpp +++ b/src/ccache/core/resultinspector.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -30,7 +30,7 @@ ResultInspector::ResultInspector(FILE* stream) } void -ResultInspector::on_header(const Result::Deserializer::Header& header) +ResultInspector::on_header(const result::Deserializer::Header& header) { PRINT(m_stream, "Result format version: {}\n", header.format_version); PRINT(m_stream, "Number of files: {}\n", header.n_files); @@ -38,25 +38,25 @@ ResultInspector::on_header(const Result::Deserializer::Header& header) void ResultInspector::on_embedded_file(uint8_t file_number, - Result::FileType file_type, + result::FileType file_type, nonstd::span data) { PRINT(m_stream, "Embedded file #{}: {} ({} bytes)\n", file_number, - Result::file_type_to_string(file_type), + result::file_type_to_string(file_type), data.size()); } void ResultInspector::on_raw_file(uint8_t file_number, - Result::FileType file_type, + result::FileType file_type, uint64_t file_size) { PRINT(m_stream, "Raw file #{}: {} ({} bytes)\n", file_number, - Result::file_type_to_string(file_type), + result::file_type_to_string(file_type), file_size); } diff --git a/src/ccache/core/resultinspector.hpp b/src/ccache/core/resultinspector.hpp index 49b3368b..da764a1f 100644 --- a/src/ccache/core/resultinspector.hpp +++ b/src/ccache/core/resultinspector.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -28,18 +28,18 @@ namespace core { // This class writes information about the result entry to `stream`. -class ResultInspector : public Result::Deserializer::Visitor +class ResultInspector : public result::Deserializer::Visitor { public: ResultInspector(FILE* stream); - void on_header(const Result::Deserializer::Header& header) override; + void on_header(const result::Deserializer::Header& header) override; void on_embedded_file(uint8_t file_number, - Result::FileType file_type, + result::FileType file_type, nonstd::span data) override; void on_raw_file(uint8_t file_number, - Result::FileType file_type, + result::FileType file_type, uint64_t file_size) override; private: diff --git a/src/ccache/core/resultretriever.cpp b/src/ccache/core/resultretriever.cpp index 5212016a..86632483 100644 --- a/src/ccache/core/resultretriever.cpp +++ b/src/ccache/core/resultretriever.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -48,7 +48,7 @@ using util::DirEntry; namespace core { -using Result::FileType; +using result::FileType; ResultRetriever::ResultRetriever(const Context& ctx, std::optional result_key) @@ -64,7 +64,7 @@ ResultRetriever::on_embedded_file(uint8_t file_number, { LOG("Reading embedded entry #{} {} ({} bytes)", file_number, - Result::file_type_to_string(file_type), + result::file_type_to_string(file_type), data.size()); if (file_type == FileType::stdout_output) { @@ -100,7 +100,7 @@ ResultRetriever::on_raw_file(uint8_t file_number, { LOG("Reading raw entry #{} {} ({} bytes)", file_number, - Result::file_type_to_string(file_type), + result::file_type_to_string(file_type), file_size); if (!m_result_key) { @@ -140,7 +140,7 @@ ResultRetriever::on_raw_file(uint8_t file_number, // Should never happen. LOG("Did not copy {} since destination path is unknown for type {}", raw_file_path, - static_cast(file_type)); + static_cast(file_type)); } } @@ -189,7 +189,7 @@ ResultRetriever::get_dest_path(FileType file_type) const case FileType::coverage_mangled: if (m_ctx.args_info.generating_coverage) { - return Result::gcno_file_in_mangled_form(m_ctx); + return result::gcno_file_in_mangled_form(m_ctx); } break; diff --git a/src/ccache/core/resultretriever.hpp b/src/ccache/core/resultretriever.hpp index ab8ee0fb..1c24efb4 100644 --- a/src/ccache/core/resultretriever.hpp +++ b/src/ccache/core/resultretriever.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -33,7 +33,7 @@ class Context; namespace core { // This class retrieves a result entry to the local file system. -class ResultRetriever : public Result::Deserializer::Visitor +class ResultRetriever : public result::Deserializer::Visitor { public: class WriteError : public Error @@ -47,17 +47,17 @@ public: std::optional result_key = std::nullopt); void on_embedded_file(uint8_t file_number, - Result::FileType file_type, + result::FileType file_type, nonstd::span data) override; void on_raw_file(uint8_t file_number, - Result::FileType file_type, + result::FileType file_type, uint64_t file_size) override; private: const Context& m_ctx; std::optional m_result_key; - std::filesystem::path get_dest_path(Result::FileType file_type) const; + std::filesystem::path get_dest_path(result::FileType file_type) const; void write_dependency_file(const std::filesystem::path& path, nonstd::span data); diff --git a/src/ccache/depfile.cpp b/src/ccache/depfile.cpp index 5ebf2322..f3c04974 100644 --- a/src/ccache/depfile.cpp +++ b/src/ccache/depfile.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -35,7 +35,7 @@ namespace fs = util::filesystem; -namespace Depfile { +namespace depfile { std::string escape_filename(std::string_view filename) @@ -254,4 +254,4 @@ untokenize(const std::vector& tokens) return result; } -} // namespace Depfile +} // namespace depfile diff --git a/src/ccache/depfile.hpp b/src/ccache/depfile.hpp index bb0ac6d5..d3b69924 100644 --- a/src/ccache/depfile.hpp +++ b/src/ccache/depfile.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -25,7 +25,7 @@ class Context; #include #include -namespace Depfile { +namespace depfile { std::string escape_filename(std::string_view filename); @@ -41,4 +41,4 @@ std::vector tokenize(std::string_view text); // Return text from `tokens` that originate from `tokenize`. std::string untokenize(const std::vector& tokens); -} // namespace Depfile +} // namespace depfile diff --git a/src/ccache/storage/local/localstorage.cpp b/src/ccache/storage/local/localstorage.cpp index 2e97762f..20aa37af 100644 --- a/src/ccache/storage/local/localstorage.cpp +++ b/src/ccache/storage/local/localstorage.cpp @@ -643,7 +643,7 @@ LocalStorage::get_raw_file_path(const Hash::Digest& result_key, void LocalStorage::put_raw_files( const Hash::Digest& key, - const std::vector& raw_files) + const std::vector& raw_files) { const auto cache_file = look_up_cache_file(key, core::CacheEntryType::result); core::ensure_dir_exists(cache_file.path.parent_path()); diff --git a/src/ccache/storage/local/localstorage.hpp b/src/ccache/storage/local/localstorage.hpp index 01b8861a..962cfed0 100644 --- a/src/ccache/storage/local/localstorage.hpp +++ b/src/ccache/storage/local/localstorage.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2024 Joel Rosdahl and other contributors +// Copyright (C) 2021-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -88,7 +88,7 @@ public: void put_raw_files( const Hash::Digest& key, - const std::vector& raw_files); + const std::vector& raw_files); // Clone, hard link or copy a file from `source` to `dest` depending on // settings in `ctx`. If cloning or hard linking cannot and should not be done diff --git a/unittest/test_depfile.cpp b/unittest/test_depfile.cpp index f5c8b212..0be8c53d 100644 --- a/unittest/test_depfile.cpp +++ b/unittest/test_depfile.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -33,21 +33,21 @@ namespace fs = util::filesystem; using TestUtil::TestContext; -TEST_SUITE_BEGIN("Depfile"); +TEST_SUITE_BEGIN("depfile"); -TEST_CASE("Depfile::escape_filename") +TEST_CASE("depfile::escape_filename") { - CHECK(Depfile::escape_filename("") == ""); - CHECK(Depfile::escape_filename("foo") == "foo"); - CHECK(Depfile::escape_filename("foo\\bar") == "foo\\\\bar"); - CHECK(Depfile::escape_filename("foo#bar") == "foo\\#bar"); - CHECK(Depfile::escape_filename("foo:bar") == "foo\\:bar"); - CHECK(Depfile::escape_filename("foo bar") == "foo\\ bar"); - CHECK(Depfile::escape_filename("foo\tbar") == "foo\\\tbar"); - CHECK(Depfile::escape_filename("foo$bar") == "foo$$bar"); + CHECK(depfile::escape_filename("") == ""); + CHECK(depfile::escape_filename("foo") == "foo"); + CHECK(depfile::escape_filename("foo\\bar") == "foo\\\\bar"); + CHECK(depfile::escape_filename("foo#bar") == "foo\\#bar"); + CHECK(depfile::escape_filename("foo:bar") == "foo\\:bar"); + CHECK(depfile::escape_filename("foo bar") == "foo\\ bar"); + CHECK(depfile::escape_filename("foo\tbar") == "foo\\\tbar"); + CHECK(depfile::escape_filename("foo$bar") == "foo$$bar"); } -TEST_CASE("Depfile::rewrite_source_paths") +TEST_CASE("depfile::rewrite_source_paths") { Context ctx; @@ -59,27 +59,27 @@ TEST_CASE("Depfile::rewrite_source_paths") "\n" " {0}/bar/bar.h: \n" " {1}/fie.h:\n", - Depfile::escape_filename(util::pstr(cwd).str()), - Depfile::escape_filename(util::pstr(cwd.parent_path()).str())); + depfile::escape_filename(util::pstr(cwd).str()), + depfile::escape_filename(util::pstr(cwd.parent_path()).str())); SUBCASE("Base directory not in dep file content") { ctx.config.set_base_dir("/foo/bar"); - CHECK(!Depfile::rewrite_source_paths(ctx, "")); - CHECK(!Depfile::rewrite_source_paths(ctx, content)); + CHECK(!depfile::rewrite_source_paths(ctx, "")); + CHECK(!depfile::rewrite_source_paths(ctx, content)); } SUBCASE("Base directory in dep file content but not matching") { ctx.config.set_base_dir((cwd.parent_path() / "other").string()); - CHECK(!Depfile::rewrite_source_paths(ctx, "")); - CHECK(!Depfile::rewrite_source_paths(ctx, content)); + CHECK(!depfile::rewrite_source_paths(ctx, "")); + CHECK(!depfile::rewrite_source_paths(ctx, content)); } SUBCASE("Absolute paths under base directory rewritten") { ctx.config.set_base_dir(cwd.string()); - const auto actual = Depfile::rewrite_source_paths(ctx, content); + const auto actual = depfile::rewrite_source_paths(ctx, content); const auto expected = FMT( "{0}/foo.o: \\\n" " bar.c \\\n" @@ -87,26 +87,26 @@ TEST_CASE("Depfile::rewrite_source_paths") " {1}/fie.h\n" "{2}:\n" "{1}/fie.h:\n", - Depfile::escape_filename(util::pstr(cwd).str()), - Depfile::escape_filename(util::pstr(cwd.parent_path()).str()), - Depfile::escape_filename( + depfile::escape_filename(util::pstr(cwd).str()), + depfile::escape_filename(util::pstr(cwd.parent_path()).str()), + depfile::escape_filename( util::pstr(fs::path("bar/bar.h").lexically_normal()).str())); REQUIRE(actual); CHECK(*actual == expected); } } -TEST_CASE("Depfile::tokenize") +TEST_CASE("depfile::tokenize") { SUBCASE("Empty") { - auto result = Depfile::tokenize(""); + auto result = depfile::tokenize(""); CHECK(result.size() == 0); } SUBCASE("Simple") { - auto result = Depfile::tokenize("cat.o: meow meow purr"); + auto result = depfile::tokenize("cat.o: meow meow purr"); REQUIRE(result.size() == 6); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -118,7 +118,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Dollar sign followed by a dollar sign") { - auto result = Depfile::tokenize("cat.o: meow$$"); + auto result = depfile::tokenize("cat.o: meow$$"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -128,7 +128,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Dollar sign followed by an alphabet") { - auto result = Depfile::tokenize("cat.o: meow$w"); + auto result = depfile::tokenize("cat.o: meow$w"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -138,7 +138,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Backslash followed by a number sign or a colon") { - auto result = Depfile::tokenize("cat.o: meow\\# meow\\:"); + auto result = depfile::tokenize("cat.o: meow\\# meow\\:"); REQUIRE(result.size() == 5); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -149,7 +149,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Backslash followed by an alphabet") { - auto result = Depfile::tokenize("cat.o: meow\\w purr\\r"); + auto result = depfile::tokenize("cat.o: meow\\w purr\\r"); REQUIRE(result.size() == 5); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -160,7 +160,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Backslash followed by a space or a tab") { - auto result = Depfile::tokenize("cat.o: meow\\ meow purr\\\tpurr"); + auto result = depfile::tokenize("cat.o: meow\\ meow purr\\\tpurr"); REQUIRE(result.size() == 5); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -171,7 +171,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Backslashes followed by a space or a tab") { - auto result = Depfile::tokenize("cat.o: meow\\\\\\ meow purr\\\\ purr"); + auto result = depfile::tokenize("cat.o: meow\\\\\\ meow purr\\\\ purr"); REQUIRE(result.size() == 6); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -183,7 +183,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Backslash newline") { - auto result = Depfile::tokenize("cat.o: meow\\\nmeow\\\n purr\\\n\tpurr"); + auto result = depfile::tokenize("cat.o: meow\\\nmeow\\\n purr\\\n\tpurr"); REQUIRE(result.size() == 7); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -198,8 +198,8 @@ TEST_CASE("Depfile::tokenize") { // This is an invalid dependency file since it has multiple lines without // backslash, which is not valid Makefile syntax. However, the - // Depfile::tokenize's simplistic parser accepts them. - auto result = Depfile::tokenize("cat.o: meow\nmeow\npurr\n"); + // depfile::tokenize's simplistic parser accepts them. + auto result = depfile::tokenize("cat.o: meow\nmeow\npurr\n"); REQUIRE(result.size() == 8); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -213,7 +213,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Multiple entries") { - auto result = Depfile::tokenize( + auto result = depfile::tokenize( "foo.o bar.o: a.h \\\n" " b.h\\\n" " c.h\n" @@ -237,7 +237,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Trailing dollar sign") { - auto result = Depfile::tokenize("cat.o: meow$"); + auto result = depfile::tokenize("cat.o: meow$"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -247,7 +247,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Trailing backslash") { - auto result = Depfile::tokenize("cat.o: meow\\"); + auto result = depfile::tokenize("cat.o: meow\\"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -257,7 +257,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Trailing backslash newline") { - auto result = Depfile::tokenize("cat.o: meow\\\n"); + auto result = depfile::tokenize("cat.o: meow\\\n"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -267,7 +267,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Space before the colon but not after") { - auto result = Depfile::tokenize("cat.o :meow"); + auto result = depfile::tokenize("cat.o :meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -277,7 +277,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Space around the colon") { - auto result = Depfile::tokenize("cat.o : meow"); + auto result = depfile::tokenize("cat.o : meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -287,7 +287,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("No space between colon and dependency") { - auto result = Depfile::tokenize("cat.o:meow"); + auto result = depfile::tokenize("cat.o:meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -297,7 +297,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename (with backslashes in target)") { - auto result = Depfile::tokenize("e:\\cat.o: meow"); + auto result = depfile::tokenize("e:\\cat.o: meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "e:\\cat.o"); CHECK(result[1] == ":"); @@ -307,7 +307,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename (with backslashes in prerequisite)") { - auto result = Depfile::tokenize("cat.o: c:\\meow\\purr"); + auto result = depfile::tokenize("cat.o: c:\\meow\\purr"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -317,7 +317,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename (with slashes in target)") { - auto result = Depfile::tokenize("e:/cat.o: meow"); + auto result = depfile::tokenize("e:/cat.o: meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "e:/cat.o"); CHECK(result[1] == ":"); @@ -327,7 +327,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename (with slashes in prerequisite)") { - auto result = Depfile::tokenize("cat.o: c:/meow/purr"); + auto result = depfile::tokenize("cat.o: c:/meow/purr"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat.o"); CHECK(result[1] == ":"); @@ -337,7 +337,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename: cat:/meow") { - auto result = Depfile::tokenize("cat:/meow"); + auto result = depfile::tokenize("cat:/meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat"); CHECK(result[1] == ":"); @@ -347,7 +347,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename: cat:\\meow") { - auto result = Depfile::tokenize("cat:\\meow"); + auto result = depfile::tokenize("cat:\\meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat"); CHECK(result[1] == ":"); @@ -357,7 +357,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename: cat:\\ meow") { - auto result = Depfile::tokenize("cat:\\ meow"); + auto result = depfile::tokenize("cat:\\ meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat"); CHECK(result[1] == ":"); @@ -367,7 +367,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename: cat:c:/meow") { - auto result = Depfile::tokenize("cat:c:/meow"); + auto result = depfile::tokenize("cat:c:/meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat"); CHECK(result[1] == ":"); @@ -377,7 +377,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename: cat:c:\\meow") { - auto result = Depfile::tokenize("cat:c:\\meow"); + auto result = depfile::tokenize("cat:c:\\meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat"); CHECK(result[1] == ":"); @@ -388,7 +388,7 @@ TEST_CASE("Depfile::tokenize") // Invalid pattern but tested for documentative purposes. SUBCASE("Windows filename: cat:c:") { - auto result = Depfile::tokenize("cat:c:"); + auto result = depfile::tokenize("cat:c:"); REQUIRE(result.size() == 5); CHECK(result[0] == "cat"); CHECK(result[1] == ":"); @@ -400,7 +400,7 @@ TEST_CASE("Depfile::tokenize") // Invalid pattern but tested for documentative purposes. SUBCASE("Windows filename: cat:c:\\") { - auto result = Depfile::tokenize("cat:c:\\"); + auto result = depfile::tokenize("cat:c:\\"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat"); CHECK(result[1] == ":"); @@ -410,7 +410,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename: cat:c:/") { - auto result = Depfile::tokenize("cat:c:/"); + auto result = depfile::tokenize("cat:c:/"); REQUIRE(result.size() == 4); CHECK(result[0] == "cat"); CHECK(result[1] == ":"); @@ -421,7 +421,7 @@ TEST_CASE("Depfile::tokenize") // Invalid pattern but tested for documentative purposes. SUBCASE("Windows filename: cat:c:meow") { - auto result = Depfile::tokenize("cat:c:meow"); + auto result = depfile::tokenize("cat:c:meow"); REQUIRE(result.size() == 6); CHECK(result[0] == "cat"); CHECK(result[1] == ":"); @@ -433,7 +433,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename: c:c:/meow") { - auto result = Depfile::tokenize("c:c:/meow"); + auto result = depfile::tokenize("c:c:/meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "c"); CHECK(result[1] == ":"); @@ -443,7 +443,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename: c:c:\\meow") { - auto result = Depfile::tokenize("c:c:\\meow"); + auto result = depfile::tokenize("c:c:\\meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "c"); CHECK(result[1] == ":"); @@ -453,7 +453,7 @@ TEST_CASE("Depfile::tokenize") SUBCASE("Windows filename: c:z:\\meow") { - auto result = Depfile::tokenize("c:z:\\meow"); + auto result = depfile::tokenize("c:z:\\meow"); REQUIRE(result.size() == 4); CHECK(result[0] == "c"); CHECK(result[1] == ":"); @@ -464,7 +464,7 @@ TEST_CASE("Depfile::tokenize") // Invalid pattern but tested for documentative purposes. SUBCASE("Windows filename: c:cd:\\meow") { - auto result = Depfile::tokenize("c:cd:\\meow"); + auto result = depfile::tokenize("c:cd:\\meow"); REQUIRE(result.size() == 6); CHECK(result[0] == "c"); CHECK(result[1] == ":"); @@ -475,12 +475,12 @@ TEST_CASE("Depfile::tokenize") } } -TEST_CASE("Depfile::untokenize") +TEST_CASE("depfile::untokenize") { - CHECK(Depfile::untokenize({}) == ""); - CHECK(Depfile::untokenize({"foo.o"}) == "foo.o\n"); - CHECK(Depfile::untokenize({"foo.o", ":"}) == "foo.o:\n"); - CHECK(Depfile::untokenize({"foo.o", ":", "bar.h"}) + CHECK(depfile::untokenize({}) == ""); + CHECK(depfile::untokenize({"foo.o"}) == "foo.o\n"); + CHECK(depfile::untokenize({"foo.o", ":"}) == "foo.o:\n"); + CHECK(depfile::untokenize({"foo.o", ":", "bar.h"}) == ("foo.o: \\\n" " bar.h\n")); } -- 2.47.2