[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/6] tests: main: support -s and -p
From: |
Akim Demaille |
Subject: |
[PATCH 2/6] tests: main: support -s and -p |
Date: |
Sun, 9 Jun 2019 11:13:08 +0200 |
* tests/local.at (AT_MAIN_DEFINE(c), AT_MAIN_DEFINE(c++)): here.
---
tests/local.at | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/tests/local.at b/tests/local.at
index 976d9caa..ee55efd6 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -567,10 +567,13 @@ m4_define([AT_MAIN_DEFINE(c)],
int
main (int argc, char const* argv[])
{]AT_DEBUG_IF([[
- if (getenv("YYDEBUG")
- || (argc == 2
- && (!strcmp (argv[1], "-d") || !strcmp (argv[1], "--debug"))))
- yydebug |= 1;]], [[
+ yydebug = !!getenv("YYDEBUG");
+ for (int i = 1; i < argc; ++i)
+ if (!strcmp(argv[i], "-p")
+ || !strcmp (argv[i], "-d") || !strcmp (argv[i], "--debug"))
+ yydebug |= 1;
+ else if (!strcmp (argv[i], "-s") || !strcmp (argv[i], "--stat"))
+ yydebug |= 2;]], [[
(void) argc;
(void) argv;]])[
return ]AT_NAME_PREFIX[parse ();
@@ -615,10 +618,14 @@ int
main (int argc, char const* argv[])
{
]AT_NAMESPACE[::parser p;]AT_DEBUG_IF([[
- if (getenv("YYDEBUG")
- || (argc == 2
- && (!strcmp (argv[1], "-d") || !strcmp (argv[1], "--debug"))))
- p.set_debug_level (true);]], [[
+ int debug = !!getenv("YYDEBUG");
+ for (int i = 1; i < argc; ++i)
+ if (!strcmp(argv[i], "-p")
+ || !strcmp (argv[i], "-d") || !strcmp (argv[i], "--debug"))
+ debug |= 1;
+ else if (!strcmp (argv[i], "-s") || !strcmp (argv[i], "--stat"))
+ debug |= 2;
+ p.set_debug_level (debug);]], [[
(void) argc;
(void) argv;]])[
return p.parse ();
--
2.21.0
- [PATCH 0/6] Clean up tests, Akim Demaille, 2019/06/09
- [PATCH 1/6] tests: remove useless support of '.' in integers, Akim Demaille, 2019/06/09
- [PATCH 2/6] tests: main: support -s and -p,
Akim Demaille <=
- [PATCH 3/6] tests: make sure the default action properly works in C++, Akim Demaille, 2019/06/09
- [PATCH 4/6] traces: add some colors, Akim Demaille, 2019/06/09
- [PATCH 5/6] lr0: more debug traces, Akim Demaille, 2019/06/09
- [PATCH 6/6] CI: factor, Akim Demaille, 2019/06/09