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

             Branch data     Line data    Source code
       1                 :             : #include "sute.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * The Example 1 from README:
       5                 :             :  * Now some tests could be running:
       6                 :             :  * Stage 1. Adding:
       7                 :             :  * precizer --progress --database=database1.db tests/fixtures/diffs/diff1
       8                 :             :  * Stage 2. Adding:
       9                 :             :  * precizer --progress --database=database2.db tests/fixtures/diffs/diff2
      10                 :             :  * Final stage. Comparing:
      11                 :             :  * precizer --compare --check-level=QUICK database1.db database2.db
      12                 :             :  */
      13                 :           2 : static Return test0011_1(void)
      14                 :             : {
      15                 :           2 :         INITTEST;
      16                 :             : 
      17                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      18                 :             : 
      19                 :             :         // Create memory for the result
      20                 :           2 :         m_create(char,result,MEMORY_STRING);
      21                 :           2 :         m_create(char,chunk,MEMORY_STRING);
      22                 :             : 
      23                 :           2 :         const char *arguments = "--progress --database=database1.db "
      24                 :             :                 "tests/fixtures/diffs/diff1";
      25                 :             : 
      26                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      27                 :           2 :         ASSERT(SUCCESS == m_copy(result,chunk));
      28                 :             : 
      29                 :           2 :         arguments = "--progress --database=database2.db "
      30                 :             :                 "tests/fixtures/diffs/diff2";
      31                 :             : 
      32                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      33                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
      34                 :             : 
      35                 :           2 :         arguments = "--compare --check-level=QUICK database1.db database2.db";
      36                 :             : 
      37                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      38                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
      39                 :             : 
      40                 :           2 :         m_create(char,pattern,MEMORY_STRING);
      41                 :             : 
      42                 :           2 :         const char *filename = "templates/0011_001.txt";
      43                 :             : 
      44                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      45                 :             : 
      46                 :             :         // Match the result against the pattern
      47                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      48                 :             : 
      49                 :             :         // Clean up test results
      50                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
      51                 :           2 :         ASSERT(SUCCESS == delete_path("database2.db"));
      52                 :             : 
      53                 :           2 :         m_del(pattern);
      54                 :           2 :         m_del(chunk);
      55                 :           2 :         m_del(result);
      56                 :             : 
      57                 :           2 :         RETURN_STATUS;
      58                 :             : }
      59                 :             : 
      60                 :             : /**
      61                 :             :  * @brief Verify updates and the existing-database warning with progress enabled
      62                 :             :  *
      63                 :             :  * The Example 2 from README
      64                 :             :  * Updating the database:
      65                 :             :  * Stage 1. Adding:
      66                 :             :  * precizer --progress --database=database1.db tests/fixtures/diffs/diff1
      67                 :             :  * Stage 2. Repeat the scan through CLI and configuration without --update.
      68                 :             :  * Both runs must show the same warning and leave the database unchanged:
      69                 :             :  * precizer --progress --check-level=QUICK --database=database1.db tests/fixtures/diffs/diff1
      70                 :             :  * Stage 3. Run of database update without making actual changes to disk:
      71                 :             :  * precizer --update --check-level=QUICK --progress --database=database1.db tests/fixtures/diffs/diff1
      72                 :             :  * Stage 4. Now let's make some changes:
      73                 :             :  * # Backup
      74                 :             :  * prepare_mutable_fixture("tests/fixtures/diffs/diff1")
      75                 :             :  * # Modify a file
      76                 :             :  * echo -n "  " >> tests/fixtures/diffs/diff1/1/AAA/BCB/CCC/a.txt
      77                 :             :  * # Add a new file by truncating the file with the target name
      78                 :             :  * truncate_file_to_zero_size("tests/fixtures/diffs/diff1/1/AAA/BCB/CCC/c.txt")
      79                 :             :  * # Remove a file
      80                 :             :  * delete_path("tests/fixtures/diffs/diff1/path2/AAA/ZAW/D/e/f/b_file.txt")
      81                 :             :  * Stage 5. Run the precizer once again:
      82                 :             :  * precizer --update --check-level=QUICK --progress --database=database1.db tests/fixtures/diffs/diff1
      83                 :             :  * Final stage. Recover from backup:
      84                 :             :  * restore_mutable_fixture("tests/fixtures/diffs/diff1")
      85                 :             :  */
      86                 :           2 : static Return test0011_2(void)
      87                 :             : {
      88                 :           2 :         INITTEST;
      89                 :             : 
      90                 :             :         // Preparation for tests
      91                 :           2 :         ASSERT(SUCCESS == prepare_mutable_fixture("tests/fixtures/diffs/diff1"));
      92                 :             : 
      93                 :           2 :         const char *arguments = "--progress --database=database1.db "
      94                 :             :                 "tests/fixtures/diffs/diff1";
      95                 :             : 
      96                 :             :         // Create memory for the result
      97                 :           2 :         m_create(char,result,MEMORY_STRING);
      98                 :             : 
      99                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
     100                 :             : 
     101                 :           2 :         m_create(char,pattern,MEMORY_STRING);
     102                 :             : 
     103                 :           2 :         const char *filename = "templates/0011_002_1.txt";
     104                 :             : 
     105                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
     106                 :             : 
     107                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
     108                 :             : 
     109                 :             :         // Match the result against the pattern
     110                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
     111                 :             : 
     112                 :             :         // Clean to use it iteratively
     113                 :           2 :         m_del(pattern);
     114                 :           2 :         m_del(result);
     115                 :             : 
     116                 :           2 :         arguments = "--progress --check-level=QUICK --database=database1.db "
     117                 :             :                 "tests/fixtures/diffs/diff1";
     118                 :             : 
     119                 :           2 :         filename = "templates/0011_002_2.txt";
     120                 :             : 
     121                 :           2 :         const struct argument_test_case cases[] = {
     122                 :             :                 {arguments,WARNING,filename,STDERR_MUST_BE_EMPTY},
     123                 :             :                 {0}
     124                 :             :         };
     125                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
     126                 :             : 
     127                 :             :         /* The rejected update leaves the same database ready for the configuration run */
     128                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0011_002_2.conf","0011_002_2.conf"));
     129                 :           2 :         const struct argument_test_case file_cases[] = {
     130                 :             :                 {"--config=0011_002_2.conf",WARNING,filename,STDERR_MUST_BE_EMPTY},
     131                 :             :                 {0}
     132                 :             :         };
     133                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,NULL,NULL));
     134                 :           2 :         call(delete_path_if_present("0011_002_2.conf"));
     135                 :             : 
     136                 :           2 :         m_create(char,chunk,MEMORY_STRING);
     137                 :             : 
     138                 :           2 :         arguments = "--update --check-level=QUICK --progress --database=database1.db "
     139                 :             :                 "tests/fixtures/diffs/diff1";
     140                 :             : 
     141                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     142                 :             : 
     143                 :           2 :         ASSERT(SUCCESS == m_copy(result,chunk));
     144                 :             : 
     145                 :           2 :         ASSERT(SUCCESS == add_string_to("  ","tests/fixtures/diffs/diff1/1/AAA/BCB/CCC/a.txt"));
     146                 :           2 :         ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1/path2/AAA/ZAW/D/e/f/b_file.txt"));
     147                 :             : 
     148                 :             :         // Create the file as empty without using shell touch
     149                 :           2 :         ASSERT(SUCCESS == truncate_file_to_zero_size("tests/fixtures/diffs/diff1/1/AAA/BCB/CCC/c.txt"));
     150                 :             : 
     151                 :           2 :         arguments = "--watch-timestamps --update --check-level=QUICK --progress "
     152                 :             :                 "--database=database1.db tests/fixtures/diffs/diff1";
     153                 :             : 
     154                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     155                 :             : 
     156                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
     157                 :             : 
     158                 :           2 :         filename = "templates/0011_002_3.txt";
     159                 :             : 
     160                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
     161                 :             : 
     162                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
     163                 :             : 
     164                 :           2 :         m_del(pattern);
     165                 :           2 :         m_del(result);
     166                 :           2 :         m_del(chunk);
     167                 :             : 
     168                 :             :         // Don't clean up test results to use on the next test
     169                 :             : 
     170                 :           2 :         RETURN_STATUS;
     171                 :             : }
     172                 :             : 
     173                 :             : /**
     174                 :             :  * @brief Verify silent output through CLI and configuration on an unchanged database
     175                 :             :  *
     176                 :             :  * The Example 3 from README
     177                 :             :  * Using the --silent mode. When this mode is enabled, the program suppresses
     178                 :             :  * normal output after command execution. This makes sense when using the
     179                 :             :  * program inside scripts. An exception is --compare: with --silent, compare
     180                 :             :  * results remain
     181                 :             :  * visible. Paths with differences are printed directly, and category headings
     182                 :             :  * are kept only when more than one compare category is active
     183                 :             :  * Let's add the --silent option to the previous example:
     184                 :             :  *
     185                 :             :  * precizer --silent --update --check-level=QUICK --progress --database=database1.db tests/fixtures/diffs/diff1
     186                 :             :  *
     187                 :             :  *
     188                 :             :  */
     189                 :           2 : static Return test0011_3(void)
     190                 :             : {
     191                 :           2 :         INITTEST;
     192                 :             : 
     193                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
     194                 :             : 
     195                 :           2 :         const char *arguments = "--silent --update --check-level=QUICK --progress --database=database1.db "
     196                 :             :                 "tests/fixtures/diffs/diff1";
     197                 :             : 
     198                 :             :         // Verify that silent mode produced no stdout after command execution
     199                 :           2 :         const struct argument_test_case silent_cases[] = {
     200                 :             :                 {arguments,COMPLETED,STDOUT_MUST_BE_EMPTY,STDERR_MUST_BE_EMPTY},
     201                 :             :                 {0}
     202                 :             :         };
     203                 :             : 
     204                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(silent_cases,NULL,NULL));
     205                 :             : 
     206                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
     207                 :             : 
     208                 :           2 :         const struct argument_test_case testing_cases[] = {
     209                 :             :                 {arguments,COMPLETED,"templates/0011_003.txt",STDERR_MUST_BE_EMPTY},
     210                 :             :                 {0}
     211                 :             :         };
     212                 :             : 
     213                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(testing_cases,NULL,NULL));
     214                 :             : 
     215                 :             :         /* The unchanged database and fixtures are ready for the configuration repeat */
     216                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0011_003.conf","0011_003.conf"));
     217                 :           2 :         const struct argument_test_case file_cases[] = {
     218                 :             :                 {"--config=0011_003.conf",COMPLETED,"templates/0011_003.txt",STDERR_MUST_BE_EMPTY},
     219                 :             :                 {0}
     220                 :             :         };
     221                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,NULL,NULL));
     222                 :           2 :         call(delete_path_if_present("0011_003.conf"));
     223                 :             : 
     224                 :           2 :         RETURN_STATUS;
     225                 :             : }
     226                 :             : 
     227                 :             : /**
     228                 :             :  * @brief Verify verbose output through CLI and configuration before fixture cleanup
     229                 :             :  *
     230                 :             :  * The Example 4 from README
     231                 :             :  * Additional information with --verbose mode
     232                 :             :  *
     233                 :             :  */
     234                 :           2 : static Return test0011_4(void)
     235                 :             : {
     236                 :           2 :         INITTEST;
     237                 :             : 
     238                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
     239                 :             : 
     240                 :           2 :         const char *arguments = "--verbose --update --check-level=QUICK --progress --database=database1.db "
     241                 :             :                 "tests/fixtures/diffs/diff1";
     242                 :             : 
     243                 :           2 :         const struct argument_test_case cases[] = {
     244                 :             :                 {arguments,COMPLETED,"templates/0011_004_1.txt",STDERR_MUST_BE_EMPTY},
     245                 :             :                 {0}
     246                 :             :         };
     247                 :             : 
     248                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
     249                 :             : 
     250                 :             :         /* Repeat the same unchanged update before the shared database is removed */
     251                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0011_004_1.conf","0011_004_1.conf"));
     252                 :           2 :         const struct argument_test_case file_cases[] = {
     253                 :             :                 {"--config=0011_004_1.conf",COMPLETED,"templates/0011_004_1.txt",STDERR_MUST_BE_EMPTY},
     254                 :             :                 {0}
     255                 :             :         };
     256                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,NULL,NULL));
     257                 :           2 :         call(delete_path_if_present("0011_004_1.conf"));
     258                 :             : 
     259                 :             :         // Clean up test results
     260                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
     261                 :           2 :         ASSERT(SUCCESS == restore_mutable_fixture("tests/fixtures/diffs/diff1"));
     262                 :             : 
     263                 :           2 :         RETURN_STATUS;
     264                 :             : }
     265                 :             : 
     266                 :             : /**
     267                 :             :  * @brief Verify depth zero through CLI and configuration before an unlimited update
     268                 :             :  *
     269                 :             :  * The Example 5 from README
     270                 :             :  * Disable recursion with --maxdepth=0 option
     271                 :             :  *
     272                 :             :  * Both initial scans start without a database and use the same full output
     273                 :             :  * template. The resulting database is then updated without the depth limit
     274                 :             :  */
     275                 :           2 : static Return test0011_5(void)
     276                 :             : {
     277                 :           2 :         INITTEST;
     278                 :             : 
     279                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
     280                 :             : 
     281                 :           2 :         const char *template = "%DB_NAME%";
     282                 :             : 
     283                 :           2 :         const char *replacement = getenv("DBNAME");  // Database name
     284                 :             : 
     285                 :           2 :         ASSERT(replacement != NULL);
     286                 :             : 
     287                 :           2 :         const struct argument_test_case cases[] = {
     288                 :             :                 {"--maxdepth=0 tests/fixtures/4",COMPLETED,"templates/0011_005_1.txt",STDERR_MUST_BE_EMPTY},
     289                 :             :                 {0}
     290                 :             :         };
     291                 :             : 
     292                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,template,replacement));
     293                 :             : 
     294                 :             :         /* Repeat the initial scan without a database, then retain its result for the update */
     295                 :           2 :         ASSERT(SUCCESS == delete_path(replacement));
     296                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0011_005_1.conf","0011_005_1.conf"));
     297                 :           2 :         const struct argument_test_case file_cases[] = {
     298                 :             :                 {"--config=0011_005_1.conf",COMPLETED,"templates/0011_005_1.txt",STDERR_MUST_BE_EMPTY},
     299                 :             :                 {0}
     300                 :             :         };
     301                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,template,replacement));
     302                 :           2 :         call(delete_path_if_present("0011_005_1.conf"));
     303                 :             : 
     304                 :           2 :         const struct argument_test_case update_cases[] = {
     305                 :             :                 /* At the second stage, the --maxdepth=0 option is not used.
     306                 :             :                    Therefore, all files that were not previously included
     307                 :             :                    will be added to the database */
     308                 :             :                 {"--update --check-level=QUICK tests/fixtures/4",COMPLETED,"templates/0011_005_2.txt",STDERR_MUST_BE_EMPTY},
     309                 :             :                 {0}
     310                 :             :         };
     311                 :             : 
     312                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(update_cases,template,replacement));
     313                 :             : 
     314                 :           2 :         ASSERT(SUCCESS == delete_path(replacement));
     315                 :             : 
     316                 :           2 :         RETURN_STATUS;
     317                 :             : }
     318                 :             : 
     319                 :             : /**
     320                 :             :  *
     321                 :             :  * The Example 6 from README
     322                 :             :  * Relative path to ignore with --ignore
     323                 :             :  *
     324                 :             :  *
     325                 :             :  */
     326                 :           2 : static Return test0011_6(void)
     327                 :             : {
     328                 :           2 :         INITTEST;
     329                 :             : 
     330                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
     331                 :             : 
     332                 :           2 :         const char *template = "%DB_NAME%";
     333                 :             : 
     334                 :           2 :         const char *replacement = getenv("DBNAME");  // Database name
     335                 :             : 
     336                 :           2 :         ASSERT(replacement != NULL);
     337                 :             : 
     338                 :           2 :         const struct argument_test_case cases[] = {
     339                 :             :                 {"--ignore=\"^diff1/1/.*\" tests/fixtures/diffs",COMPLETED,"templates/0011_006_1.txt",STDERR_MUST_BE_EMPTY},
     340                 :             :                 {"--update --check-level=QUICK tests/fixtures/diffs",COMPLETED,"templates/0011_006_2.txt",STDERR_MUST_BE_EMPTY},
     341                 :             :                 {0}
     342                 :             :         };
     343                 :             : 
     344                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,template,replacement));
     345                 :             : 
     346                 :           2 :         RETURN_STATUS;
     347                 :             : }
     348                 :             : 
     349                 :             : /**
     350                 :             :  *
     351                 :             :  * The Example 7 from README
     352                 :             :  * Multiple regular expressions for ignoring can be specified
     353                 :             :  * using many --ignore options
     354                 :             :  *
     355                 :             :  */
     356                 :           2 : static Return test0011_7(void)
     357                 :             : {
     358                 :           2 :         INITTEST;
     359                 :             : 
     360                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
     361                 :             : 
     362                 :           2 :         const char *arguments = "--update --check-level=QUICK --db-drop-ignored"
     363                 :             :                 " --ignore=\"^diff1/1/.*\""
     364                 :             :                 " --ignore=\"^diff2/1/.*\" tests/fixtures/diffs";
     365                 :             : 
     366                 :           2 :         const char *filename = "templates/0011_007.txt";
     367                 :             : 
     368                 :           2 :         const char *template = "%DB_NAME%";
     369                 :             : 
     370                 :           2 :         const char *replacement = getenv("DBNAME");  // Database name
     371                 :             : 
     372                 :           2 :         ASSERT(replacement != NULL);
     373                 :             : 
     374                 :           2 :         const struct argument_test_case cases[] = {
     375                 :             :                 {arguments,COMPLETED,filename,STDERR_MUST_BE_EMPTY},
     376                 :             :                 {0}
     377                 :             :         };
     378                 :             : 
     379                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,template,replacement));
     380                 :             : 
     381                 :           2 :         ASSERT(SUCCESS == delete_path(replacement));
     382                 :             : 
     383                 :           2 :         RETURN_STATUS;
     384                 :             : }
     385                 :             : 
     386                 :             : /**
     387                 :             :  *
     388                 :             :  * The Example 8 from README
     389                 :             :  * Using the --ignore options together with --include
     390                 :             :  * Also covers the compare example that narrows the reported comparison scope
     391                 :             :  *
     392                 :             :  * The cleanup update is repeated through configuration from the same saved
     393                 :             :  * database, retaining all ignore and include rules and the full output check
     394                 :             :  */
     395                 :           2 : static Return test0011_8(void)
     396                 :             : {
     397                 :           2 :         INITTEST;
     398                 :             : 
     399                 :           2 :         const char *arguments = "tests/fixtures/diffs";
     400                 :             : 
     401                 :           2 :         ASSERT(SUCCESS == runit(arguments,NULL,NULL,COMPLETED,ALLOW_BOTH));
     402                 :             : 
     403                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
     404                 :             : 
     405                 :           2 :         arguments = "--update --check-level=QUICK"
     406                 :             :                 " --progress"
     407                 :             :                 " --ignore=\"^.*/path2/.*\""
     408                 :             :                 " --ignore=\"^diff2/.*\""
     409                 :             :                 " --include=\"^diff2/1/AAA/ZAW/A/b/c/.*\""
     410                 :             :                 " --include=\"^diff2/path1/AAA/ZAW/.*\""
     411                 :             :                 " --include=\"^diff1/path2/AAA/ZAW/A/b/c/a_file\\..*\""
     412                 :             :                 " --db-drop-ignored"
     413                 :             :                 " tests/fixtures/diffs";
     414                 :             : 
     415                 :           2 :         const char *filename = "templates/0011_008_1.txt";
     416                 :             : 
     417                 :           2 :         const char *template = "%DB_NAME%";
     418                 :             : 
     419                 :           2 :         const char *replacement = getenv("DBNAME");  // Database name
     420                 :             : 
     421                 :           2 :         ASSERT(replacement != NULL);
     422                 :             : 
     423                 :           2 :         const struct argument_test_case update_cases[] = {
     424                 :             :                 {arguments,COMPLETED,filename,STDERR_MUST_BE_EMPTY},
     425                 :             :                 {0}
     426                 :             :         };
     427                 :             : 
     428                 :             :         /* Preserve the prepared database before either cleanup update */
     429                 :           2 :         ASSERT(SUCCESS == copy_path(replacement,"0011_008_1.db"));
     430                 :             : 
     431                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(update_cases,template,replacement));
     432                 :             : 
     433                 :             :         /* Repeat the same cleanup with all filtering rules supplied by configuration */
     434                 :           2 :         ASSERT(SUCCESS == copy_path("0011_008_1.db",replacement));
     435                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0011_008_1.conf","0011_008_1.conf"));
     436                 :           2 :         const struct argument_test_case file_cases[] = {
     437                 :             :                 {"--config=0011_008_1.conf",COMPLETED,filename,STDERR_MUST_BE_EMPTY},
     438                 :             :                 {0}
     439                 :             :         };
     440                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,template,replacement));
     441                 :           2 :         call(delete_path_if_present("0011_008_1.conf"));
     442                 :           2 :         call(delete_path_if_present("0011_008_1.db"));
     443                 :             : 
     444                 :           2 :         ASSERT(SUCCESS == delete_path(replacement));
     445                 :             : 
     446                 :           2 :         arguments = "--progress --database=database1.db tests/fixtures/diffs/diff1";
     447                 :             : 
     448                 :           2 :         ASSERT(SUCCESS == runit(arguments,NULL,NULL,COMPLETED,ALLOW_BOTH));
     449                 :             : 
     450                 :           2 :         arguments = "--progress --database=database2.db tests/fixtures/diffs/diff2";
     451                 :             : 
     452                 :           2 :         ASSERT(SUCCESS == runit(arguments,NULL,NULL,COMPLETED,ALLOW_BOTH));
     453                 :             : 
     454                 :           2 :         arguments = "--compare --check-level=QUICK"
     455                 :             :                 " --ignore=\"^(?:2|3|4)/.*\""
     456                 :             :                 " --ignore=\"^path1/.*\""
     457                 :             :                 " --ignore=\"^path2/.*\""
     458                 :             :                 " --include=\"^2/AAA/BBB/CZC/a\\.txt$\""
     459                 :             :                 " database1.db database2.db";
     460                 :             : 
     461                 :           2 :         filename = "templates/0011_008_2.txt";
     462                 :             : 
     463                 :           2 :         const struct argument_test_case compare_cases[] = {
     464                 :             :                 {arguments,COMPLETED,filename,STDERR_MUST_BE_EMPTY},
     465                 :             :                 {0}
     466                 :             :         };
     467                 :             : 
     468                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(compare_cases,NULL,NULL));
     469                 :             : 
     470                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
     471                 :           2 :         ASSERT(SUCCESS == delete_path("database2.db"));
     472                 :             : 
     473                 :           2 :         RETURN_STATUS;
     474                 :             : }
     475                 :             : 
     476                 :             : /**
     477                 :             :  *
     478                 :             :  * User's Manual and examples from README test set
     479                 :             :  *
     480                 :             :  */
     481                 :           2 : Return test0011(void)
     482                 :             : {
     483                 :             :         /// The status that will be passed to return() before exiting.
     484                 :             :         /// By default, the function worked without errors.
     485                 :           2 :         INITTEST;
     486                 :             : 
     487                 :           2 :         TEST(test0011_1,"README Example 1 Adding and comparing");
     488                 :           2 :         TEST(test0011_2,"README Example 2 Updating the data in DB");
     489                 :           2 :         TEST(test0011_3,"README Example 3 --silent mode");
     490                 :           2 :         TEST(test0011_4,"README Example 4 --verbose mode");
     491                 :           2 :         TEST(test0011_5,"README Example 5 Disable recursion with --maxdepth");
     492                 :           2 :         TEST(test0011_6,"README Example 6 Relative path to ignore with --ignore");
     493                 :           2 :         TEST(test0011_7,"README Example 7 Multiple regexp for ignoring");
     494                 :           2 :         TEST(test0011_8,"README Example 8 The --ignore options together with --include, including the compare-scope example");
     495                 :           2 :         SUTE(test0030,"README Examples 9 & 10: --lock-checksum with --rehash-locked and --watch-timestamps");
     496                 :           2 :         SUTE(test0029,"README Example 11: Testing how the application behaves with inaccessible files");
     497                 :             : 
     498                 :           2 :         RETURN_STATUS;
     499                 :             : }
        

Generated by: LCOV version 2.0-1