Merge remote-tracking branch 'origin/topic/jsiwek/improve-command-line-option-redefs'

* origin/topic/jsiwek/improve-command-line-option-redefs:
  Integrate review feedback: improve command-line option redef parsing
  Fix several issues with command-line option redefs
This commit is contained in:
Johanna Amann 2020-06-26 16:25:34 +00:00
commit eb1a408b6a
8 changed files with 95 additions and 22 deletions

View file

@ -0,0 +1,4 @@
mystr,
mynum, 0
mytable, {"one":"1"}
MyMod::str, Good

View file

@ -0,0 +1,4 @@
mystr, default
mynum, 0
mytable, {"zero":"0","one":"1"}
MyMod::str, def

View file

@ -0,0 +1 @@
error: unknown identifier 'no_such_var' in command-line options

View file

@ -0,0 +1,2 @@
error: must assign non-empty value to 'mynum' in command-line options
error: must assign non-empty value to 'mytable' in command-line options

View file

@ -0,0 +1,27 @@
# @TEST-EXEC: zeek -b %INPUT mynum=0 mytable='{["one"] = "1"}' mystr="" MyMod::str="Good" >1.out
# @TEST-EXEC: zeek -b %INPUT mynum=0 mytable+='{["one"] = "1"}' >2.out
# @TEST-EXEC-FAIL: zeek -b %INPUT no_such_var=13 >3.out 2>&1
# @TEST-EXEC-FAIL: zeek -b %INPUT mynum="" mytable="" >4.out 2>&1
# @TEST-EXEC: btest-diff 1.out
# @TEST-EXEC: btest-diff 2.out
# @TEST-EXEC: btest-diff 3.out
# @TEST-EXEC: btest-diff 4.out
const mynum: count &redef;
const mytable: table[string] of string = {["zero"] = "0"} &redef;
option mystr="default";
module MyMod;
export { option str="def"; }
module GLOBAL;
event zeek_init()
{
print "mystr", mystr;
print "mynum", mynum;
print "mytable", to_json(mytable);
print "MyMod::str", MyMod::str;
}