All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v5 1/3] package/nushell: new package
@ 2023-03-08  8:53 Sebastian Weyer
  2023-03-08  8:53 ` [Buildroot] [PATCH v5 2/3] package/nushell: Add default configs Sebastian Weyer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sebastian Weyer @ 2023-03-08  8:53 UTC (permalink / raw)
  To: buildroot; +Cc: Sebastian Weyer

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 3341 bytes --]

Nushell is a shell - written in Rust - that makes use of the nushell
language to interact with the operating system

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
---
This new version adds ncurses-target-progs as a dependency which is a
hidden dependency of nushell. With this option enabled, nushell is also
usable without specifically replacing getty by agetty.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
---
 DEVELOPERS                   |  3 +++
 package/Config.in            |  1 +
 package/nushell/Config.in    | 12 ++++++++++++
 package/nushell/nushell.hash |  2 ++
 package/nushell/nushell.mk   | 20 ++++++++++++++++++++
 5 files changed, 38 insertions(+)
 create mode 100644 package/nushell/Config.in
 create mode 100644 package/nushell/nushell.hash
 create mode 100644 package/nushell/nushell.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 6256576e02..4577f20b22 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2550,6 +2550,9 @@ F:	support/misc/toolchainfile.cmake.in
 N:	Sam Voss <sam.voss@gmail.com>
 F:	package/ripgrep/
 
+N:  Sebastian Weyer <sebastian.weyer@smile.fr>
+F:	package/nushell/
+
 N:	Sébastien Szymanski <sebastien.szymanski@armadeus.com>
 F:	package/mmc-utils/
 F:	package/python-flask-jsonrpc/
diff --git a/package/Config.in b/package/Config.in
index 3ace25c665..7fca46afb5 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2577,6 +2577,7 @@ comment "Shells"
 	source "package/bash/Config.in"
 	source "package/dash/Config.in"
 	source "package/mksh/Config.in"
+	source "package/nushell/Config.in"
 	source "package/zsh/Config.in"
 comment "Utilities"
 	source "package/apg/Config.in"
diff --git a/package/nushell/Config.in b/package/nushell/Config.in
new file mode 100644
index 0000000000..edb01d2f72
--- /dev/null
+++ b/package/nushell/Config.in
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_NUSHELL
+	bool "nushell"
+	depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
+	select BR2_PACKAGE_HOST_RUSTC
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_HOST_PKGCONF
+	select BR2_PACKAGE_NCURSES
+	select BR2_PACKAGE_NCURSES_TARGET_PROGS
+	help
+	  A new type of shell.
+
+	  https://github.com/nushell/nushell
diff --git a/package/nushell/nushell.hash b/package/nushell/nushell.hash
new file mode 100644
index 0000000000..a77e711a5d
--- /dev/null
+++ b/package/nushell/nushell.hash
@@ -0,0 +1,2 @@
+# Locally generated
+sha256  352e807698d5f95e9bfdd9dd5512acab3cbef315379299a32e5f322a76eb718a  nushell-0.76.0.tar.gz
diff --git a/package/nushell/nushell.mk b/package/nushell/nushell.mk
new file mode 100644
index 0000000000..836f414d0a
--- /dev/null
+++ b/package/nushell/nushell.mk
@@ -0,0 +1,20 @@
+################################################################################
+#
+# nushell
+#
+################################################################################
+
+NUSHELL_VERSION = 0.76.0
+NUSHELL_SITE = $(call github,nushell,nushell,$(NUSHELL_VERSION))
+NUSHELL_LICENSE = MIT
+NUSHELL_LICENSE_FILES = LICENSE
+NUSHELL_DEPENDENCIES = openssl host-pkgconf ncurses
+
+# Add /bin/nu to /etc/shells as in package/bash/bash.mk
+define NUSHELL_ADD_NU_TO_SHELLS
+	grep -qsE '^/bin/nu$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/nu" >> $(TARGET_DIR)/etc/shells
+endef
+NUSHELL_TARGET_FINALIZE_HOOKS += NUSHELL_ADD_NU_TO_SHELLS
+
+$(eval $(cargo-package))
-- 
2.25.1


[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH v5 2/3] package/nushell: Add default configs
  2023-03-08  8:53 [Buildroot] [PATCH v5 1/3] package/nushell: new package Sebastian Weyer
@ 2023-03-08  8:53 ` Sebastian Weyer
  2023-03-08  9:57   ` Romain Naour
  2023-03-08  8:53 ` [Buildroot] [PATCH v5 3/3] support/testing/tests/package/test_nu.py: New runtime test Sebastian Weyer
  2023-03-08  9:53 ` [Buildroot] [PATCH v5 1/3] package/nushell: new package Romain Naour
  2 siblings, 1 reply; 6+ messages in thread
From: Sebastian Weyer @ 2023-03-08  8:53 UTC (permalink / raw)
  To: buildroot; +Cc: Sebastian Weyer

Automatically place default files for the nushell environment and
config in the appropriate folder to avoid the prompt at startup, asking
if you want to create them.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
---
These default configs are optional and might not even be necessary, they
only prevent the prompt at the first startup of the shell
---
 package/nushell/nushell.mk | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/package/nushell/nushell.mk b/package/nushell/nushell.mk
index 836f414d0a..0a596c39fa 100644
--- a/package/nushell/nushell.mk
+++ b/package/nushell/nushell.mk
@@ -10,6 +10,15 @@ NUSHELL_LICENSE = MIT
 NUSHELL_LICENSE_FILES = LICENSE
 NUSHELL_DEPENDENCIES = openssl host-pkgconf ncurses
 
+define NUSHELL_CREATE_DEFCONFIG
+	$(INSTALL) -m 0644 -D $(@D)/crates/nu-utils/src/sample_config/default_config.nu \
+		$(TARGET_DIR)/root/.config/nushell/config.nu
+	$(INSTALL) -m 0644 -D $(@D)/crates/nu-utils/src/sample_config/default_env.nu \
+		$(TARGET_DIR)/root/.config/nushell/env.nu
+endef
+
+NUSHELL_POST_INSTALL_TARGET_HOOKS += NUSHELL_CREATE_DEFCONFIG
+
 # Add /bin/nu to /etc/shells as in package/bash/bash.mk
 define NUSHELL_ADD_NU_TO_SHELLS
 	grep -qsE '^/bin/nu$$' $(TARGET_DIR)/etc/shells \
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH v5 3/3] support/testing/tests/package/test_nu.py: New runtime test
  2023-03-08  8:53 [Buildroot] [PATCH v5 1/3] package/nushell: new package Sebastian Weyer
  2023-03-08  8:53 ` [Buildroot] [PATCH v5 2/3] package/nushell: Add default configs Sebastian Weyer
