From 421167362242ce1fb46d6d720798787e7cd65aad Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 10 Aug 2017 23:33:47 -0400 Subject: [PATCH] Exclude flex-generated code from coverage testing 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 --- contrib/cube/cubescan.l | 4 ++++ contrib/seg/segscan.l | 4 ++++ src/backend/bootstrap/bootscanner.l | 3 +++ src/backend/parser/scan.l | 5 +++++ src/backend/replication/repl_scanner.l | 3 +++ src/backend/replication/syncrep_scanner.l | 3 +++ src/backend/utils/misc/guc-file.l | 4 +++- src/bin/pgbench/exprscan.l | 4 ++++ src/bin/psql/psqlscanslash.l | 4 ++++ src/fe_utils/psqlscan.l | 4 ++++ src/interfaces/ecpg/preproc/pgc.l | 6 ++++++ src/test/isolation/specscanner.l | 4 ++++ 12 files changed, 47 insertions(+), 1 deletion(-) diff --git a/contrib/cube/cubescan.l b/contrib/cube/cubescan.l index dada9178202..bd400e36842 100644 --- a/contrib/cube/cubescan.l +++ b/contrib/cube/cubescan.l @@ -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) diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l index 6db24fdd1f7..5f6595e9eb2 100644 --- a/contrib/seg/segscan.l +++ b/contrib/seg/segscan.l @@ -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) { diff --git a/src/backend/bootstrap/bootscanner.l b/src/backend/bootstrap/bootscanner.l index 51c5e5e3cd6..5465217bc30 100644 --- a/src/backend/bootstrap/bootscanner.l +++ b/src/backend/bootstrap/bootscanner.l @@ -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) { diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l index 634bfa512f4..6af2199cdc5 100644 --- a/src/backend/parser/scan.l +++ b/src/backend/parser/scan.l @@ -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 diff --git a/src/backend/replication/repl_scanner.l b/src/backend/replication/repl_scanner.l index 62bb5288c01..568d55ac953 100644 --- a/src/backend/replication/repl_scanner.l +++ b/src/backend/replication/repl_scanner.l @@ -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) diff --git a/src/backend/replication/syncrep_scanner.l b/src/backend/replication/syncrep_scanner.l index d1d1b26a480..1fbc936aa6f 100644 --- a/src/backend/replication/syncrep_scanner.l +++ b/src/backend/replication/syncrep_scanner.l @@ -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 diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l index f01b814c6ed..3de8e791f21 100644 --- a/src/backend/utils/misc/guc-file.l +++ b/src/backend/utils/misc/guc-file.l @@ -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 diff --git a/src/bin/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l index 9bf6d237f57..9f46fb9db88 100644 --- a/src/bin/pgbench/exprscan.l +++ b/src/bin/pgbench/exprscan.l @@ -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) { diff --git a/src/bin/psql/psqlscanslash.l b/src/bin/psql/psqlscanslash.l index 9a53cb3e02b..e3cde04188a 100644 --- a/src/bin/psql/psqlscanslash.l +++ b/src/bin/psql/psqlscanslash.l @@ -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 diff --git a/src/fe_utils/psqlscan.l b/src/fe_utils/psqlscan.l index 4375142a007..44fcf7ee46e 100644 --- a/src/fe_utils/psqlscan.l +++ b/src/fe_utils/psqlscan.l @@ -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. * diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index fc450f30ab4..e35843ba4ed 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -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})((\/\*[^*/]*\*+ } } {other}|\n { mmfatal(PARSE_ERROR, "internal error: unreachable state; please report this to "); } + %% + +/* LCOV_EXCL_STOP */ + void lex_init(void) { diff --git a/src/test/isolation/specscanner.l b/src/test/isolation/specscanner.l index a9528bda6bb..9c0532c0c5b 100644 --- a/src/test/isolation/specscanner.l +++ b/src/test/isolation/specscanner.l @@ -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) {