-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from vito/runs-errgroup
better error handling
- Loading branch information
Showing
9 changed files
with
129 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
; just for eyeballing files | ||
(defn ls paths | ||
(from (linux/alpine) | ||
($ ls -al & $paths))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package bass_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/vito/bass/pkg/bass" | ||
"github.com/vito/bass/pkg/basstest" | ||
"github.com/vito/is" | ||
) | ||
|
||
func TestRuns(t *testing.T) { | ||
is := is.New(t) | ||
|
||
ctx := context.Background() | ||
ctx, runs := bass.TrackRuns(ctx) | ||
|
||
errorScpt := bass.NewInMemoryFile("error.bass", ` | ||
(defn main [msg] | ||
(error msg)) | ||
`) | ||
|
||
thunk1 := bass.MustThunk(errorScpt).AppendArgs(bass.String("oh no")) | ||
thunk2 := bass.MustThunk(errorScpt).AppendArgs(bass.String("let's go")) | ||
|
||
errCb := bass.Func("err-if-not-ok", "[ok?]", func(ok bool) error { | ||
if !ok { | ||
return fmt.Errorf("it failed!") | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
comb1, err := thunk1.Start(ctx, errCb) | ||
is.NoErr(err) | ||
|
||
comb2, err := thunk2.Start(ctx, errCb) | ||
is.NoErr(err) | ||
|
||
_, err = basstest.Call(comb1, bass.NewEmptyScope(), bass.NewList()) | ||
is.True(err != nil) | ||
is.Equal(err.Error(), "it failed!: oh no") | ||
|
||
_, err = basstest.Call(comb2, bass.NewEmptyScope(), bass.NewList()) | ||
is.True(err != nil) | ||
is.Equal(err.Error(), "it failed!: let's go") | ||
|
||
err = runs.Wait() | ||
is.True(err != nil) | ||
is.True(strings.Contains(err.Error(), "it failed!: oh no")) | ||
is.True(strings.Contains(err.Error(), "it failed!: let's go")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
; location to track dependency resolution | ||
(def *memos* | ||
*dir*/bass/bass.lock) | ||
; file for memoized dependency resolution | ||
(def *memos* *dir*/bass/bass.lock) | ||
|
||
; load dependencies | ||
(use (.git (linux/alpine/git)) | ||
(*dir*/bass/bass.bass) | ||
(*dir*/bass/util.bass) | ||
(git:github/vito/bass-loop/ref/main/bass/github.bass)) | ||
|
||
; standard suite of validations for the repo | ||
(defn checks [src] | ||
{:build-linux (ls (bass:build src "dev" "linux" "amd64")) | ||
:build-darwin (ls (bass:build src "dev" "darwin" "amd64") | ||
{:build-linux (util:ls (bass:build src "dev" "linux" "amd64")) | ||
:build-darwin (util:ls (bass:build src "dev" "darwin" "amd64") | ||
(bass:build src "dev" "darwin" "arm64")) | ||
:build-windows (ls (bass:build src "dev" "windows" "amd64")) | ||
:docs (ls (bass:docs src)) | ||
:build-windows (util:ls (bass:build src "dev" "windows" "amd64")) | ||
:docs (util:ls (bass:docs src)) | ||
:test (bass:tests src ["./..."]) | ||
:nix (bass:nix-checks src)}) | ||
|
||
; just for eyeballing the files | ||
(defn ls paths | ||
(from (linux/alpine) | ||
($ ls -al & $paths))) | ||
|
||
; called by bass-loop | ||
(defn github-hook [event client] | ||
(github:check-hook event client git checks)) |