@ 2023-03-08  8:53 ` Sebastian Weyer
  2023-03-08 10:10   ` Romain Naour
  2023-03-08  9:53 ` [Buildroot] [PATCH v5 1/3] package/nushell: new package Romain Naour
  2 siblings, 1 reply; 6+ messages in thread
From: Sebastian Weyer @ 2023-03-08  8:53 UTC (permalink / raw)
  To: buildroot; +Cc: Sebastian Weyer

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 3781 bytes --]

Load sample script support/testing/tests/package/sample_nu.nu onto the
target and verify proper execution by nushell

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
---
 DEVELOPERS                                 |  2 +
 support/testing/tests/package/sample_nu.nu |  6 ++
 support/testing/tests/package/test_nu.py   | 65 ++++++++++++++++++++++
 3 files changed, 73 insertions(+)
 create mode 100644 support/testing/tests/package/sample_nu.nu
 create mode 100644 support/testing/tests/package/test_nu.py

diff --git a/DEVELOPERS b/DEVELOPERS
index 4577f20b22..726cd73af7 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2552,6 +2552,8 @@ F:	package/ripgrep/
 
 N:  Sebastian Weyer <sebastian.weyer@smile.fr>
 F:	package/nushell/
+F:	support/testing/tests/package/test_nu.py
+F:	support/testing/tests/package/sample_nu.nu
 
 N:	Sébastien Szymanski <sebastien.szymanski@armadeus.com>
 F:	package/mmc-utils/
diff --git a/support/testing/tests/package/sample_nu.nu b/support/testing/tests/package/sample_nu.nu
new file mode 100644
index 0000000000..8904b29933
--- /dev/null
+++ b/support/testing/tests/package/sample_nu.nu
@@ -0,0 +1,6 @@
+# myscript.nu
+def greet [name] {
+  ["hello" $name]
+}
+
+greet "world"
diff --git a/support/testing/tests/package/test_nu.py b/support/testing/tests/package/test_nu.py
new file mode 100644
index 0000000000..b7ca52038d
--- /dev/null
+++ b/support/testing/tests/package/test_nu.py
@@ -0,0 +1,65 @@
+import os
+
+import infra.basetest
+
+class TestNuBase(infra.basetest.BRTest):
+    # infra.basetest.BASIC_TOOLCHAIN_CONFIG cannot be used as it doesn't
+    # support a host rustc which is necessary for nushell
+    config = \
+        """
+        BR2_arm=y
+        BR2_cortex_a9=y
+        BR2_ARM_ENABLE_NEON=y
+        BR2_ARM_ENABLE_VFP=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+        BR2_SYSTEM_DHCP="eth0"
+        BR2_PACKAGE_NUSHELL=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        """
+
+    def login(self):
+        img = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv7",
+                           kernel="builtin",
+                           options=["-initrd",img])
+        self.emulator.login()
+
+# load a scipt on the target and check if it is executed correctly by nu
+class TestNu(TestNuBase):
+    config_sample_scripts = \
+        """
+        BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
+        BR2_ROOTFS_POST_SCRIPT_ARGS="{}"
+        """.format(infra.filepath("tests/package/copy-sample-script-to-target.sh"),
+                   "{sample_scripts}")
+
+    #simple hello world script found in the nushell doc
+    sample_scripts = ["tests/package/sample_nu.nu"]
+
+    timeout = -1
+    interpreter = "nu"
+
+    def __init__(self, names):
+        """Add the scripts to the target in build time."""
+        super(TestNuBase, self).__init__(names)
+        scripts = [infra.filepath(s) for s in self.sample_scripts]
+        self.config += self.config_sample_scripts.format(sample_scripts=" ".join(scripts))
+
+    def check_sample_scripts_exist(self):
+        """Check the scripts were really added to the image."""
+        scripts = [os.path.basename(s) for s in self.sample_scripts]
+        cmd = "md5sum " + " ".join(scripts)
+        _, exit_code = self.emulator.run(cmd)
+        self.assertEqual(exit_code, 0)
+
+    def run_sample_scripts(self):
+        """Run each script previously added to the image."""
+        for script in self.sample_scripts:
+            cmd = self.interpreter + " " + os.path.basename(script)
+            self.assertRunOk(cmd, timeout=self.timeout)
+
+    def test_run(self):
+        self.login()
+        self.check_sample_scripts_exist()
+        self.run_sample_scripts()
-- 
2.25.1


[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH v5 1/3] package/nushell: new package
  2023-03-08  8:53 [Buildroot] [PATCH v5 1/3] package/nushell: new package Sebastian Weyer
  2023-03-08  8:53 ` [Buildroot] [PATCH v5 2/3] package/nushell: Add default configs Sebastian Weyer
  2023-03-08  8:53 ` [Buildroot] [PATCH v5 3/3] support/testing/tests/package/test_nu.py: New runtime test Sebastian Weyer
@ 2023-03-08  9:53 ` Romain Naour
  2 siblings, 0 replies; 6+ messages in thread
