]> granicus.if.org Git - nethack/commitdiff
Make runmode option complain, add some tests for it
authorPasi Kallinen <paxed@alt.org>
Fri, 12 Feb 2021 17:38:40 +0000 (19:38 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 12 Feb 2021 17:41:46 +0000 (19:41 +0200)
src/options.c
test/test_cnf.lua

index a15c4e1287660aedbf854f82eb96dc2db8ab8752..e23620bed8beb442310eb5ed9b6da4ad6a68be7c 100644 (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) {
index 8efdf55533f67f364cc4499604cd7bd584b8ebd4..a177443ac95c1d377005d1bf4e434be3aacdf6f2 100644 (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