Skip to content

Commit be551dd

Browse files
committed
testing: Add a fixture to set $PATH to CLN versions
Fewer demands on the environments, better managed, should make it simpler to use.
1 parent 2cd4d07 commit be551dd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

libs/gl-testing/gltesting/fixtures.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,43 @@
1414
from gltesting.network import node_factory
1515
from pyln.testing.fixtures import directory as str_directory
1616
from decimal import Decimal
17+
from clnvm import ClnVersionManager
1718

1819
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
1920
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
2021
logging.getLogger("sh").setLevel(logging.ERROR)
2122
logging.getLogger("hpack").setLevel(logging.ERROR)
2223
logger = logging.getLogger(__name__)
2324

25+
26+
@pytest.fixture(autouse=True)
27+
def paths():
28+
"""A fixture to ensure that we have all CLN versions and that
29+
`PATH` points to the latest one.
30+
31+
If you'd like to test a development version rather than the
32+
released ones, ensure that its executable path is in the PATH
33+
before calling `pytest` since this appends to the end.
34+
35+
"""
36+
vm = ClnVersionManager()
37+
versions = vm.get_versions()
38+
39+
# Should be a no-op after the first run
40+
vm.get_all()
41+
42+
latest = [v for v in versions if 'gl' in v.tag][-1]
43+
44+
os.environ['PATH'] += f":{vm.get_target_path(latest) / 'usr' / 'local' / 'bin'}"
45+
46+
yield
47+
48+
2449
@pytest.fixture()
2550
def directory(str_directory : str) -> Path:
2651
return Path(str_directory) / "gl-testing"
2752

53+
2854
@pytest.fixture()
2955
def cert_directory(directory):
3056
yield directory / "certs"

0 commit comments

Comments
 (0)