From: Romain Naour @ 2023-03-08  9:53 UTC (permalink / raw)
  To: Sebastian Weyer, buildroot

Le 08/03/2023 à 09:53, Sebastian Weyer a écrit :
> Nushell is a shell - written in Rust - that makes use of the nushell
> language to interact with the operating system
> 
> Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
> ---
> This new version adds ncurses-target-progs as a dependency which is a
> hidden dependency of nushell. With this option enabled, nushell is also
> usable without specifically replacing getty by agetty.

For the next time, please keep the history of changes between each new version.

> 
> Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
> ---
>  DEVELOPERS                   |  3 +++
>  package/Config.in            |  1 +
>  package/nushell/Config.in    | 12 ++++++++++++
>  package/nushell/nushell.hash |  2 ++
>  package/nushell/nushell.mk   | 20 ++++++++++++++++++++
>  5 files changed, 38 insertions(+)
>  create mode 100644 package/nushell/Config.in
>  create mode 100644 package/nushell/nushell.hash
>  create mode 100644 package/nushell/nushell.mk
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 6256576e02..4577f20b22 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -2550,6 +2550,9 @@ F:	support/misc/toolchainfile.cmake.in
>  N:	Sam Voss <sam.voss@gmail.com>
>  F:	package/ripgrep/
>  
> +N:  Sebastian Weyer <sebastian.weyer@smile.fr>

Small indentation issue.

> +F:	package/nushell/
> +
>  N:	Sébastien Szymanski <sebastien.szymanski@armadeus.com>
>  F:	package/mmc-utils/
>  F:	package/python-flask-jsonrpc/
> diff --git a/package/Config.in b/package/Config.in
> index 3ace25c665..7fca46afb5 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -2577,6 +2577,7 @@ comment "Shells"
>  	source "package/bash/Config.in"
>  	source "package/dash/Config.in"
>  	source "package/mksh/Config.in"
> +	source "package/nushell/Config.in"
>  	source "package/zsh/Config.in"
>  comment "Utilities"
>  	source "package/apg/Config.in"
> diff --git a/package/nushell/Config.in b/package/nushell/Config.in
> new file mode 100644
> index 0000000000..edb01d2f72
> --- /dev/null
> +++ b/package/nushell/Config.in
> @@ -0,0 +1,12 @@
> +config BR2_PACKAGE_NUSHELL
> +	bool "nushell"
> +	depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
> +	select BR2_PACKAGE_HOST_RUSTC
> +	select BR2_PACKAGE_OPENSSL
> +	select BR2_PACKAGE_HOST_PKGCONF
> +	select BR2_PACKAGE_NCURSES
> +	select BR2_PACKAGE_NCURSES_TARGET_PROGS
> +	help
> +	  A new type of shell.
> +
> +	  https://github.com/nushell/nushell
> diff --git a/package/nushell/nushell.hash b/package/nushell/nushell.hash
> new file mode 100644
> index 0000000000..a77e711a5d
> --- /dev/null
> +++ b/package/nushell/nushell.hash
> @@ -0,0 +1,2 @@
> +# Locally generated
> +sha256  352e807698d5f95e9bfdd9dd5512acab3cbef315379299a32e5f322a76eb718a  nushell-0.76.0.tar.gz

Missing hash of the LICENSE file.

> diff --git a/package/nushell/nushell.mk b/package/nushell/nushell.mk
> new file mode 100644
> index 0000000000..836f414d0a
> --- /dev/null
> +++ b/package/nushell/nushell.mk
> @@ -0,0 +1,20 @@
> +################################################################################
> +#
> +# nushell
> +#
> +################################################################################
> +
> +NUSHELL_VERSION = 0.76.0
> +NUSHELL_SITE = $(call github,nushell,nushell,$(NUSHELL_VERSION))
> +NUSHELL_LICENSE = MIT
> +NUSHELL_LICENSE_FILES = LICENSE
> +NUSHELL_DEPENDENCIES = openssl host-pkgconf ncurses

Please don't mix host and target package in this list.

> +
> +# Add /bin/nu to /etc/shells as in package/bash/bash.mk

nu is installed into /usr/bin/ not /bin.

Maybe you had BR2_ROOTFS_MERGED_USR=y ?

Best regards,
Romain


> +define NUSHELL_ADD_NU_TO_SHELLS
> +	grep -qsE '^/bin/nu$$' $(TARGET_DIR)/etc/shells \
> +		|| echo "/bin/nu" >> $(TARGET_DIR)/etc/shells
> +endef
> +NUSHELL_TARGET_FINALIZE_HOOKS += NUSHELL_ADD_NU_TO_SHELLS
> +
> +$(eval $(cargo-package))
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH v5 2/3] package/nushell: Add default configs
  2023-03-08  8:53 ` [Buildroot] [PATCH v5 2/3] package/nushell: Add default configs Sebastian Weyer
@ 2023-03-08  9:57   ` Romain Naour
  0 siblings, 0 replies; 6+ messages in thread
From: Romain Naour @ 2023-03-08  9:57 UTC (permalink / raw)
  To: Sebastian Weyer, buildroot

Le 08/03/2023 à 09:53, Sebastian Weyer a écrit :
> Automatically place default files for the nushell environment and
> config in the appropriate folder to avoid the prompt at startup, asking
> if you want to create them.
> 
> Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
> ---
> These default configs are optional and might not even be necessary, they
> only prevent the prompt at the first startup of the shell
> ---
>  package/nushell/nushell.mk | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/package/nushell/nushell.mk b/package/nushell/nushell.mk
> index 836f414d0a..0a596c39fa 100644
> --- a/package/nushell/nushell.mk
> +++ b/package/nushell/nushell.mk
> @@ -10,6 +10,15 @@ NUSHELL_LICENSE = MIT
>  NUSHELL_LICENSE_FILES = LICENSE
>  NUSHELL_DEPENDENCIES = openssl host-pkgconf ncurses
>  
> +define NUSHELL_CREATE_DEFCONFIG

The name of this define is not really accurate, what about
NUSHELL_INSTALL_DEFAULT_CONFIG ?

> +	$(INSTALL) -m 0644 -D $(@D)/crates/nu-utils/src/sample_config/default_config.nu \
> +		$(TARGET_DIR)/root/.config/nushell/config.nu
> +	$(INSTALL) -m 0644 -D $(@D)/crates/nu-utils/src/sample_config/default_env.nu \
> +		$(TARGET_DIR)/root/.config/nushell/env.nu
> +endef
> +
I think you can remove this new empty line.
> +NUSHELL_POST_INSTALL_TARGET_HOOKS += NUSHELL_CREATE_DEFCONFIG

Best regards,
Romain


> +
>  # Add /bin/nu to /etc/shells as in package/bash/bash.mk
>  define NUSHELL_ADD_NU_TO_SHELLS
>  	grep -qsE '^/bin/nu$$' $(TARGET_DIR)/etc/shells \

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH v5 3/3] support/testing/tests/package/test_nu.py: New runtime test
  2023-03-08  8:53 ` [Buildroot] [PATCH v5 3/3] support/testing/tests/package/test_nu.py: New runtime test Sebastian Weyer
@ 2023-03-08 10:10   ` Romain Naour
  0 siblings, 0 replies; 6+ messages in thread
From: Romain Naour @ 2023-03-08 10:10 UTC (permalink / raw)
  To: Sebastian Weyer, buildroot

Le 08/03/2023 à 09:53, Sebastian Weyer a écrit :
> Load sample script support/testing/tests/package/sample_nu.nu onto the
> target and verify proper execution by nushell
> 
> Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
> ---
>  DEVELOPERS                                 |  2 +
>  support/testing/tests/package/sample_nu.nu |  6 ++
>  support/testing/tests/package/test_nu.py   | 65 ++++++++++++++++++++++
>  3 files changed, 73 insertions(+)
>  create mode 100644 support/testing/tests/package/sample_nu.nu
>  create mode 100644 support/testing/tests/package/test_nu.py
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 4577f20b22..726cd73af7 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -2552,6 +2552,8 @@ F:	package/ripgrep/
>  
>  N:  Sebastian Weyer <sebastian.weyer@smile.fr>
>  F:	package/nushell/
> +F:	support/testing/tests/package/test_nu.py
> +F:	support/testing/tests/package/sample_nu.nu
>  
>  N:	Sébastien Szymanski <sebastien.szymanski@armadeus.com>
>  F:	package/mmc-utils/
> diff --git a/support/testing/tests/package/sample_nu.nu b/support/testing/tests/package/sample_nu.nu
> new file mode 100644
> index 0000000000..8904b29933
> --- /dev/null
> +++ b/support/testing/tests/package/sample_nu.nu
> @@ -0,0 +1,6 @@

