简体   繁体   English

Tox运行shell命令并获取正确的退出代码

[英]Tox run shell command and get correct exit code

I have the following tox.ini file to run pylint. 我有以下tox.ini文件可运行pylint。

It grabs all python files and then lints them. 它会抓取所有python文件,然后将它们掉毛。

[testenv:pylint]
deps =
  -rrequirements.txt
basepython=python2
commands =
  - sh -c 'find . -iname "*.py" | grep -v .tox | xargs pylint -sn --output-format=colorized --rcfile={toxinidir}/.pylintrc'

Running just the shell portion on the command line has the correct exit code. 仅在命令行上运行外壳程序部分具有正确的退出代码。

However when running using tox, it swallows the exit code and is always successful. 但是,使用Tox运行时,它会吞下退出代码,并且总是成功的。

Is there anyway for tox to have the correct exit code while using the sh -c option? 无论如何,使用sh -c选项时,tox是否具有正确的退出代码?

Starting a command with a single dash character means ignore the exit code. 以单个破折号字符启动命令意味着忽略退出代码。 [1] [1]

commands =
  sh -c 'find . -iname "*.py" | grep -v .tox | xargs pylint -sn --output-format=colorized --rcfile={toxinidir}/.pylintrc'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM