Make runmode option complain, add some tests for it

This commit is contained in:
Pasi Kallinen
2021-02-12 19:38:40 +02:00
parent 2e69789e6d
commit b1097df86d
2 changed files with 18 additions and 2 deletions

View File

@@ -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) {

View File

@@ -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