diff mbox series

package/python-pathspec: enable target variant

Message ID 20240412054421.1346030-1-heiko.thiery@gmail.com
State Accepted
Headers show
Series package/python-pathspec: enable target variant | expand

Commit Message

Heiko Thiery April 12, 2024, 5:44 a.m. UTC
Also a runtime testcase is added.

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
 package/Config.in                             |  1 +
 package/python-pathspec/Config.in             |  6 ++++
 package/python-pathspec/python-pathspec.mk    |  1 +
 .../tests/package/sample_python_pathspec.py   | 35 +++++++++++++++++++
 .../tests/package/test_python_pathspec.py     | 11 ++++++
 5 files changed, 54 insertions(+)
 create mode 100644 package/python-pathspec/Config.in
 create mode 100644 support/testing/tests/package/sample_python_pathspec.py
 create mode 100644 support/testing/tests/package/test_python_pathspec.py

Comments

Yann E. MORIN April 12, 2024, 3:48 p.m. UTC | #1
Heiko, All,

On 2024-04-12 07:44 +0200, Heiko Thiery spake thusly:
> Also a runtime testcase is added.
> 
> Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
> ---
[--SNIP--]
> diff --git a/package/python-pathspec/Config.in b/package/python-pathspec/Config.in
> new file mode 100644
> index 0000000000..4ecf76d456
> --- /dev/null
> +++ b/package/python-pathspec/Config.in
> @@ -0,0 +1,6 @@
> +config BR2_PACKAGE_PYTHON_PATHSPEC
> +	bool "python-pathspec"
> +	help
> +	  pathspec is a utility library for pattern matching of file paths.

    $ ./utils/docker-run make check-package
    package/python-pathspec/Config.in:4: help text: <tab><2 spaces><62 chars> (https://nightly.buildroot.org/#writing-rules-config-in)

[--SNIP--]
> diff --git a/support/testing/tests/package/sample_python_pathspec.py b/support/testing/tests/package/sample_python_pathspec.py
> new file mode 100644
> index 0000000000..6205126e21
> --- /dev/null
> +++ b/support/testing/tests/package/sample_python_pathspec.py
> @@ -0,0 +1,35 @@
> +# example from https://pypi.org/project/pathspec/
> +
> +import pathspec

I've added an empty line after the import, it's... cleaner. I guess?

Applied to master, with the above two fixed, thanks.

Regards,
Yann E. MORIN.

> +# The gitignore-style patterns for files to select, but we're including
> +# instead of ignoring.
> +spec_text = """
> +
> +# This is a comment because the line begins with a hash: "#"
> +
> +# Include several project directories (and all descendants) relative to
> +# the current directory. To reference a directory you must end with a
> +# slash: "/"
> +/project-a/
> +/project-b/
> +/project-c/
> +
> +# Patterns can be negated by prefixing with exclamation mark: "!"
> +
> +# Ignore temporary files beginning or ending with "~" and ending with
> +# ".swp".
> +!~*
> +!*~
> +!*.swp
> +
> +# These are python projects so ignore compiled python files from
> +# testing.
> +!*.pyc
> +
> +# Ignore the build directories but only directly under the project
> +# directories.
> +!/*/build/
> +
> +"""
> +
> +spec = pathspec.PathSpec.from_lines('gitwildmatch', spec_text.splitlines())
> diff --git a/support/testing/tests/package/test_python_pathspec.py b/support/testing/tests/package/test_python_pathspec.py
> new file mode 100644
> index 0000000000..4e4a992bb3
> --- /dev/null
> +++ b/support/testing/tests/package/test_python_pathspec.py
> @@ -0,0 +1,11 @@
> +from tests.package.test_python import TestPythonPackageBase
> +
> +
> +class TestPythonPathSpec(TestPythonPackageBase):
> +    __test__ = True
> +    config = TestPythonPackageBase.config + \
> +        """
> +        BR2_PACKAGE_PYTHON3=y
> +        BR2_PACKAGE_PYTHON_PATHSPEC=y
> +        """
> +    sample_scripts = ["tests/package/sample_python_pathspec.py"]
> -- 
> 2.39.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

Patch

diff --git a/package/Config.in b/package/Config.in
index 0d31faf354..d9bbf64c95 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1223,6 +1223,7 @@  menu "External python modules"
 	source "package/python-parso/Config.in"
 	source "package/python-passlib/Config.in"
 	source "package/python-pathpy/Config.in"
+	source "package/python-pathspec/Config.in"
 	source "package/python-pathtools/Config.in"
 	source "package/python-pathvalidate/Config.in"
 	source "package/python-periphery/Config.in"
diff --git a/package/python-pathspec/Config.in b/package/python-pathspec/Config.in
new file mode 100644
index 0000000000..4ecf76d456
--- /dev/null
+++ b/package/python-pathspec/Config.in
@@ -0,0 +1,6 @@ 
+config BR2_PACKAGE_PYTHON_PATHSPEC
+	bool "python-pathspec"
+	help
+	  pathspec is a utility library for pattern matching of file paths.
+
+	  https://github.com/cpburnz/python-pathspec
diff --git a/package/python-pathspec/python-pathspec.mk b/package/python-pathspec/python-pathspec.mk
index c4cb34b4c3..b46dbef7ea 100644
--- a/package/python-pathspec/python-pathspec.mk
+++ b/package/python-pathspec/python-pathspec.mk
@@ -11,4 +11,5 @@  PYTHON_PATHSPEC_LICENSE = MPL-2.0
 PYTHON_PATHSPEC_LICENSE_FILES = LICENSE
 PYTHON_PATHSPEC_SETUP_TYPE = flit
 
+$(eval $(python-package))
 $(eval $(host-python-package))
diff --git a/support/testing/tests/package/sample_python_pathspec.py b/support/testing/tests/package/sample_python_pathspec.py
new file mode 100644
index 0000000000..6205126e21
--- /dev/null
+++ b/support/testing/tests/package/sample_python_pathspec.py
@@ -0,0 +1,35 @@ 
+# example from https://pypi.org/project/pathspec/
+
+import pathspec
+# The gitignore-style patterns for files to select, but we're including
+# instead of ignoring.
+spec_text = """
+
+# This is a comment because the line begins with a hash: "#"
+
+# Include several project directories (and all descendants) relative to
+# the current directory. To reference a directory you must end with a
+# slash: "/"
+/project-a/
+/project-b/
+/project-c/
+
+# Patterns can be negated by prefixing with exclamation mark: "!"
+
+# Ignore temporary files beginning or ending with "~" and ending with
+# ".swp".
+!~*
+!*~
+!*.swp
+
+# These are python projects so ignore compiled python files from
+# testing.
+!*.pyc
+
+# Ignore the build directories but only directly under the project
+# directories.
+!/*/build/
+
+"""
+
+spec = pathspec.PathSpec.from_lines('gitwildmatch', spec_text.splitlines())
diff --git a/support/testing/tests/package/test_python_pathspec.py b/support/testing/tests/package/test_python_pathspec.py
new file mode 100644
index 0000000000..4e4a992bb3
--- /dev/null
+++ b/support/testing/tests/package/test_python_pathspec.py
@@ -0,0 +1,11 @@ 
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPathSpec(TestPythonPackageBase):
+    __test__ = True
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        BR2_PACKAGE_PYTHON_PATHSPEC=y
+        """
+    sample_scripts = ["tests/package/sample_python_pathspec.py"]