Skip to content

Commit

Permalink
Fix TypeError when running get_rpaths on rez.utils.elf module
Browse files Browse the repository at this point in the history
Signed-off-by: Ruzette Krukkert <[email protected]>
  • Loading branch information
Ruzette Krukkert authored and Ruzette Krukkert committed Jul 18, 2024
1 parent 9c27f5e commit 351bb0e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
35 changes: 35 additions & 0 deletions src/rez/tests/test_utils_elf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright Contributors to the Rez Project


"""
unit tests for 'rez.utils.elf' module
"""
from rez.tests.util import TestBase
from rez.utils.elf import get_rpaths, patch_rpaths


class TestElfUtils(TestBase):

def __init__(self, *nargs, **kwargs):
super().__init__(*nargs, **kwargs)

@classmethod
def setUpClass(cls):
super().setUpClass()

@classmethod
def tearDownClass(cls):
super().tearDownClass()

def test_get_rpaths_raises_runtime_exception(self):
"""Tests that no TypeError from elf functions are raised."""
self.assertRaises(
RuntimeError,
get_rpaths("/path/to/elfpath")
)

self.assertRaises(
RuntimeError,
patch_rpaths("/path/to/elfpath", ["$ORIGIN", "$ORIGINTEST"])
)
4 changes: 3 additions & 1 deletion src/rez/utils/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import subprocess

from rez.utils.filesystem import make_path_writable
from rez.utils.execution import Popen


def get_rpaths(elfpath):
Expand Down Expand Up @@ -54,10 +55,11 @@ def patch_rpaths(elfpath, rpaths):


def _run(*nargs, **popen_kwargs):
proc = subprocess.Popen(
proc = Popen(
nargs,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
**popen_kwargs
)

Expand Down

0 comments on commit 351bb0e

Please sign in to comment.