mirror of
https://github.com/openwrt/packages.git
synced 2025-12-24 03:21:22 +00:00
python-userpath: Add new package
The patches have been submitted upstream in https://github.com/ofek/userpath/pull/52 and https://github.com/ofek/userpath/pull/53. From the README: This is a tool for modifying a user's PATH. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
This commit is contained in:
committed by
Tianling Shen
parent
b354a7edbe
commit
5b3e4a4b3f
@@ -0,0 +1,112 @@
|
||||
From 7823b9b39c486aedf830783329abdc3bd9664ba4 Mon Sep 17 00:00:00 2001
|
||||
From: Jeffery To <jeffery.to@gmail.com>
|
||||
Date: Thu, 9 Nov 2023 17:51:21 +0800
|
||||
Subject: [PATCH 2/2] Add support for ash (Almquist shell)
|
||||
|
||||
---
|
||||
tests/docker/debian | 2 +-
|
||||
tests/test_ash.py | 65 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
userpath/shells.py | 5 ++++
|
||||
3 files changed, 71 insertions(+), 1 deletion(-)
|
||||
create mode 100644 tests/test_ash.py
|
||||
|
||||
--- a/tests/docker/debian
|
||||
+++ b/tests/docker/debian
|
||||
@@ -2,7 +2,7 @@ ARG PYTHON_VERSION
|
||||
FROM python:${PYTHON_VERSION}
|
||||
|
||||
RUN apt-get update \
|
||||
- && apt-get --no-install-recommends -y install fish zsh
|
||||
+ && apt-get --no-install-recommends -y install ash fish zsh
|
||||
|
||||
COPY requirements.txt /
|
||||
RUN pip install -r requirements.txt
|
||||
--- /dev/null
|
||||
+++ b/tests/test_ash.py
|
||||
@@ -0,0 +1,65 @@
|
||||
+import pytest
|
||||
+import userpath
|
||||
+
|
||||
+from .utils import SKIP_WINDOWS_CI, get_random_path
|
||||
+
|
||||
+SHELL_NAME = 'ash'
|
||||
+
|
||||
+pytestmark = [SKIP_WINDOWS_CI, pytest.mark.ash]
|
||||
+
|
||||
+
|
||||
+@pytest.mark.usefixtures('shell_test')
|
||||
+class TestDebian(object):
|
||||
+ DOCKERFILE = 'debian'
|
||||
+
|
||||
+ def test_prepend(self, request, shell_test):
|
||||
+ if shell_test is None:
|
||||
+ location = get_random_path()
|
||||
+ assert not userpath.in_current_path(location)
|
||||
+ assert userpath.prepend(location, check=True)
|
||||
+ assert userpath.in_new_path(location)
|
||||
+ assert userpath.need_shell_restart(location)
|
||||
+ else:
|
||||
+ process = shell_test(request.node.name)
|
||||
+ stdout, stderr = process.communicate()
|
||||
+
|
||||
+ assert process.returncode == 0, (stdout + stderr).decode('utf-8')
|
||||
+
|
||||
+ def test_prepend_multiple(self, request, shell_test):
|
||||
+ if shell_test is None:
|
||||
+ locations = [get_random_path(), get_random_path()]
|
||||
+ assert not userpath.in_current_path(locations)
|
||||
+ assert userpath.prepend(locations, check=True)
|
||||
+ assert userpath.in_new_path(locations)
|
||||
+ assert userpath.need_shell_restart(locations)
|
||||
+ else:
|
||||
+ process = shell_test(request.node.name)
|
||||
+ stdout, stderr = process.communicate()
|
||||
+
|
||||
+ assert process.returncode == 0, (stdout + stderr).decode('utf-8')
|
||||
+
|
||||
+ def test_append(self, request, shell_test):
|
||||
+ if shell_test is None:
|
||||
+ location = get_random_path()
|
||||
+ assert not userpath.in_current_path(location)
|
||||
+ assert userpath.append(location, check=True)
|
||||
+ assert userpath.in_new_path(location)
|
||||
+ assert userpath.need_shell_restart(location)
|
||||
+ else:
|
||||
+ process = shell_test(request.node.name)
|
||||
+ stdout, stderr = process.communicate()
|
||||
+
|
||||
+ assert process.returncode == 0, (stdout + stderr).decode('utf-8')
|
||||
+
|
||||
+ def test_append_multiple(self, request, shell_test):
|
||||
+ if shell_test is None:
|
||||
+ locations = [get_random_path(), get_random_path()]
|
||||
+ assert not userpath.in_current_path(locations)
|
||||
+ assert userpath.append(locations, check=True)
|
||||
+ assert userpath.in_new_path(locations)
|
||||
+ assert userpath.need_shell_restart(locations)
|
||||
+ else:
|
||||
+ process = shell_test(request.node.name)
|
||||
+ stdout, stderr = process.communicate()
|
||||
+
|
||||
+ assert process.returncode == 0, (stdout + stderr).decode('utf-8')
|
||||
--- a/userpath/shells.py
|
||||
+++ b/userpath/shells.py
|
||||
@@ -37,6 +37,10 @@ class Sh(Shell):
|
||||
return [cls._interactive_login_show_path_command()]
|
||||
|
||||
|
||||
+class Ash(Sh):
|
||||
+ name = 'ash'
|
||||
+
|
||||
+
|
||||
class Bash(Sh):
|
||||
name = 'bash'
|
||||
|
||||
@@ -114,6 +118,7 @@ class Zsh(Sh):
|
||||
|
||||
|
||||
SHELLS = {
|
||||
+ 'ash': Ash,
|
||||
'bash': Bash,
|
||||
'fish': Fish,
|
||||
'sh': Sh,
|
||||
Reference in New Issue
Block a user