Skip to content

Commit ec40535

Browse files
committed
added test to nushell-based plugin
1 parent 7560186 commit ec40535

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,40 @@ jobs:
6464
run: ./nu -n -c 'use testing.nu; testing run-tests --path ./javascript/${{ matrix.plugin }} --plugins ["./javascript/${{ matrix.plugin }}/${{ matrix.plugin}}.js"]'
6565

6666

67+
test-nushell:
68+
name: "Test Nushell-based Plugin: ${{ matrix.plugin }}"
69+
needs: build-nu
70+
runs-on: ubuntu-latest
71+
72+
strategy:
73+
matrix:
74+
plugin:
75+
- nu_plugin_nu_example
76+
77+
steps:
78+
- uses: actions/checkout@v4
79+
80+
- name: Setup Nushell
81+
uses: hustcer/setup-nu@v3
82+
83+
- name: Download Nushell Binary
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: nu
87+
88+
- name: Ensure Nushell binary is executable
89+
run: chmod +x ./nu
90+
91+
# - name: Download testing.nu
92+
# run: wget ${{ env.testing-file }}
93+
94+
- name: Ensure plugin is executable
95+
run: chmod +x ./nushell/${{ matrix.plugin }}/${{ matrix.plugin }}.nu
96+
97+
- name: Run tests
98+
run: ./nu -n -c 'use testing.nu; testing run-tests --path ./nushell/${{ matrix.plugin }} --plugins ["./nushell/${{ matrix.plugin }}/${{ matrix.plugin}}.nu"]'
99+
100+
67101
test-python:
68102
name: "Test Python-based Plugin: ${{ matrix.plugin }}"
69103
needs: build-nu
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@echo off
2-
nu %~dp0nu_plugin_nu_example.nu %*
2+
nu --stdin %~dp0nu_plugin_nu_example.nu %*

nushell/nu_plugin_nu_example/nu_plugin_nu_example.nu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def process_call [
125125
# Use this information to implement your plugin logic
126126

127127
# Print the call to stderr, in raw nuon and as a table
128-
$plugin_call | to nuon --raw | print -e
129-
$plugin_call | table -e | print -e
128+
# $plugin_call | to nuon --raw | print -e
129+
# $plugin_call | table -e | print -e
130130

131131
# Get the span from the call
132132
let span = $plugin_call.call.head
@@ -247,6 +247,7 @@ def handle_input []: any -> nothing {
247247
}
248248
}
249249
}
250+
{ Signal: "Reset" } => ignore
250251
$other => {
251252
print -e $"Unknown message: ($other | to json --raw)"
252253
exit 1

nushell/nu_plugin_nu_example/test_nu_plugin_nu_example.nu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std/assert
33

44
@test
55
def test [] {
6-
let expected = (0..9 | generate {|i| {out: {one: $i, two: ($i * 2), three: ($i * 3)}, next: ($i + 1)}} 0)
7-
assert equal (node_example 1 a) $expected
8-
assert length (node_example 1 a) 10
6+
let expected = (0..9 | generate {|i| {out: {one: 0, two: $i, three: ($i * 2)}, next: ($i + 1)}} 0)
7+
assert equal (nu_plugin_nu_example 1 a) $expected
8+
assert length (nu_plugin_nu_example 1 a) 10
99
}

0 commit comments

Comments
 (0)