Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

IndexError with empty command via env #1397

Closed
blueyed opened this issue Aug 13, 2019 · 4 comments
Closed

IndexError with empty command via env #1397

blueyed opened this issue Aug 13, 2019 · 4 comments
Labels
bug:normal affects many people or has quite an impact

Comments

@blueyed
Copy link

blueyed commented Aug 13, 2019

Given this tox.ini:

[tox]
skipsdist = True
[testenv]
commands =
  {env:EMPTY_COMMAND:}
  true

tox fails:

% tox
python run-test-pre: PYTHONHASHSEED='215393528'
python run-test: commands[0] | 
___________________________________ summary ____________________________________
  python: commands succeeded
  congratulations :)
Traceback (most recent call last):
  File "…/Vcs/tox/.venv/bin/tox", line 11, in <module>
    load_entry_point('tox', 'console_scripts', 'tox')()
  File "…/Vcs/tox/src/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "…/Vcs/tox/src/tox/session/__init__.py", line 68, in main
    exit_code = session.runcommand()
  File "…/Vcs/tox/src/tox/session/__init__.py", line 192, in runcommand
    return self.subcommand_test()
  File "…/Vcs/tox/src/tox/session/__init__.py", line 220, in subcommand_test
    run_sequential(self.config, self.venv_dict)
  File "…/Vcs/tox/src/tox/session/commands/run/sequential.py", line 22, in run_sequential
    runtestenv(venv, config)
  File "…/Vcs/tox/src/tox/session/commands/run/sequential.py", line 75, in runtestenv
    config.pluginmanager.hook.tox_runtest(venv=venv, redirect=redirect)
  File "…/Vcs/tox/.venv/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "…/Vcs/tox/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "…/Vcs/tox/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "…/Vcs/tox/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "…/Vcs/tox/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "…/Vcs/tox/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "…/Vcs/tox/src/tox/venv.py", line 748, in tox_runtest
    venv.test(redirect=redirect)
  File "…/Vcs/tox/src/tox/venv.py", line 507, in test
    if argv[0].startswith("-"):
IndexError: list index out of range

Empty commands should be either filtered out before, or skipped when being run - which makes a difference for the counter/index.
It is probably good to see that a command turned out to be empty.

My use case here is injecting a command to uninstall "colorama" for when the "colorama" factor is not used (but pytest installs it as a dependency).

tox 3.13.3.dev16+g0bd5198

@blueyed blueyed added the bug:normal affects many people or has quite an impact label Aug 13, 2019
@blueyed
Copy link
Author

blueyed commented Aug 13, 2019

As for my use case: using nocolorama: pip uninstall --yes colorama as a separate command, without redirection via env works.
But this is still a bug I would say - or would need a clearer error, i.e. "empty commands are not allowed".

@wisepotato
Copy link

Running into the same error. using echo as a placeholder, but removing the commands from a base environment would seem logical.

@gaborbernat
Copy link
Member

Feel free to open a PR against master and fix it. My available efforts at the moment are aimed at fixing this as part of #1394, but that probably will take a while (ETA September).

@gaborbernat
Copy link
Member

❯ tox4 c -e py -k commands
[testenv:py]
commands = true
/tmp/magic

This now has been fixed with tox 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:normal affects many people or has quite an impact
Projects
None yet
Development

No branches or pull requests

3 participants