]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
style: Add some comments and tweaks
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 19 Dec 2021 20:11:49 +0000 (21:11 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 19 Dec 2021 20:11:49 +0000 (21:11 +0100)
test/suites/secondary_file.bash
unittest/test_Util.cpp

index 3ab48f973e2b8b72ade323b302859f44488f0e6e..0878a0ffda056be8aa829d800a7700f1b209009c 100644 (file)
@@ -12,6 +12,7 @@ SUITE_secondary_file() {
     # -------------------------------------------------------------------------
     TEST "Base case"
 
+    # Compile and send result to primary and secondary storage.
     $CCACHE_COMPILE -c test.c
     expect_stat direct_cache_hit 0
     expect_stat cache_miss 1
@@ -27,6 +28,7 @@ SUITE_secondary_file() {
     fi
     expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
 
+    # Get result from primary storage.
     $CCACHE_COMPILE -c test.c
     expect_stat direct_cache_hit 1
     expect_stat cache_miss 1
@@ -37,10 +39,12 @@ SUITE_secondary_file() {
     expect_stat files_in_cache 2
     expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
 
+    # Clear primary storage.
     $CCACHE -C >/dev/null
     expect_stat files_in_cache 0
     expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
 
+    # Get result from secondary storage, copying it to primary storage.
     $CCACHE_COMPILE -c test.c
     expect_stat direct_cache_hit 2
     expect_stat cache_miss 1
@@ -51,6 +55,7 @@ SUITE_secondary_file() {
     expect_stat files_in_cache 2 # fetched from secondary
     expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
 
+    # Get result from primary storage again.
     $CCACHE_COMPILE -c test.c
     expect_stat direct_cache_hit 3
     expect_stat cache_miss 1
@@ -60,6 +65,7 @@ SUITE_secondary_file() {
     expect_stat secondary_storage_miss 2 # result + manifest
     expect_stat files_in_cache 2 # fetched from secondary
     expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
+
     # -------------------------------------------------------------------------
     TEST "Flat layout"
 
index 218927278a7c419358fecea7e0654d30a3b712b1..f2398c4fb83534bfa93e03cdb696c6243e821e4f 100644 (file)
@@ -651,23 +651,20 @@ TEST_CASE("Util::read_file and Util::write_file")
                     "No such file or directory");
 }
 
-TEST_CASE(
-  "Util::read_file, Util::write_file and Util::copy_file with binary files")
+TEST_CASE("Util::{read,write,copy}_file with binary files")
 {
   TestContext test_context;
 
-  std::string origin_data;
-  for (int i = 0; i < 512; i++) {
-    origin_data.push_back(static_cast<char>((32 + i) % 256));
+  std::string data;
+  for (size_t i = 0; i < 512; ++i) {
+    data.push_back(static_cast<char>((32 + i) % 256));
   }
 
-  Util::write_file("test", origin_data, std::ios_base::binary);
-  std::string data = Util::read_file("test");
-  CHECK(data == origin_data);
+  Util::write_file("test", data);
+  CHECK(Util::read_file("test") == data);
 
   Util::copy_file("test", "copy");
-  data = Util::read_file("copy");
-  CHECK(data == origin_data);
+  CHECK(Util::read_file("copy") == data);
 }
 
 TEST_CASE("Util::remove_extension")