Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Exclude flex-generated code from coverage testing
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 11 Aug 2017 03:33:47 +0000 (23:33 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Mon, 16 Oct 2017 20:28:11 +0000 (16:28 -0400)
Flex generates a lot of functions that are not actually used.  In order
to avoid coverage figures being ruined by that, mark up the part of the
.l files where the generated code appears by lcov exclusion markers.
That way, lcov will typically only reported on coverage for the .l file,
which is under our control, but not for the .c file.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
12 files changed:
contrib/cube/cubescan.l
contrib/seg/segscan.l
src/backend/bootstrap/bootscanner.l
src/backend/parser/scan.l
src/backend/replication/repl_scanner.l
src/backend/replication/syncrep_scanner.l
src/backend/utils/misc/guc-file.l
src/bin/pgbench/exprscan.l
src/bin/psql/psqlscanslash.l
src/fe_utils/psqlscan.l
src/interfaces/ecpg/preproc/pgc.l
src/test/isolation/specscanner.l

index dada9178202d8ad555d4ea0705f269af7cb5dad5..bd400e36842917ba3fbd0f2ef98428057409b316 100644 (file)
@@ -4,6 +4,8 @@
  * contrib/cube/cubescan.l
  */
 
+/* LCOV_EXCL_START */
+
 /* No reason to constrain amount of data slurped */
 #define YY_READ_BUF_SIZE 16777216
 
@@ -56,6 +58,8 @@ NaN          [nN][aA][nN]
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 /* result is not used, but Bison expects this signature */
 void
 yyerror(NDBOX **result, const char *message)
index 6db24fdd1f79551d6540ee0fd5befbd7a36808e4..5f6595e9eb25b38c03f4eac065609ca51e5dee05 100644 (file)
@@ -3,6 +3,8 @@
  * A scanner for EMP-style numeric ranges
  */
 
+/* LCOV_EXCL_START */
+
 /* No reason to constrain amount of data slurped */
 #define YY_READ_BUF_SIZE 16777216
 
@@ -51,6 +53,8 @@ float        ({integer}|{real})([eE]{integer})?
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 void
 yyerror(SEG *result, const char *message)
 {
index 51c5e5e3cd637d4b258a474bb7b7a9880d2f4243..5465217bc30b30a6513dd9392ade8763c3ea8468 100644 (file)
@@ -38,6 +38,7 @@
 /* Not needed now that this file is compiled as part of bootparse. */
 /* #include "bootparse.h" */
 
+/* LCOV_EXCL_START */
 
 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
 #undef fprintf
@@ -134,6 +135,8 @@ insert          { return INSERT_TUPLE; }
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 void
 yyerror(const char *message)
 {
index 634bfa512f4fff37e3010dfedc68fd5e49fb6b3b..6af2199cdc5ca3f598a471bc09ed66c9b64239ac 100644 (file)
@@ -41,6 +41,9 @@
 }
 
 %{
+
+/* LCOV_EXCL_START */
+
 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
 #undef fprintf
 #define fprintf(file, fmt, msg)  fprintf_to_ereport(fmt, msg)
@@ -1011,6 +1014,8 @@ other         .
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 /*
  * Arrange access to yyextra for subroutines of the main yylex() function.
  * We expect each subroutine to have a yyscanner parameter.  Rather than
index 62bb5288c0196b32a157526e3f5bc3d3ea507099..568d55ac953eb47ba6ce4446ff82b020b2ce1dff 100644 (file)
@@ -38,6 +38,8 @@ static char *litbufdup(void);
 static void addlit(char *ytext, int yleng);
 static void addlitchar(unsigned char ychar);
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -186,6 +188,7 @@ WAIT                { return K_WAIT; }
                }
 %%
 
+/* LCOV_EXCL_STOP */
 
 static void
 startlit(void)
index d1d1b26a480a01720f64fa40d2c4d6347414fceb..1fbc936aa6f7099ea8522db79a553a49de2757fc 100644 (file)
@@ -32,6 +32,8 @@ static YY_BUFFER_STATE scanbufhandle;
 
 static StringInfoData xdbuf;
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -112,6 +114,7 @@ xdinside        [^"]+
 .          { return JUNK; }
 %%
 
+/* LCOV_EXCL_STOP */
 
 /* Needs to be here for access to yytext */
 void
index f01b814c6edfcc035959e4b3d6ab2b35560b68a6..3de8e791f217a4c2dae4d728c8d0b18b3a7b81c4 100644 (file)
@@ -57,6 +57,8 @@ static void record_config_file_error(const char *errmsg,
 static int GUC_flex_fatal(const char *msg);
 static char *GUC_scanstr(const char *s);
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -107,7 +109,7 @@ STRING          \'([^'\\\n]|\\.|\'\')*\'
 
 %%
 
-
+/* LCOV_EXCL_STOP */
 
 /*
  * Exported function to read and process the configuration file. The
index 9bf6d237f570c3dcf0078ee22f827a0a9b6adac0..9f46fb9db885e6a5d187c8daa171c72198735c13 100644 (file)
@@ -43,6 +43,8 @@ static bool last_was_newline = false;
 extern int expr_yyget_column(yyscan_t yyscanner);
 extern void expr_yyset_column(int column_no, yyscan_t yyscanner);
 
+/* LCOV_EXCL_START */
+
 %}
 
 /* Except for the prefix, these options should match psqlscan.l */
@@ -190,6 +192,8 @@ continuation    \\{newline}
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 void
 expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more)
 {
index 9a53cb3e02baacf97b9e42a33e62e2f91b3e52da..e3cde04188a088175acd133dc54d909a7ee17c1b 100644 (file)
@@ -67,6 +67,8 @@ static void evaluate_backtick(PsqlScanState state);
 extern int slash_yyget_column(yyscan_t yyscanner);
 extern void slash_yyset_column(int column_no, yyscan_t yyscanner);
 
+/* LCOV_EXCL_START */
+
 %}
 
 /* Except for the prefix, these options should match psqlscan.l */
@@ -468,6 +470,8 @@ other           .
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 /*
  * Scan the command name of a psql backslash command.  This should be called
  * after psql_scan() returns PSCAN_BACKSLASH.  It is assumed that the input
index 4375142a0072b718e024bfbe80ac5b4195beec37..44fcf7ee46e92f85c27fdc68d42f7a8c6af5e519 100644 (file)
@@ -71,6 +71,8 @@ typedef int YYSTYPE;
 extern int psql_yyget_column(yyscan_t yyscanner);
 extern void psql_yyset_column(int column_no, yyscan_t yyscanner);
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option reentrant
@@ -899,6 +901,8 @@ other           .
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 /*
  * Create a lexer working state struct.
  *
index fc450f30ab4fcea3b53e552c4fc57d8521f4cc7d..e35843ba4edb184fa15917cdc05a568f63f0b149 100644 (file)
@@ -79,6 +79,8 @@ static struct _if_value
    short else_branch;
 } stacked_if_value[MAX_NESTED_IF];
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -1249,7 +1251,11 @@ cppline          {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
                    }
                }
 <INITIAL>{other}|\n    { mmfatal(PARSE_ERROR, "internal error: unreachable state; please report this to <pgsql-bugs@postgresql.org>"); }
+
 %%
+
+/* LCOV_EXCL_STOP */
+
 void
 lex_init(void)
 {
index a9528bda6bbd070e4203eafebeab5841d5819341..9c0532c0c5b7b5be0cc178b72326349fc6c28a79 100644 (file)
@@ -17,6 +17,8 @@ static int litbufpos = 0;
 
 static void addlitchar(char c);
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -93,6 +95,8 @@ teardown      { return TEARDOWN; }
                }
 %%
 
+/* LCOV_EXCL_STOP */
+
 static void
 addlitchar(char c)
 {