Do we need a shebang here ?

> +# myscript.nu

Remove this comment.

> +def greet [name] {
> +  ["hello" $name]
> +}
> +
> +greet "world"
> diff --git a/support/testing/tests/package/test_nu.py b/support/testing/tests/package/test_nu.py
> new file mode 100644
> index 0000000000..b7ca52038d
> --- /dev/null
> +++ b/support/testing/tests/package/test_nu.py
> @@ -0,0 +1,65 @@
> +import os
> +
> +import infra.basetest
> +
> +class TestNuBase(infra.basetest.BRTest):
> +    # infra.basetest.BASIC_TOOLCHAIN_CONFIG cannot be used as it doesn't
> +    # support a host rustc which is necessary for nushell
> +    config = \
> +        """
> +        BR2_arm=y
> +        BR2_cortex_a9=y
> +        BR2_ARM_ENABLE_NEON=y
> +        BR2_ARM_ENABLE_VFP=y
> +        BR2_TOOLCHAIN_EXTERNAL=y
> +        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
> +        BR2_SYSTEM_DHCP="eth0"
> +        BR2_PACKAGE_NUSHELL=y
> +        BR2_TARGET_ROOTFS_CPIO=y
> +        """
> +
> +    def login(self):
> +        img = os.path.join(self.builddir, "images", "rootfs.cpio")
> +        self.emulator.boot(arch="armv7",
> +                           kernel="builtin",
> +                           options=["-initrd",img])
> +        self.emulator.login()
> +
> +# load a scipt on the target and check if it is executed correctly by nu
> +class TestNu(TestNuBase):
> +    config_sample_scripts = \
> +        """
> +        BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
> +        BR2_ROOTFS_POST_SCRIPT_ARGS="{}"
> +        """.format(infra.filepath("tests/package/copy-sample-script-to-target.sh"),
> +                   "{sample_scripts}")
> +
> +    #simple hello world script found in the nushell doc
> +    sample_scripts = ["tests/package/sample_nu.nu"]
> +
> +    timeout = -1

-1 seems the default value for timeout.

> +    interpreter = "nu"
> +
> +    def __init__(self, names):
> +        """Add the scripts to the target in build time."""
> +        super(TestNuBase, self).__init__(names)
> +        scripts = [infra.filepath(s) for s in self.sample_scripts]
> +        self.config += self.config_sample_scripts.format(sample_scripts=" ".join(scripts))
> +
> +    def check_sample_scripts_exist(self):
> +        """Check the scripts were really added to the image."""
> +        scripts = [os.path.basename(s) for s in self.sample_scripts]
> +        cmd = "md5sum " + " ".join(scripts)
> +        _, exit_code = self.emulator.run(cmd)
> +        self.assertEqual(exit_code, 0)
> +
> +    def run_sample_scripts(self):
> +        """Run each script previously added to the image."""
> +        for script in self.sample_scripts:
> +            cmd = self.interpreter + " " + os.path.basename(script)

Maybe we can just use "nu " + os.path.basename(script)

I guess you used the python infra example.

> +            self.assertRunOk(cmd, timeout=self.timeout)
> +
> +    def test_run(self):
> +        self.login()
> +        self.check_sample_scripts_exist()
> +        self.run_sample_scripts()

Best regards,
Romain


> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-08 10:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08  8:53 [Buildroot] [PATCH v5 1/3] package/nushell: new package Sebastian Weyer
2023-03-08  8:53 ` [Buildroot] [PATCH v5 2/3] package/nushell: Add default configs Sebastian Weyer
2023-03-08  9:57   ` Romain Naour
2023-03-08  8:53 ` [Buildroot] [PATCH v5 3/3] support/testing/tests/package/test_nu.py: New runtime test Sebastian Weyer
2023-03-08 10:10   ` Romain Naour
2023-03-08  9:53 ` [Buildroot] [PATCH v5 1/3] package/nushell: new package Romain Naour

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.