LCOV - code coverage report
Current view: top level - tests/src - test0009.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 186 186
Test Date: 2026-10-20 14:27:43 Functions: 100.0 % 10 10
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : #include "sute.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Validate file-level ignore filtering through CLI and configuration
       5                 :             :  *
       6                 :             :  * Both scans start without a database and check the same full output and exact
       7                 :             :  * stored paths. A separate CLI run also checks the TESTING diagnostics
       8                 :             :  *
       9                 :             :  * @return Return status for equivalent filtering and diagnostic output
      10                 :             :  */
      11                 :           2 : Return test0009_1(void)
      12                 :             : {
      13                 :           2 :         INITTEST;
      14                 :           2 :         const char *db_filename = "database0009.db";
      15                 :             : 
      16                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
      17                 :             : 
      18                 :           2 :         const char *arguments = "--database=database0009.db "
      19                 :             :                 "--ignore=\"^(?:skip_|tmp_).*\\.(?:log|bak)$\" "
      20                 :             :                 "tests/fixtures/ignore_include_cases/chaotic_filenames";
      21                 :             : 
      22                 :           2 :         const struct argument_test_case non_testing_cases[] = {
      23                 :             :                 {arguments,COMPLETED,"templates/0009_001_1.txt",STDERR_MUST_BE_EMPTY},
      24                 :             :                 {0}
      25                 :             :         };
      26                 :             : 
      27                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(non_testing_cases,NULL,NULL));
      28                 :             : 
      29                 :           2 :         const char *expected_paths[] =
      30                 :             :         {
      31                 :             :                 "alpha_m0n9k2_zz.txt",
      32                 :             :                 "hold_a1r9v-0pq.bak",
      33                 :             :                 "keep_4xv7__m2.log",
      34                 :             :                 "omega_77xy__aa.bin",
      35                 :             :                 "xqwe_90210.md",
      36                 :             :                 "zeta_z1-9vv.dat"
      37                 :             :         };
      38                 :             : 
      39                 :           2 :         ASSERT(SUCCESS == db_paths_match(db_filename,expected_paths,(int)(sizeof(expected_paths) / sizeof(expected_paths[0]))));
      40                 :             : 
      41                 :           2 :         ASSERT(SUCCESS == delete_path(db_filename));
      42                 :             : 
      43                 :             :         /* Repeat the initial scan from an empty database with the same ignore rule */
      44                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0009_001_1.conf","0009_001_1.conf"));
      45                 :           2 :         const struct argument_test_case file_cases[] = {
      46                 :             :                 {"--config=0009_001_1.conf",COMPLETED,"templates/0009_001_1.txt",STDERR_MUST_BE_EMPTY},
      47                 :             :                 {0}
      48                 :             :         };
      49                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,NULL,NULL));
      50                 :           2 :         ASSERT(SUCCESS == db_paths_match(db_filename,expected_paths,(int)(sizeof(expected_paths) / sizeof(expected_paths[0]))));
      51                 :           2 :         ASSERT(SUCCESS == delete_path(db_filename));
      52                 :           2 :         call(delete_path_if_present("0009_001_1.conf"));
      53                 :             : 
      54                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      55                 :             : 
      56                 :           2 :         const struct argument_test_case testing_cases[] = {
      57                 :             :                 {arguments,COMPLETED,"templates/0009_001_2.txt",STDERR_MUST_BE_EMPTY},
      58                 :             :                 {0}
      59                 :             :         };
      60                 :             : 
      61                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(testing_cases,NULL,NULL));
      62                 :             : 
      63                 :           2 :         ASSERT(SUCCESS == delete_path(db_filename));
      64                 :             : 
      65                 :           2 :         RETURN_STATUS;
      66                 :             : }
      67                 :             : 
      68                 :             : /**
      69                 :             :  * @brief Validate include exceptions to ignore rules through CLI and configuration
      70                 :             :  *
      71                 :             :  * Both scans start without a database and check the same full output and exact
      72                 :             :  * stored paths, including the files restored by include
      73                 :             :  *
      74                 :             :  * @return Return status for equivalent include filtering
      75                 :             :  */
      76                 :           2 : static Return test0009_2(void)
      77                 :             : {
      78                 :           2 :         INITTEST;
      79                 :           2 :         const char *db_filename = "database0009_2.db";
      80                 :             : 
      81                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
      82                 :             : 
      83                 :           2 :         const char *arguments = "--database=database0009_2.db "
      84                 :             :                 "--ignore=\"^(?:skip_|tmp_|zeta_|omega_).+\" "
      85                 :             :                 "--include=\"^(?:skip_4xv7__m2\\.log|tmp_qwe_90210\\.log|zeta_z1-9vv\\.dat)$\" "
      86                 :             :                 "tests/fixtures/ignore_include_cases/chaotic_filenames";
      87                 :             : 
      88                 :           2 :         const struct argument_test_case cases[] = {
      89                 :             :                 {arguments,COMPLETED,"templates/0009_002.txt",STDERR_MUST_BE_EMPTY},
      90                 :             :                 {0}
      91                 :             :         };
      92                 :             : 
      93                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
      94                 :             : 
      95                 :           2 :         const char *expected_paths[] =
      96                 :             :         {
      97                 :             :                 "alpha_m0n9k2_zz.txt",
      98                 :             :                 "hold_a1r9v-0pq.bak",
      99                 :             :                 "keep_4xv7__m2.log",
     100                 :             :                 "skip_4xv7__m2.log",
     101                 :             :                 "tmp_qwe_90210.log",
     102                 :             :                 "xqwe_90210.md",
     103                 :             :                 "zeta_z1-9vv.dat"
     104                 :             :         };
     105                 :             : 
     106                 :           2 :         ASSERT(SUCCESS == db_paths_match(db_filename,expected_paths,(int)(sizeof(expected_paths) / sizeof(expected_paths[0]))));
     107                 :             : 
     108                 :           2 :         ASSERT(SUCCESS == delete_path(db_filename));
     109                 :             : 
     110                 :             :         /* Repeat the scan with the same ignore and include rules from configuration */
     111                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0009_002.conf","0009_002.conf"));
     112                 :           2 :         const struct argument_test_case file_cases[] = {
     113                 :             :                 {"--config=0009_002.conf",COMPLETED,"templates/0009_002.txt",STDERR_MUST_BE_EMPTY},
     114                 :             :                 {0}
     115                 :             :         };
     116                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,NULL,NULL));
     117                 :           2 :         ASSERT(SUCCESS == db_paths_match(db_filename,expected_paths,(int)(sizeof(expected_paths) / sizeof(expected_paths[0]))));
     118                 :           2 :         ASSERT(SUCCESS == delete_path(db_filename));
     119                 :           2 :         call(delete_path_if_present("0009_002.conf"));
     120                 :             : 
     121                 :           2 :         RETURN_STATUS;
     122                 :             : }
     123                 :             : 
     124                 :             : /**
     125                 :             :  *
     126                 :             :  * Validate whole-directory ignore with selective include
     127                 :             :  *
     128                 :             :  */
     129                 :           2 : static Return test0009_3(void)
     130                 :             : {
     131                 :           2 :         INITTEST;
     132                 :           2 :         const char *db_filename = "database0009_3.db";
     133                 :             : 
     134                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
     135                 :             : 
     136                 :           2 :         const char *arguments = "--database=database0009_3.db "
     137                 :             :                 "--ignore=\"^chaotic_filenames(?:/|$)\" "
     138                 :             :                 "--include=\"^chaotic_filenames/(?:alpha_m0n9k2_zz\\.txt|hold_a1r9v-0pq\\.bak|keep_4xv7__m2\\.log|omega_77xy__aa\\.bin|xqwe_90210\\.md|zeta_z1-9vv\\.dat)$\" "
     139                 :             :                 "tests/fixtures/ignore_include_cases";
     140                 :             : 
     141                 :           2 :         const struct argument_test_case cases[] = {
     142                 :             :                 {arguments,COMPLETED,"templates/0009_003.txt",STDERR_MUST_BE_EMPTY},
     143                 :             :                 {0}
     144                 :             :         };
     145                 :             : 
     146                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
     147                 :             : 
     148                 :           2 :         const char *expected_paths[] =
     149                 :             :         {
     150                 :             :                 "chaotic_filenames/alpha_m0n9k2_zz.txt",
     151                 :             :                 "chaotic_filenames/hold_a1r9v-0pq.bak",
     152                 :             :                 "chaotic_filenames/keep_4xv7__m2.log",
     153                 :             :                 "chaotic_filenames/omega_77xy__aa.bin",
     154                 :             :                 "chaotic_filenames/xqwe_90210.md",
     155                 :             :                 "chaotic_filenames/zeta_z1-9vv.dat"
     156                 :             :         };
     157                 :             : 
     158                 :           2 :         ASSERT(SUCCESS == db_paths_match(db_filename,expected_paths,(int)(sizeof(expected_paths) / sizeof(expected_paths[0]))));
     159                 :             : 
     160                 :           2 :         ASSERT(SUCCESS == delete_path(db_filename));
     161                 :             : 
     162                 :           2 :         RETURN_STATUS;
     163                 :             : }
     164                 :             : 
     165                 :             : /**
     166                 :             :  * @brief Validate update included branch in three passes
     167                 :             :  */
     168                 :           2 : static Return test0009_4(void)
     169                 :             : {
     170                 :           2 :         INITTEST;
     171                 :             : 
     172                 :           2 :         const char *db_filename = "database0009_4.db";
     173                 :             : 
     174                 :           2 :         ASSERT(SUCCESS == prepare_mutable_fixture("tests/fixtures/ignore_include_cases/chaotic_filenames"));
     175                 :             : 
     176                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
     177                 :             : 
     178                 :           2 :         const char *arguments_create = "--database=database0009_4.db "
     179                 :             :                 "--ignore=\"^(?:skip_|tmp_).+\" "
     180                 :             :                 "--include=\"^(?:skip_4xv7__m2\\.log|tmp_qwe_90210\\.log|tmp_z1-9vv\\.bak)$\" "
     181                 :             :                 "tests/fixtures/ignore_include_cases/chaotic_filenames";
     182                 :             : 
     183                 :             :         /*
     184                 :             :          * Create the baseline DB using the same ignore/include rules as the later update passes
     185                 :             :          * We intentionally build the initial record set as "tracked-after-filters" and not as "all files in directory"
     186                 :             :          * Update mode processes the current filtered set and does not retroactively delete rows that were inserted earlier
     187                 :             :          * If this first pass omitted filters, all 12 paths would be stored and the update-included scenario would validate a different logic branch
     188                 :             :          */
     189                 :           2 :         const struct argument_test_case create_cases[] = {
     190                 :             :                 {arguments_create,COMPLETED,"templates/0009_004_1.txt",STDERR_MUST_BE_EMPTY},
     191                 :             :                 {0}
     192                 :             :         };
     193                 :             : 
     194                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(create_cases,NULL,NULL));
     195                 :             : 
     196                 :           2 :         ASSERT(SUCCESS == add_string_to(" ","tests/fixtures/ignore_include_cases/chaotic_filenames/skip_4xv7__m2.log"));
     197                 :             : 
     198                 :           2 :         const char *arguments_update = "--update --check-level=QUICK --database=database0009_4.db "
     199                 :             :                 "--ignore=\"^(?:skip_|tmp_).+\" "
     200                 :             :                 "--include=\"^(?:skip_4xv7__m2\\.log|tmp_qwe_90210\\.log|tmp_z1-9vv\\.bak)$\" "
     201                 :             :                 "tests/fixtures/ignore_include_cases/chaotic_filenames";
     202                 :             : 
     203                 :             :         // Update mode pass where only one included file has changed
     204                 :           2 :         const struct argument_test_case update_cases[] = {
     205                 :             :                 {arguments_update,COMPLETED,"templates/0009_004_2.txt",STDERR_MUST_BE_EMPTY},
     206                 :             :                 {0}
     207                 :             :         };
     208                 :             : 
     209                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(update_cases,NULL,NULL));
     210                 :             : 
     211                 :           2 :         ASSERT(SUCCESS == add_string_to(" ","tests/fixtures/ignore_include_cases/chaotic_filenames/tmp_qwe_90210.log"));
     212                 :           2 :         ASSERT(SUCCESS == add_string_to(" ","tests/fixtures/ignore_include_cases/chaotic_filenames/tmp_z1-9vv.bak"));
     213                 :             :         // Truncate a tracked non-included file to trigger the "updated as empty" branch
     214                 :           2 :         ASSERT(SUCCESS == truncate_file_to_zero_size("tests/fixtures/ignore_include_cases/chaotic_filenames/alpha_m0n9k2_zz.txt"));
     215                 :             : 
     216                 :           2 :         const char *arguments_update_watch = "--watch-timestamps --update --check-level=QUICK --database=database0009_4.db "
     217                 :             :                 "--ignore=\"^(?:skip_|tmp_).+\" "
     218                 :             :                 "--include=\"^(?:skip_4xv7__m2\\.log|tmp_qwe_90210\\.log|tmp_z1-9vv\\.bak)$\" "
     219                 :             :                 "tests/fixtures/ignore_include_cases/chaotic_filenames";
     220                 :             : 
     221                 :             :         // Update mode with watch-timestamps enabled where one non-included file becomes empty and two included files are updated
     222                 :           2 :         const struct argument_test_case watch_timestamps_cases[] = {
     223                 :             :                 {arguments_update_watch,COMPLETED,"templates/0009_004_3.txt",STDERR_MUST_BE_EMPTY},
     224                 :             :                 {0}
     225                 :             :         };
     226                 :             : 
     227                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(watch_timestamps_cases,NULL,NULL));
     228                 :             : 
     229                 :           2 :         const char *expected_paths[] =
     230                 :             :         {
     231                 :             :                 "alpha_m0n9k2_zz.txt",
     232                 :             :                 "hold_a1r9v-0pq.bak",
     233                 :             :                 "keep_4xv7__m2.log",
     234                 :             :                 "omega_77xy__aa.bin",
     235                 :             :                 "skip_4xv7__m2.log",
     236                 :             :                 "tmp_qwe_90210.log",
     237                 :             :                 "tmp_z1-9vv.bak",
     238                 :             :                 "xqwe_90210.md",
     239                 :             :                 "zeta_z1-9vv.dat"
     240                 :             :         };
     241                 :             : 
     242                 :           2 :         ASSERT(SUCCESS == db_paths_match(db_filename,expected_paths,(int)(sizeof(expected_paths) / sizeof(expected_paths[0]))));
     243                 :           2 :         ASSERT(SUCCESS == delete_path(db_filename));
     244                 :             : 
     245                 :           2 :         ASSERT(SUCCESS == restore_mutable_fixture("tests/fixtures/ignore_include_cases/chaotic_filenames"));
     246                 :             : 
     247                 :           2 :         RETURN_STATUS;
     248                 :             : }
     249                 :             : 
     250                 :             : /**
     251                 :             :  * @brief Verify ignored missing DB rows stay outside cleanup without --db-drop-ignored
     252                 :             :  *
     253                 :             :  * The test creates a database with all fixture files, removes one file below a
     254                 :             :  * later ignored subtree, then runs update with the matching --ignore pattern.
     255                 :             :  * The deleted ignored row must remain in the DB and must not be reported as
     256                 :             :  * missing-file cleanup
     257                 :             :  */
     258                 :           2 : static Return test0009_5(void)
     259                 :             : {
     260                 :           2 :         INITTEST;
     261                 :             : 
     262                 :           2 :         const char *db_file_name = "database0009_5.db";
     263                 :           2 :         const char *ignored_relative_path = "path2/AAA/ZAW/D/e/f/b_file.txt";
     264                 :           2 :         const char *arguments = NULL;
     265                 :           2 :         bool ignored_row_exists = false;
     266                 :             : 
     267                 :           2 :         ASSERT(SUCCESS == prepare_mutable_fixture("tests/fixtures/diffs/diff1"));
     268                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
     269                 :             : 
     270                 :           2 :         arguments = "--database=database0009_5.db tests/fixtures/diffs/diff1";
     271                 :           2 :         ASSERT(SUCCESS == runit(arguments,NULL,NULL,COMPLETED,ALLOW_BOTH));
     272                 :             : 
     273                 :           2 :         ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1/path2/AAA/ZAW/D/e/f/b_file.txt"));
     274                 :             : 
     275                 :           2 :         arguments = "--update --check-level=QUICK --ignore=\"^path2/AAA/ZAW/.*\" "
     276                 :             :                 "--database=database0009_5.db tests/fixtures/diffs/diff1";
     277                 :             : 
     278                 :           2 :         const struct argument_test_case cases[] = {
     279                 :             :                 {arguments,COMPLETED,"templates/0009_005.txt",STDERR_MUST_BE_EMPTY},
     280                 :             :                 {0}
     281                 :             :         };
     282                 :             : 
     283                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
     284                 :             : 
     285                 :           2 :         ASSERT(SUCCESS == db_relative_path_exists(db_file_name,ignored_relative_path,&ignored_row_exists));
     286                 :           2 :         ASSERT(ignored_row_exists == true);
     287                 :             : 
     288                 :           2 :         ASSERT(SUCCESS == delete_path(db_file_name));
     289                 :           2 :         ASSERT(SUCCESS == restore_mutable_fixture("tests/fixtures/diffs/diff1"));
     290                 :             : 
     291                 :           2 :         RETURN_STATUS;
     292                 :             : }
     293                 :             : 
     294                 :             : /**
     295                 :             :  * @brief Verify --include restores an ignored missing DB row to cleanup scope
     296                 :             :  *
     297                 :             :  * The test deletes a file that matches both --ignore and --include during the
     298                 :             :  * update run. The include pattern must make cleanup treat the missing row as a
     299                 :             :  * normal tracked path, delete it from the DB, and report it as no longer present
     300                 :             :  */
     301                 :           2 : static Return test0009_6(void)
     302                 :             : {
     303                 :           2 :         INITTEST;
     304                 :             : 
     305                 :           2 :         const char *db_file_name = "database0009_6.db";
     306                 :           2 :         const char *included_relative_path = "path2/AAA/ZAW/D/e/f/b_file.txt";
     307                 :           2 :         const char *arguments = NULL;
     308                 :           2 :         bool included_row_exists = true;
     309                 :             : 
     310                 :           2 :         ASSERT(SUCCESS == prepare_mutable_fixture("tests/fixtures/diffs/diff1"));
     311                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
     312                 :             : 
     313                 :           2 :         arguments = "--database=database0009_6.db tests/fixtures/diffs/diff1";
     314                 :           2 :         ASSERT(SUCCESS == runit(arguments,NULL,NULL,COMPLETED,ALLOW_BOTH));
     315                 :             : 
     316                 :           2 :         ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1/path2/AAA/ZAW/D/e/f/b_file.txt"));
     317                 :             : 
     318                 :           2 :         arguments = "--update --check-level=QUICK --ignore=\"^path2/AAA/ZAW/.*\" "
     319                 :             :                 "--include=\"^path2/AAA/ZAW/D/e/f/b_file\\.txt$\" "
     320                 :             :                 "--database=database0009_6.db tests/fixtures/diffs/diff1";
     321                 :             : 
     322                 :           2 :         const struct argument_test_case cases[] = {
     323                 :             :                 {arguments,COMPLETED,"templates/0009_006.txt",STDERR_MUST_BE_EMPTY},
     324                 :             :                 {0}
     325                 :             :         };
     326                 :             : 
     327                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
     328                 :             : 
     329                 :           2 :         ASSERT(SUCCESS == db_relative_path_exists(db_file_name,included_relative_path,&included_row_exists));
     330                 :           2 :         ASSERT(included_row_exists == false);
     331                 :             : 
     332                 :           2 :         ASSERT(SUCCESS == delete_path(db_file_name));
     333                 :           2 :         ASSERT(SUCCESS == restore_mutable_fixture("tests/fixtures/diffs/diff1"));
     334                 :             : 
     335                 :           2 :         RETURN_STATUS;
     336                 :             : }
     337                 :             : 
     338                 :             : /**
     339                 :             :  * @brief Verify --db-drop-ignored removes an ignored missing DB row as ignored
     340                 :             :  *
     341                 :             :  * A deleted file row that matches --ignore must be classified as ignored cleanup
     342                 :             :  * when --db-drop-ignored is present, not as ordinary missing-file cleanup.
     343                 :             :  * CLI and configuration updates use the same saved database and deleted file,
     344                 :             :  * then check the full output and removal of the ignored record
     345                 :             :  */
     346                 :           2 : static Return test0009_7(void)
     347                 :             : {
     348                 :           2 :         INITTEST;
     349                 :             : 
     350                 :           2 :         const char *db_file_name = "database0009_7.db";
     351                 :           2 :         const char *db_backup_file_name = "database0009_7_before_update.db";
     352                 :           2 :         const char *ignored_relative_path = "path2/AAA/ZAW/D/e/f/b_file.txt";
     353                 :           2 :         const char *arguments = NULL;
     354                 :           2 :         bool ignored_row_exists = true;
     355                 :             : 
     356                 :           2 :         ASSERT(SUCCESS == prepare_mutable_fixture("tests/fixtures/diffs/diff1"));
     357                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
     358                 :             : 
     359                 :           2 :         arguments = "--database=database0009_7.db tests/fixtures/diffs/diff1";
     360                 :           2 :         ASSERT(SUCCESS == runit(arguments,NULL,NULL,COMPLETED,ALLOW_BOTH));
     361                 :             : 
     362                 :           2 :         ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1/path2/AAA/ZAW/D/e/f/b_file.txt"));
     363                 :             : 
     364                 :             :         /* Preserve the database before either update removes the ignored record */
     365                 :           2 :         ASSERT(SUCCESS == copy_path(db_file_name,db_backup_file_name));
     366                 :             : 
     367                 :           2 :         arguments = "--update --check-level=QUICK --db-drop-ignored "
     368                 :             :                 "--ignore=\"^path2/AAA/ZAW/D/e/f/b_file\\.txt$\" "
     369                 :             :                 "--database=database0009_7.db tests/fixtures/diffs/diff1";
     370                 :             : 
     371                 :           2 :         const struct argument_test_case cases[] = {
     372                 :             :                 {arguments,COMPLETED,"templates/0009_007.txt",STDERR_MUST_BE_EMPTY},
     373                 :             :                 {0}
     374                 :             :         };
     375                 :             : 
     376                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
     377                 :             : 
     378                 :           2 :         ASSERT(SUCCESS == db_relative_path_exists(db_file_name,ignored_relative_path,&ignored_row_exists));
     379                 :           2 :         ASSERT(ignored_row_exists == false);
     380                 :             : 
     381                 :             :         /* Restore only the database; the file remains deleted for the configuration run */
     382                 :           2 :         ASSERT(SUCCESS == copy_path(db_backup_file_name,db_file_name));
     383                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0009_007.conf","0009_007.conf"));
     384                 :           2 :         const struct argument_test_case file_cases[] = {
     385                 :             :                 {"--config=0009_007.conf",COMPLETED,"templates/0009_007.txt",STDERR_MUST_BE_EMPTY},
     386                 :             :                 {0}
     387                 :             :         };
     388                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,NULL,NULL));
     389                 :           2 :         ASSERT(SUCCESS == db_relative_path_exists(db_file_name,ignored_relative_path,&ignored_row_exists));
     390                 :           2 :         ASSERT(ignored_row_exists == false);
     391                 :           2 :         call(delete_path_if_present("0009_007.conf"));
     392                 :           2 :         call(delete_path_if_present(db_backup_file_name));
     393                 :             : 
     394                 :           2 :         ASSERT(SUCCESS == delete_path(db_file_name));
     395                 :           2 :         ASSERT(SUCCESS == restore_mutable_fixture("tests/fixtures/diffs/diff1"));
     396                 :             : 
     397                 :           2 :         RETURN_STATUS;
     398                 :             : }
     399                 :             : 
     400                 :             : /**
     401                 :             :  * @brief Verify --db-drop-ignored removes an ignored existing DB row
     402                 :             :  *
     403                 :             :  * The ignored file still exists on disk, so this covers explicit ignored
     404                 :             :  * cleanup independently from missing-file cleanup
     405                 :             :  */
     406                 :           2 : static Return test0009_8(void)
     407                 :             : {
     408                 :           2 :         INITTEST;
     409                 :             : 
     410                 :           2 :         const char *db_file_name = "database0009_8.db";
     411                 :           2 :         const char *ignored_relative_path = "path2/AAA/ZAW/D/e/f/b_file.txt";
     412                 :           2 :         const char *arguments = NULL;
     413                 :           2 :         bool ignored_row_exists = true;
     414                 :             : 
     415                 :           2 :         ASSERT(SUCCESS == prepare_mutable_fixture("tests/fixtures/diffs/diff1"));
     416                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
     417                 :             : 
     418                 :           2 :         arguments = "--database=database0009_8.db tests/fixtures/diffs/diff1";
     419                 :           2 :         ASSERT(SUCCESS == runit(arguments,NULL,NULL,COMPLETED,ALLOW_BOTH));
     420                 :             : 
     421                 :           2 :         arguments = "--update --check-level=QUICK --db-drop-ignored "
     422                 :             :                 "--ignore=\"^path2/AAA/ZAW/D/e/f/b_file\\.txt$\" "
     423                 :             :                 "--database=database0009_8.db tests/fixtures/diffs/diff1";
     424                 :             : 
     425                 :           2 :         const struct argument_test_case cases[] = {
     426                 :             :                 {arguments,COMPLETED,"templates/0009_008.txt",STDERR_MUST_BE_EMPTY},
     427                 :             :                 {0}
     428                 :             :         };
     429                 :             : 
     430                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
     431                 :             : 
     432                 :           2 :         ASSERT(SUCCESS == db_relative_path_exists(db_file_name,ignored_relative_path,&ignored_row_exists));
     433                 :           2 :         ASSERT(ignored_row_exists == false);
     434                 :             : 
     435                 :           2 :         ASSERT(SUCCESS == delete_path(db_file_name));
     436                 :           2 :         ASSERT(SUCCESS == restore_mutable_fixture("tests/fixtures/diffs/diff1"));
     437                 :             : 
     438                 :           2 :         RETURN_STATUS;
     439                 :             : }
     440                 :             : 
     441                 :             : /**
     442                 :             :  * @brief Validate quiet ignore reporting through CLI and configuration
     443                 :             :  *
     444                 :             :  * Both scans start without a database and use the same full output template.
     445                 :             :  * Ignored-file lines must be absent while the remaining messages and exact
     446                 :             :  * stored paths match the ordinary ignore-filtered scan
     447                 :             :  *
     448                 :             :  * @return Return status for equivalent quiet reporting and stored paths
     449                 :             :  */
     450                 :           2 : static Return test0009_9(void)
     451                 :             : {
     452                 :           2 :         INITTEST;
     453                 :           2 :         const char *db_filename = "database0009_9.db";
     454                 :             : 
     455                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
     456                 :             : 
     457                 :           2 :         const char *arguments = "--database=database0009_9.db --quiet-ignored "
     458                 :             :                 "--ignore=\"^(?:skip_|tmp_).*\\.(?:log|bak)$\" "
     459                 :             :                 "tests/fixtures/ignore_include_cases/chaotic_filenames";
     460                 :             : 
     461                 :           2 :         const struct argument_test_case cases[] = {
     462                 :             :                 {arguments,COMPLETED,"templates/0009_009.txt",STDERR_MUST_BE_EMPTY},
     463                 :             :                 {0}
     464                 :             :         };
     465                 :             : 
     466                 :           2 :         const char *expected_paths[] =
     467                 :             :         {
     468                 :             :                 "alpha_m0n9k2_zz.txt",
     469                 :             :                 "hold_a1r9v-0pq.bak",
     470                 :             :                 "keep_4xv7__m2.log",
     471                 :             :                 "omega_77xy__aa.bin",
     472                 :             :                 "xqwe_90210.md",
     473                 :             :                 "zeta_z1-9vv.dat"
     474                 :             :         };
     475                 :             : 
     476                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
     477                 :           2 :         ASSERT(SUCCESS == db_paths_match(db_filename,expected_paths,(int)(sizeof(expected_paths) / sizeof(expected_paths[0]))));
     478                 :           2 :         ASSERT(SUCCESS == delete_path(db_filename));
     479                 :             : 
     480                 :             :         /* Repeat the scan with the same quiet setting and ignore rule from configuration */
     481                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0009_009.conf","0009_009.conf"));
     482                 :           2 :         const struct argument_test_case file_cases[] = {
     483                 :             :                 {"--config=0009_009.conf",COMPLETED,"templates/0009_009.txt",STDERR_MUST_BE_EMPTY},
     484                 :             :                 {0}
     485                 :             :         };
     486                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,NULL,NULL));
     487                 :           2 :         ASSERT(SUCCESS == db_paths_match(db_filename,expected_paths,(int)(sizeof(expected_paths) / sizeof(expected_paths[0]))));
     488                 :           2 :         ASSERT(SUCCESS == delete_path(db_filename));
     489                 :           2 :         call(delete_path_if_present("0009_009.conf"));
     490                 :             : 
     491                 :           2 :         RETURN_STATUS;
     492                 :             : }
     493                 :             : 
     494                 :           2 : Return test0009(void)
     495                 :             : {
     496                 :           2 :         INITTEST;
     497                 :             : 
     498                 :           2 :         TEST(test0009_1,"Ignore regexp splits chaotic filenames into tracked and skipped sets");
     499                 :           2 :         TEST(test0009_2,"Ignore most files and include back selected ones");
     500                 :           2 :         TEST(test0009_3,"Directory ignore with selective child include");
     501                 :           2 :         TEST(test0009_4,"Create then update included files with and without detailed change output");
     502                 :           2 :         TEST(test0009_5,"Ignored missing DB rows stay outside cleanup without --db-drop-ignored");
     503                 :           2 :         TEST(test0009_6,"--include restores an ignored missing DB row to cleanup scope");
     504                 :           2 :         TEST(test0009_7,"--db-drop-ignored removes an ignored missing DB row as ignored");
     505                 :           2 :         TEST(test0009_8,"--db-drop-ignored removes an ignored existing DB row");
     506                 :           2 :         TEST(test0009_9,"--quiet-ignored hides ignored-file lines without changing stored paths through CLI and configuration");
     507                 :             : 
     508                 :           2 :         RETURN_STATUS;
     509                 :             : }
        

Generated by: LCOV version 2.0-1