Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix bug with System\args + add cmdline-related unit-tests #1558

Merged
merged 12 commits into from
Jan 25, 2024
4 changes: 2 additions & 2 deletions src/vm/env.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#=======================================
# Libraries
#=======================================
when not defined(WEB) and not defined(windows):
when not defined(WEB):
import parseopt, sequtils, sugar

when not defined(WEB):
Expand Down Expand Up @@ -84,7 +84,7 @@ proc parseCmdlineArguments*(): ValueDict =
result = initOrderedTable[string,Value]()
var values: ValueArray

when not defined(windows) and not defined(WEB):
when not defined(WEB):
if Arguments.a.len > 0:
var p = initOptParser(Arguments.a.map((x)=>x.s))
for kind, key, val in p.getopt():
Expand Down
8 changes: 8 additions & 0 deletions tests/unittests/cmdline.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
loop sort select list relative "cmdline" 'loc -> contains? loc ".txt" 'test [
inputArgs: read test
print repeat "-" 70
print [" test:" extract.filename test]
print repeat "-" 70
execute.directly ~{|sys\binary| --no-color |inputArgs|}
print ""
]
92 changes: 92 additions & 0 deletions tests/unittests/cmdline.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
----------------------------------------------------------------------
test: input1
----------------------------------------------------------------------
[ :block

]
[ :dictionary
values : [ :block

]
]

----------------------------------------------------------------------
test: input2
----------------------------------------------------------------------
[ :block
1 :string
2 :string
3 :string
]
[ :dictionary
values : [ :block
1 :integer
2 :integer
3 :integer
]
]

----------------------------------------------------------------------
test: input3
----------------------------------------------------------------------
[ :block
one :string
two :string
three :string
]
[ :dictionary
values : [ :block
one :string
two :string
three :string
]
]

----------------------------------------------------------------------
test: input4
----------------------------------------------------------------------
[ :block
one :string
2 :string
three :string
4.0 :string
]
[ :dictionary
values : [ :block
one :string
2 :integer
three :string
4.0 :floating
]
]

----------------------------------------------------------------------
test: input5
----------------------------------------------------------------------
[ :block
-a :string
main :string
]
[ :dictionary
a : true :logical
values : [ :block
main :string
]
]

----------------------------------------------------------------------
test: input6
----------------------------------------------------------------------
[ :block
-c :string
-b :string
--name:Rick :string
]
[ :dictionary
c : true :logical
b : true :logical
name : Rick :string
values : [ :block

]
]
1 change: 1 addition & 0 deletions tests/unittests/cmdline/input1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|relative "cmdline/inspectArgs.art"|
1 change: 1 addition & 0 deletions tests/unittests/cmdline/input2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|relative "cmdline/inspectArgs.art"| 1 2 3
1 change: 1 addition & 0 deletions tests/unittests/cmdline/input3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|relative "cmdline/inspectArgs.art"| one two three
1 change: 1 addition & 0 deletions tests/unittests/cmdline/input4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|relative "cmdline/inspectArgs.art"| one 2 three 4.0
1 change: 1 addition & 0 deletions tests/unittests/cmdline/input5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|relative "cmdline/inspectArgs.art"| -a main
1 change: 1 addition & 0 deletions tests/unittests/cmdline/input6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|relative "cmdline/inspectArgs.art"| -c -b --name:Rick
2 changes: 2 additions & 0 deletions tests/unittests/cmdline/inspectArgs.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inspect arg
inspect args
2 changes: 1 addition & 1 deletion version/build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2274
2276
Loading