Test coverage: make LCOV ignore bug() and all calls to BUG()
authorAaron Traas <aaron@traas.org>
Wed, 28 Jun 2017 16:21:05 +0000 (12:21 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 28 Jun 2017 17:23:34 +0000 (13:23 -0400)
In theory, these should be unreachable, so they shouldn't be covered
with testing.

actions.c
main.c
misc.c

index d2eb46ba2320f76f449c5a3a5a60f2a52e2a9272..16d303f10d60c216b128eca5a17af5ec2e9ee2a7 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -1138,7 +1138,7 @@ int action(FILE *input, struct command_t *command)
             case PART:
                 return reservoir();
            default:
-               BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
+               BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
             }
         }
     /* FALLTHRU */
@@ -1235,13 +1235,13 @@ int action(FILE *input, struct command_t *command)
        case PART:
             return reservoir();
     default:
-        BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
+        BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
     }
     case unknown:
         /* Unknown verb, couldn't deduce object - might need hint */
         rspeak(WHAT_DO, command->wd1, command->wd1x);
         return GO_CHECKHINT;
     default:
-        BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN);
+        BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN); // LCOV_EXCL_LINE
     }
 }
diff --git a/main.c b/main.c
index 8acae39e43bc2b94aea85d3147643a2f995dcf04..3f4140971fcc09d5d4134f28c7d0682e592b71bf 100644 (file)
--- a/main.c
+++ b/main.c
@@ -250,7 +250,7 @@ static void checkhints(void)
                     game.hintlc[hint] = 0;
                     return;
                 default:
-                    BUG(HINT_NUMBER_EXCEEDS_GOTO_LIST);
+                    BUG(HINT_NUMBER_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
                     break;
                 }
 
@@ -524,7 +524,7 @@ static bool playermove(token_t verb, int motion)
     int scratchloc, k2, kk = tkey[game.loc];
     game.newloc = game.loc;
     if (kk == 0)
-        BUG(LOCATION_HAS_NO_TRAVEL_ENTRIES);
+        BUG(LOCATION_HAS_NO_TRAVEL_ENTRIES); // LCOV_EXCL_LINE
     if (motion == NUL)
         return true;
     else if (motion == BACK) {
@@ -640,7 +640,7 @@ static bool playermove(token_t verb, int motion)
                     break;
                 do {
                     if (travel[kk].stop)
-                        BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
+                        BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
                     ++kk;
                     game.newloc = T_HIGH(travel[kk]);
                 } while
@@ -681,7 +681,7 @@ static bool playermove(token_t verb, int motion)
                     drop(EMERALD, game.loc);
                     do {
                         if (travel[kk].stop)
-                            BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
+                            BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
                         ++kk;
                         game.newloc = T_HIGH(travel[kk]);
                     } while
@@ -723,7 +723,7 @@ static bool playermove(token_t verb, int motion)
                         return true;
                     }
                default:
-                   BUG(SPECIAL_TRAVEL_500_GT_L_GT_300_EXCEEDS_GOTO_LIST);
+                   BUG(SPECIAL_TRAVEL_500_GT_L_GT_300_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
                 }
             }
             break; /* Leave L12 loop */
@@ -1113,7 +1113,7 @@ Lookup:
             rspeak(kmod);
             goto L2012;
         default:
-            BUG(VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3);
+            BUG(VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3); // LCOV_EXCL_LINE
         }
 
 Laction:
@@ -1150,7 +1150,7 @@ Laction:
             rspeak(DWARVES_AWAKEN);
             terminate(endgame);
         default:
-            BUG(ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH);
+            BUG(ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH); // LCOV_EXCL_LINE
         }
     }
 }
diff --git a/misc.c b/misc.c
index b01662f5120f4739cea47623b433c7e15ae58cc2..81f8e2b2bd4f0212d258495fb0bed42403a7501b 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -411,7 +411,7 @@ long vocab(long id, long init)
             lexeme = -1;
             if (init < 0)
                 return (lexeme);
-            BUG(REQUIRED_VOCABULARY_WORD_NOT_FOUND);
+            BUG(REQUIRED_VOCABULARY_WORD_NOT_FOUND); // LCOV_EXCL_LINE
         }
         if (init >= 0 && KTAB[i] / 1000 != init)
             continue;
@@ -422,7 +422,7 @@ long vocab(long id, long init)
             return (lexeme);
         }
     }
-    BUG(RAN_OFF_END_OF_VOCABULARY_TABLE);
+    BUG(RAN_OFF_END_OF_VOCABULARY_TABLE); // LCOV_EXCL_LINE
 }
 
 void juggle(long object)
@@ -690,10 +690,12 @@ void datime(long* d, long* t)
     *t = (long) tv.tv_usec;
 }
 
+// LCOV_EXCL_START
 void bug(enum bugtype num, const char *error_string)
 {
     fprintf(stderr, "Fatal error %d, %s.\n", num, error_string);
     exit(EXIT_FAILURE);
 }
+// LCOV_EXCL_STOP
 
 /* end */