Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Add Local test stage and option to jump directly to menu item from co…
Browse files Browse the repository at this point in the history
…mmandline (#13809)
  • Loading branch information
larroy authored and marcoabreu committed Jan 11, 2019
1 parent abb7ce5 commit e632386
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions dev_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,14 @@ def create_virtualenv_default():
logging.info("You can use the virtualenv by executing 'source %s/bin/activate'", DEFAULT_PYENV)

COMMANDS = OrderedDict([
('[Local build] CMake/Ninja build (using cmake_options.yaml (cp cmake/cmake_options.yml .) and edit) (creates {} virtualenv in "{}")'.format(DEFAULT_PYTHON, DEFAULT_PYENV),
('[Local] BUILD CMake/Ninja (using cmake_options.yaml (cp cmake/cmake_options.yml .) and edit) ({} virtualenv in "{}")'.format(DEFAULT_PYTHON, DEFAULT_PYENV),
[
CMake(),
create_virtualenv_default,
]),
('[Local] Python Unit tests',
"./py3_venv/bin/nosetests -v tests/python/unittest/"
),
('[Website and docs build] Will build to docs/_build/html/',
"ci/docker/runtime_functions.sh deploy_docs"),
('[Docker] sanity_check. Check for linting and code formatting.',
Expand Down Expand Up @@ -184,15 +187,18 @@ def handle_command(cmd):

def use_menu_ui(args) -> None:
command_list = list(COMMANDS.keys())
choice = show_menu(command_list, 'Available actions')
if hasattr(args, 'choice') and args.choice and args.choice[0].isdigit():
choice = int(args.choice[0]) - 1
else:
choice = show_menu(command_list, 'Available actions')
handle_commands(COMMANDS[command_list[choice]])

def build(args) -> None:
"""Build using CMake"""
venv_exe = shutil.which('virtualenv')
pyexe = shutil.which(args.pyexe)
if not venv_exe:
logging.warn("virtualenv wasn't found in path, it's recommended to install virutalenv to manage python environments")
logging.warn("virtualenv wasn't found in path, it's recommended to install virtualenv to manage python environments")
if not pyexe:
logging.warn("Python executable %s not found in path", args.pyexe)
if args.cmake_options:
Expand All @@ -219,8 +225,12 @@ def main():
type=str,
default=DEFAULT_PYTHON,
help='python executable')

build_parser.set_defaults(command='build')

menu_parser = subparsers.add_parser('menu', help='jump to menu option #')
menu_parser.set_defaults(command='use_menu_ui')
menu_parser.add_argument('choice', nargs=1)

args = parser.parse_args()
globals()[args.command](args)
return 0
Expand Down

0 comments on commit e632386

Please sign in to comment.