Make runmode option complain, add some tests for it
This commit is contained in:
+3
-1
@@ -2822,8 +2822,10 @@ optfn_runmode(int optidx, int req, boolean negated, char *opts, char *op)
|
|||||||
allopt[optidx].name, op);
|
allopt[optidx].name, op);
|
||||||
return optn_err;
|
return optn_err;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
|
config_error_add("Value is mandatory for %s", allopt[optidx].name);
|
||||||
return optn_err;
|
return optn_err;
|
||||||
|
}
|
||||||
return optn_ok;
|
return optn_ok;
|
||||||
}
|
}
|
||||||
if (req == get_val) {
|
if (req == get_val) {
|
||||||
|
|||||||
+15
-1
@@ -11,6 +11,20 @@ local configtests = {
|
|||||||
{ test = "OPTIONS=!color\nOPTIONS=color",
|
{ test = "OPTIONS=!color\nOPTIONS=color",
|
||||||
result = { { line = 2, error = "boolean option specified multiple times: 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();
|
local res = nh.get_config_errors();
|
||||||
|
|
||||||
if not testtable(err, res) then
|
if not testtable(err, res) then
|
||||||
error("Config: Results don't match");
|
error("Config: Results don't match for test \"" .. cnf .. "\"");
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(configtests[k].extra) == "function") then
|
if (type(configtests[k].extra) == "function") then
|
||||||
|
|||||||
Reference in New Issue
Block a user