mirror of
https://github.com/markqvist/rnsh.git
synced 2025-06-04 12:39:00 -04:00
Several test-driven fixes
- Improved test suite exposed several issues with the handling of command line arguments which are now fixed - Fixed a race condition that would cause remote characters to be lost intermittently when running remote commands that finish immediately. - Added automated testing that actually spins up a random listener and initiator in a private Reticulum network and passes data between them, uncovering more issues which are now fixed. - Fixed (hopefully) an issue where `rnsh` doesn't know what version it is.
This commit is contained in:
parent
d4cb31e220
commit
27664df0b3
12 changed files with 508 additions and 85 deletions
77
tests/test_args.py
Normal file
77
tests/test_args.py
Normal file
|
@ -0,0 +1,77 @@
|
|||
import rnsh.args
|
||||
import shlex
|
||||
import docopt
|
||||
|
||||
def test_program_args():
|
||||
docopt_threw = False
|
||||
try:
|
||||
args = rnsh.args.Args(shlex.split("rnsh -l -n one two three"))
|
||||
assert args.listen
|
||||
assert args.program == "one"
|
||||
assert args.program_args == ["two", "three"]
|
||||
assert args.command_line == ["one", "two", "three"]
|
||||
except docopt.DocoptExit:
|
||||
docopt_threw = True
|
||||
assert not docopt_threw
|
||||
|
||||
|
||||
def test_program_args_dash():
|
||||
docopt_threw = False
|
||||
try:
|
||||
args = rnsh.args.Args(shlex.split("rnsh -l -n -- one -l -C"))
|
||||
assert args.listen
|
||||
assert args.program == "one"
|
||||
assert args.program_args == ["-l", "-C"]
|
||||
assert args.command_line == ["one", "-l", "-C"]
|
||||
except docopt.DocoptExit:
|
||||
docopt_threw = True
|
||||
assert not docopt_threw
|
||||
|
||||
def test_program_initiate_no_args():
|
||||
docopt_threw = False
|
||||
try:
|
||||
args = rnsh.args.Args(shlex.split("rnsh one"))
|
||||
assert not args.listen
|
||||
assert args.destination == "one"
|
||||
assert args.command_line == []
|
||||
except docopt.DocoptExit:
|
||||
docopt_threw = True
|
||||
assert not docopt_threw
|
||||
|
||||
def test_program_initiate_dash_args():
|
||||
docopt_threw = False
|
||||
try:
|
||||
args = rnsh.args.Args(shlex.split("rnsh --config ~/Projects/rnsh/testconfig -s test -vvvvvvv a5f72aefc2cb3cdba648f73f77c4e887 -- -l"))
|
||||
assert not args.listen
|
||||
assert args.config == "~/Projects/rnsh/testconfig"
|
||||
assert args.service_name == "test"
|
||||
assert args.verbose == 7
|
||||
assert args.destination == "a5f72aefc2cb3cdba648f73f77c4e887"
|
||||
assert args.command_line == ["-l"]
|
||||
except docopt.DocoptExit:
|
||||
docopt_threw = True
|
||||
assert not docopt_threw
|
||||
|
||||
|
||||
def test_program_listen_config_print():
|
||||
docopt_threw = False
|
||||
try:
|
||||
args = rnsh.args.Args(shlex.split("rnsh -l --config testconfig -p"))
|
||||
assert args.listen
|
||||
assert args.config == "testconfig"
|
||||
assert args.print_identity
|
||||
assert args.command_line == []
|
||||
except docopt.DocoptExit:
|
||||
docopt_threw = True
|
||||
assert not docopt_threw
|
||||
|
||||
|
||||
def test_split_at():
|
||||
a, b = rnsh.args._split_array_at(["one", "two", "three"], "two")
|
||||
assert a == ["one"]
|
||||
assert b == ["three"]
|
||||
|
||||
def test_split_at_not_found():
|
||||
a, b = rnsh.args._split_array_at(["one", "two", "three"], "four")
|
||||
assert a == ["one", "two", "three"]
|
||||
assert b == []
|
Loading…
Add table
Add a link
Reference in a new issue