diff --git a/pkg/bass/ground_test.go b/pkg/bass/ground_test.go index a544a432..5554055e 100644 --- a/pkg/bass/ground_test.go +++ b/pkg/bass/ground_test.go @@ -1567,6 +1567,11 @@ func TestGroundPipes(t *testing.T) { Bass: "(take 2 (list->source [1 2 3]))", Result: bass.NewList(bass.Int(1), bass.Int(2)), }, + { + Name: "take-all", + Bass: "(take-all (list->source [1 2 3]))", + Result: bass.NewList(bass.Int(1), bass.Int(2), bass.Int(3)), + }, { Name: "across", Bass: "(next (across (list->source [0 2 4]) (list->source [1 3 5])))", diff --git a/pkg/runtimes/testdata/addrs.bass b/pkg/runtimes/testdata/addrs.bass index cfa0e311..ab82de0b 100644 --- a/pkg/runtimes/testdata/addrs.bass +++ b/pkg/runtimes/testdata/addrs.bass @@ -1,12 +1,13 @@ (defn http-server [index] - (from (linux/nixery.dev/simple-http-server) - (-> ($ simple-http-server -i) + (from (linux/alpine) + ($ apk add python3) + (-> ($ python3 -m http.server) (with-mount (mkfile ./index.html index) ./index.html) (with-port :http 8000)))) (let [srv (http-server "hello, world!")] - (-> ($ curl -s (addr srv :http "http://$host:$port")) - (with-image (linux/nixery.dev/curl)) + (-> ($ wget -O- (addr srv :http "http://$host:$port")) + (with-image (linux/alpine)) (read :raw) next dump)) diff --git a/pkg/runtimes/testdata/bass.lock b/pkg/runtimes/testdata/bass.lock index fe888c1a..444dc701 100644 --- a/pkg/runtimes/testdata/bass.lock +++ b/pkg/runtimes/testdata/bass.lock @@ -85,7 +85,7 @@ memos: { symbol: "digest" value: { string: { - value: "sha256:7580ece7963bfa863801466c0a488f11c86f85d9988051a9f9c68cb27f6b7872" + value: "sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad" } } } @@ -176,173 +176,5 @@ memos: { } } } - results: { - input: { - array: { - values: { - object: { - bindings: { - symbol: "platform" - value: { - object: { - bindings: { - symbol: "os" - value: { - string: { - value: "linux" - } - } - } - } - } - } - bindings: { - symbol: "repository" - value: { - string: { - value: "nixery.dev/simple-http-server" - } - } - } - bindings: { - symbol: "tag" - value: { - string: { - value: "latest" - } - } - } - } - } - } - } - output: { - object: { - bindings: { - symbol: "repository" - value: { - string: { - value: "nixery.dev/simple-http-server" - } - } - } - bindings: { - symbol: "platform" - value: { - object: { - bindings: { - symbol: "os" - value: { - string: { - value: "linux" - } - } - } - } - } - } - bindings: { - symbol: "tag" - value: { - string: { - value: "latest" - } - } - } - bindings: { - symbol: "digest" - value: { - string: { - value: "sha256:13a32cf276567978ad829355e336174aa107f29e7cf078a25ec30ba1d1bc8d5d" - } - } - } - } - } - } - results: { - input: { - array: { - values: { - object: { - bindings: { - symbol: "platform" - value: { - object: { - bindings: { - symbol: "os" - value: { - string: { - value: "linux" - } - } - } - } - } - } - bindings: { - symbol: "repository" - value: { - string: { - value: "nixery.dev/curl" - } - } - } - bindings: { - symbol: "tag" - value: { - string: { - value: "latest" - } - } - } - } - } - } - } - output: { - object: { - bindings: { - symbol: "repository" - value: { - string: { - value: "nixery.dev/curl" - } - } - } - bindings: { - symbol: "platform" - value: { - object: { - bindings: { - symbol: "os" - value: { - string: { - value: "linux" - } - } - } - } - } - } - bindings: { - symbol: "tag" - value: { - string: { - value: "latest" - } - } - } - bindings: { - symbol: "digest" - value: { - string: { - value: "sha256:ea6ad85d3dfbf10668b325aa4382eea4859df41cdd160d7204bd9200a698b24d" - } - } - } - } - } - } } } diff --git a/std/streams.bass b/std/streams.bass index 5a32630f..e0a86708 100644 --- a/std/streams.bass +++ b/std/streams.bass @@ -52,3 +52,12 @@ (if (<= n 0) [] (cons (next source) (take (- n 1) source)))) + +; reads all values from the source into a list +; +; => (take-all (list->source [1 2 3])) +(defn take-all [source] + (let [val (next source _)] + (if (ignore? val) + [] + (cons val (take-all source)))))