Hi, Am Tue, 11 Jun 2013 22:44:28 +0200 schrieb Uli Schlachter <[email protected]>:
> > If I get it right, your commit adds a warning when parsing the > > config failes on runtime. Do you think it's a good start to use this > > for warnings on deprecated terms? > > http://git.naquadah.org/?p=awesome.git;a=blobdiff;f=luaa.c;h=7c94dac0d247657c815aafa97632853157e4db57;hp=d484172310dc0a1fdd40473507d4bcd3a3435018;hb=3739aabda1323dc488c5150aed166e2fd37edf56;hpb=3f259d0ed2469eb4bfea565628e38138c9c1c06f > > That URL seems wrong. It seems like you meant to quote this one > instead (otherwise: Why are you digging out ancient commits?): I wanted to show the called function. > http://git.naquadah.org/?p=awesome.git;a=commitdiff;h=0c62831eea5e651577928ef8b09c947565eaed7d > as you see this now contains a backtrace. I had a deeper look on the --check function. Currently it silently ignores my specified config file (see attached patch): $ awesome -k -c rc.l ✔ Configuration file syntax OK. $ awesome -c rc.l -k cannot open rc.l: No such file or directory ✘ Configuration file syntax error. It does not check, if the specified functions exist: awesome -c rc.lua -k ✔ Configuration file syntax OK. awesome -c rc.lua.wrong -k ✔ Configuration file syntax OK. $ diff rc.lua rc.lua.wrong 26c26 < awesome.connect_signal("debug::error", function (err) --- > awesome.add_signal("debug::error", function (err) It only tries to parse it and prints the result. if(!luaA_parserc(&xdg, confpath, false)) { fprintf(stderr, "✘ Configuration file syntax error.\n"); return EXIT_FAILURE; } else { fprintf(stderr, "✔ Configuration file syntax OK.\n"); return EXIT_SUCCESS; } Also luaA_parserc does basically nothing more than if(luaA_loadrc(confpatharg, run)) { ret = true; goto bailout; } else if(!run) goto bailout; As you can see luaA_loadrc is called without the instruction to really run the program. For that reason the check will not find basic errors like misspelled functions. One has to use Xephyr for that kind of validation. I suggeset to implement a three step test for 1) syntax 2) deprecated terms 3) Xephyr. The user supplied configuration file will be tested life if Xephyr is installed. Otherwise it gives the hint to install it for 'really' testing the configuration. kardan
From 386ad6bfd134833a19e40c1920975e100f207a51 Mon Sep 17 00:00:00 2001 From: kardan <[email protected]> Date: Wed, 12 Jun 2013 14:15:54 +0200 Subject: [PATCH] honor appended -c option for --check --- awesome.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/awesome.c b/awesome.c index 4755d1c..776417e 100644 --- a/awesome.c +++ b/awesome.c @@ -288,6 +288,7 @@ main(int argc, char **argv) ssize_t cmdlen = 1; xdgHandle xdg; bool no_argb = false; + bool run_test = false; xcb_generic_event_t *event; xcb_query_tree_cookie_t tree_c; static struct option long_options[] = @@ -331,6 +332,7 @@ main(int argc, char **argv) /* check args */ while((opt = getopt_long(argc, argv, "vhkc:a", long_options, NULL)) != -1) + { switch(opt) { case 'v': @@ -340,16 +342,8 @@ main(int argc, char **argv) exit_help(EXIT_SUCCESS); break; case 'k': - if(!luaA_parserc(&xdg, confpath, false)) - { - fprintf(stderr, "â Configuration file syntax error.\n"); - return EXIT_FAILURE; - } - else - { - fprintf(stderr, "â Configuration file syntax OK.\n"); - return EXIT_SUCCESS; - } + run_test = true; + break; case 'c': if(a_strlen(optarg)) confpath = a_strdup(optarg); @@ -360,7 +354,22 @@ main(int argc, char **argv) no_argb = true; break; } - + } + + if (run_test) + { + if(!luaA_parserc(&xdg, confpath, false)) + { + fprintf(stderr, "â Configuration file syntax error.\n"); + return EXIT_FAILURE; + } + else + { + fprintf(stderr, "â Configuration file syntax OK.\n"); + return EXIT_SUCCESS; + } + } + /* register function for signals */ g_unix_signal_add(SIGINT, exit_on_signal, NULL); g_unix_signal_add(SIGTERM, exit_on_signal, NULL); -- 1.7.10.4
