在 tox 部分自动选择平台(或其他)条件
Auto-chose platform (or other) condition in tox sections
我想特别 运行 某个 tox 部分,然后自动决定特定平台。
如果我只是 运行 tox -e ALL
,下面的示例代码片段就可以正常工作。然后平台条件很好地选出了正确的平台。
但是,我只想地址和运行一个特定的部分,例如tox -e other
(而不是tox -e other-win, other-linux
)和然后 tox
自动选择相应的平台(或任何其他)条件。
不知道在tox
中这种设置条件的方式是不是不行,或者我是不是遗漏了什么。
[tox]
skipsdist = true
[testenv:systest-{win, linux}]
platform =
linux: linux
win: win|msys
whitelist_externals =
win: cmd
linux: sh
commands =
win: cmd /r echo {env:OS}
linux: sh -c echo {env:OS}
[testenv:other-{win, linux}]
platform =
linux: linux
win: win|msys
whitelist_externals =
win: cmd
linux: sh
commands =
win: cmd /r echo {env:OS}
linux: sh -c echo {env:OS}
你可以试试tox-factor
plugin。
例如:
tox.ini
[tox]
envlist =
alpha-{redmond,tux}
bravo-{redmond,tux}
requires =
tox-factor
skipsdist = true
[testenv]
commands =
python -c 'import sys; print("platform", sys.platform)'
platform =
redmond: win32
tux: linux
这给出了以下四种环境:
$ tox --listenvs
alpha-redmond
alpha-tux
bravo-redmond
bravo-tux
可以根据以下因素选择:
$ tox --listenvs --factor tux
alpha-tux
bravo-tux
$ tox --listenvs --factor alpha
alpha-redmond
alpha-tux
然后 运行 像这样(例如在 Linux 平台上):
$ tox --factor bravo
bravo-tux run-test-pre: PYTHONHASHSEED='1770792708'
bravo-tux run-test: commands[0] | python -c 'import sys; print("platform", sys.platform)'
platform linux
________________________________________________ summary ________________________________________________
SKIPPED: bravo-redmond: platform mismatch ('linux' does not match 'win32')
bravo-tux: commands succeeded
congratulations :)
参考文献:
我想特别 运行 某个 tox 部分,然后自动决定特定平台。
如果我只是 运行 tox -e ALL
,下面的示例代码片段就可以正常工作。然后平台条件很好地选出了正确的平台。
但是,我只想地址和运行一个特定的部分,例如tox -e other
(而不是tox -e other-win, other-linux
)和然后 tox
自动选择相应的平台(或任何其他)条件。
不知道在tox
中这种设置条件的方式是不是不行,或者我是不是遗漏了什么。
[tox]
skipsdist = true
[testenv:systest-{win, linux}]
platform =
linux: linux
win: win|msys
whitelist_externals =
win: cmd
linux: sh
commands =
win: cmd /r echo {env:OS}
linux: sh -c echo {env:OS}
[testenv:other-{win, linux}]
platform =
linux: linux
win: win|msys
whitelist_externals =
win: cmd
linux: sh
commands =
win: cmd /r echo {env:OS}
linux: sh -c echo {env:OS}
你可以试试tox-factor
plugin。
例如:
tox.ini
[tox]
envlist =
alpha-{redmond,tux}
bravo-{redmond,tux}
requires =
tox-factor
skipsdist = true
[testenv]
commands =
python -c 'import sys; print("platform", sys.platform)'
platform =
redmond: win32
tux: linux
这给出了以下四种环境:
$ tox --listenvs
alpha-redmond
alpha-tux
bravo-redmond
bravo-tux
可以根据以下因素选择:
$ tox --listenvs --factor tux
alpha-tux
bravo-tux
$ tox --listenvs --factor alpha
alpha-redmond
alpha-tux
然后 运行 像这样(例如在 Linux 平台上):
$ tox --factor bravo
bravo-tux run-test-pre: PYTHONHASHSEED='1770792708'
bravo-tux run-test: commands[0] | python -c 'import sys; print("platform", sys.platform)'
platform linux
________________________________________________ summary ________________________________________________
SKIPPED: bravo-redmond: platform mismatch ('linux' does not match 'win32')
bravo-tux: commands succeeded
congratulations :)
参考文献: