Fixed issues with rbtools argument parsing on Python 3 when running '--help'
Review Request #10856 — Created Jan. 24, 2020 and submitted — Latest diff uploaded
On python 2, running
rbt --help <command>
andrbt <command> --help
are equivalent. However, runningrbt <command> --help
does not work
on python 3. This happens because byte strings are utilized in the
code to see if--help
or-h
are passed in as arguments. They are
never found because the code is trying to findb'--help
' orb'-h'
.
In python 2,b'--help'
is equivalent to'--help'
, but in python 3,
this is not the case.To fix this issue, the byte strings
b'--help'
andb’-h’
have been
changed to python 3 compatible strings (i.e.--help
and-h
). Unit
tests have also been added to ensure that all possible positions and
cases of the 'help' argument work for rbtools.(ex.rbt —help <command>
,
rbt <command> -h
,rbt help <command>
, etc.).All tests were run using both python 2.7.17 and python 3.7.6.
Test cases run on python 2.7.17 and 3.7.6:
Test case whererbt help <command>
is run
Test case whererbt <command> --help
orrbt <command> -h
is run
Test case whererbt --help <command>
orrbt -h <command>
is run
Test case where an invalid rbt command is run withhelp
Test case where multiple arguments are entered