Skip to content

Commit 2742381

Browse files
committed
Finishing up the version contraints of the plugin system as well as skipping plugin load if the fail
1 parent f61c0fd commit 2742381

File tree

16 files changed

+252
-70
lines changed

16 files changed

+252
-70
lines changed

docs/plugin_system.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,17 @@ The `plugin.py` file could contain something like the following:
8989
"""
9090
Initialize my custom plugin.
9191
"""
92-
super().__init__()
93-
94-
# Optional version dependency configurations:
95-
self.plugin_name = 'tmuxp-plugin-my-tmuxp-plugin'
96-
self.tmux_min_version = '1.8'
97-
self.tmux_max_version = '2.4'
98-
self.tmux_version_incompatible = ['2.3']
99-
self.tmuxp_min_version = '1.6.0'
100-
self.tmuxp_max_version = '1.6.2'
101-
self.tmuxp_version_incompatible = ['1.6.1']
92+
# Optional version dependency configuration. See Plugin API docs
93+
# for all supported config parameters
94+
config = {
95+
'tmuxp_min_version' = '1.6.2'
96+
}
97+
98+
TmuxpPluginInterface.__init__(
99+
self,
100+
plugin_name='tmuxp-plugin-my-tmuxp-plugin',
101+
**config
102+
)
102103
103104
def before_workspace_builder(self, session):
104105
session.rename_session('my-new-session-name')

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ tmuxp-test-plugin-bs = { path = "tests/fixtures/pluginsystem/plugins/tmuxp_test_
7474
tmuxp-test-plugin-r = { path = "tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_r/"}
7575
tmuxp-test-plugin-owc = { path = "tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_owc/"}
7676
tmuxp-test-plugin-awf = { path = "tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_awf/"}
77+
tmuxp-test-plugin-fail = { path = "tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_fail/"}
7778

7879
### Coverage ###
7980
codecov = "*"
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
from .test_plugin_helpers import TestTmuxpPluginInterface
1+
from .test_plugin_helpers import MyTestTmuxpPluginInterface
22

33

4-
class AllVersionPassPlugin(TestTmuxpPluginInterface):
4+
class AllVersionPassPlugin(MyTestTmuxpPluginInterface):
55
def __init__(self):
66
config = {
77
'plugin_name': 'tmuxp-plugin-my-tmuxp-plugin',
88
'tmux_min_version': '1.8',
99
'tmux_max_version': '100.0',
1010
'tmux_version_incompatible': ['2.3'],
11+
'libtmux_min_version': '0.8.3',
12+
'libtmux_max_version': '100.0',
13+
'libtmux_version_incompatible': ['0.7.1'],
1114
'tmuxp_min_version': '1.6.0',
1215
'tmuxp_max_version': '100.0.0',
1316
'tmuxp_version_incompatible': ['1.5.6'],
1417
'tmux_version': '3.0',
1518
'tmuxp_version': '1.6.0',
1619
}
17-
TestTmuxpPluginInterface.__init__(self, config)
20+
MyTestTmuxpPluginInterface.__init__(self, config)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from .test_plugin_helpers import MyTestTmuxpPluginInterface
2+
3+
4+
class LibtmuxVersionFailMinPlugin(MyTestTmuxpPluginInterface):
5+
def __init__(self):
6+
config = {
7+
'plugin_name': 'libtmux-min-version-fail',
8+
'libtmux_min_version': '0.8.3',
9+
'libtmux_version': '0.7.0'
10+
}
11+
MyTestTmuxpPluginInterface.__init__(self, config)
12+
13+
14+
class LibtmuxVersionFailMaxPlugin(MyTestTmuxpPluginInterface):
15+
def __init__(self):
16+
config = {
17+
'plugin_name': 'libtmux-max-version-fail',
18+
'libtmux_max_version': '3.0',
19+
'libtmux_version': '3.5'
20+
}
21+
MyTestTmuxpPluginInterface.__init__(self, config)
22+
23+
24+
class LibtmuxVersionFailIncompatiblePlugin(MyTestTmuxpPluginInterface):
25+
def __init__(self):
26+
config = {
27+
'plugin_name': 'libtmux-incompatible-version-fail',
28+
'libtmux_version_incompatible': ['0.7.1'],
29+
'libtmux_version': '0.7.1'
30+
}
31+
MyTestTmuxpPluginInterface.__init__(self, config)

tests/fixtures/pluginsystem/partials/test_plugin_helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
from tmuxp.plugin import TmuxpPluginInterface
22

3-
class TestTmuxpPluginInterface(TmuxpPluginInterface):
3+
class MyTestTmuxpPluginInterface(TmuxpPluginInterface):
44
def __init__(self, config):
55
tmux_version = config.pop('tmux_version', None)
6+
libtmux_version = config.pop('libtmux_version', None)
67
tmuxp_version = config.pop('tmuxp_version', None)
78

89
TmuxpPluginInterface.__init__(self, **config)
910

1011
# WARNING! This should not be done in anything but a test
1112
if tmux_version:
1213
self.version_constraints['tmux']['version'] = tmux_version
14+
if libtmux_version:
15+
self.version_constraints['libtmux']['version'] = libtmux_version
1316
if tmuxp_version:
1417
self.version_constraints['tmuxp']['version'] = tmuxp_version
1518

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
from .test_plugin_helpers import TestTmuxpPluginInterface
1+
from .test_plugin_helpers import MyTestTmuxpPluginInterface
22

33

4-
class TmuxVersionFailMinPlugin(TestTmuxpPluginInterface):
4+
class TmuxVersionFailMinPlugin(MyTestTmuxpPluginInterface):
55
def __init__(self):
66
config = {
77
'plugin_name': 'tmux-min-version-fail',
88
'tmux_min_version': '1.8',
99
'tmux_version': '1.7'
1010
}
11-
TestTmuxpPluginInterface.__init__(self, config)
11+
MyTestTmuxpPluginInterface.__init__(self, config)
1212

1313

14-
class TmuxVersionFailMaxPlugin(TestTmuxpPluginInterface):
14+
class TmuxVersionFailMaxPlugin(MyTestTmuxpPluginInterface):
1515
def __init__(self):
1616
config = {
1717
'plugin_name': 'tmux-max-version-fail',
18-
'tmux_min_version': '3.0',
18+
'tmux_max_version': '3.0',
1919
'tmux_version': '3.5'
2020
}
21-
TestTmuxpPluginInterface.__init__(self, config)
21+
MyTestTmuxpPluginInterface.__init__(self, config)
2222

2323

24-
class TmuxVersionFailIncompatiblePlugin(TestTmuxpPluginInterface):
24+
class TmuxVersionFailIncompatiblePlugin(MyTestTmuxpPluginInterface):
2525
def __init__(self):
2626
config = {
2727
'plugin_name': 'tmux-incompatible-version-fail',
2828
'tmux_version_incompatible': ['2.3'],
2929
'tmux_version': '2.3'
3030
}
3131

32-
TestTmuxpPluginInterface.__init__(self, config)
32+
MyTestTmuxpPluginInterface.__init__(self, config)
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
from .test_plugin_helpers import TestTmuxpPluginInterface
1+
from .test_plugin_helpers import MyTestTmuxpPluginInterface
22

33

4-
class TmuxpVersionFailMinPlugin(TestTmuxpPluginInterface):
4+
class TmuxpVersionFailMinPlugin(MyTestTmuxpPluginInterface):
55
def __init__(self):
66
config = {
77
'plugin_name': 'tmuxp-min-verion-fail',
88
'tmuxp_min_version': '1.6.0',
99
'tmuxp_version': '1.5.6'
1010
}
11-
TestTmuxpPluginInterface.__init__(self, config)
11+
MyTestTmuxpPluginInterface.__init__(self, config)
1212

1313

14-
class TmuxpVersionFailMaxPlugin(TestTmuxpPluginInterface):
14+
class TmuxpVersionFailMaxPlugin(MyTestTmuxpPluginInterface):
1515
def __init__(self):
1616
config = {
1717
'plugin_name': 'tmuxp-max-verion-fail',
18-
'tmuxp_min_version': '2.0.0',
18+
'tmuxp_max_version': '2.0.0',
1919
'tmuxp_version': '2.5'
2020
}
21-
TestTmuxpPluginInterface.__init__(self, config)
21+
MyTestTmuxpPluginInterface.__init__(self, config)
2222

2323

24-
class TmuxpVersionFailIncompatiblePlugin(TestTmuxpPluginInterface):
24+
class TmuxpVersionFailIncompatiblePlugin(MyTestTmuxpPluginInterface):
2525
def __init__(self):
2626
config = {
2727
'plugin_name': 'tmuxp-incompatible-verion-fail',
2828
'tmuxp_version_incompatible': ['1.5.0'],
2929
'tmuxp_version': '1.5.0'
3030
}
31-
TestTmuxpPluginInterface.__init__(self, config)
31+
MyTestTmuxpPluginInterface.__init__(self, config)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[tool.poetry]
2+
name = "tmuxp_test_plugin_fail"
3+
version = "0.1.0"
4+
description = "A test plugin designed to fail to test the cli"
5+
authors = ["Joseph Flinn <joseph.s.flinn@gmail.com>"]
6+
7+
[tool.poetry.dependencies]
8+
python = "~2.7 || ^3.5"
9+
tmuxp = "^1.6.0"
10+
11+
[tool.poetry.dev-dependencies]
12+
13+
[build-system]
14+
requires = ["poetry>=0.12"]
15+
build-backend = "poetry.masonry.api"

tests/fixtures/pluginsystem/plugins/tmuxp_test_plugin_fail/tmuxp_test_plugin_fail/__init__.py

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from tmuxp.plugin import TmuxpPluginInterface
2+
3+
4+
class PluginFailVersion(TmuxpPluginInterface):
5+
def __init__(self):
6+
config = {
7+
'plugin_name': 'tmuxp-plugin-fail-version',
8+
'tmuxp_max_version': '0.0.0',
9+
}
10+
TmuxpPluginInterface.__init__(self, **config)

0 commit comments

Comments
 (0)