From: Pasi Kallinen Date: Fri, 12 Feb 2021 17:38:40 +0000 (+0200) Subject: Make runmode option complain, add some tests for it X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1097df86d44b9b3dd28b42bc37ff042341850a7;p=nethack Make runmode option complain, add some tests for it --- diff --git a/src/options.c b/src/options.c index a15c4e128..e23620bed 100644 --- a/src/options.c +++ b/src/options.c @@ -2822,8 +2822,10 @@ optfn_runmode(int optidx, int req, boolean negated, char *opts, char *op) allopt[optidx].name, op); return optn_err; } - } else + } else { + config_error_add("Value is mandatory for %s", allopt[optidx].name); return optn_err; + } return optn_ok; } if (req == get_val) { diff --git a/test/test_cnf.lua b/test/test_cnf.lua index 8efdf5553..a177443ac 100644 --- a/test/test_cnf.lua +++ b/test/test_cnf.lua @@ -11,6 +11,20 @@ local configtests = { { test = "OPTIONS=!color\nOPTIONS=color", result = { { line = 2, error = "boolean option specified multiple times: color" } } }, + { test = "OPTIONS=runmode:crawl", + result = { }, + extra = function() return nh.get_config("runmode") == "crawl" end + }, + { test = "OPTIONS=runmode:foo", + result = { { line = 1, error = "Unknown runmode parameter 'foo'" } }, + }, + { test = "OPTIONS=runmode", + result = { { line = 1, error = "Value is mandatory for runmode" } }, + }, + { test = "OPTIONS=!runmode", + result = { }, + extra = function() return nh.get_config("runmode") == "teleport" end + }, }; @@ -37,7 +51,7 @@ for k, v in pairs(configtests) do local res = nh.get_config_errors(); if not testtable(err, res) then - error("Config: Results don't match"); + error("Config: Results don't match for test \"" .. cnf .. "\""); end if (type(configtests[k].extra) == "function") then