Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go: Add runnables #12110

Merged
merged 2 commits into from
May 22, 2024
Merged

go: Add runnables #12110

merged 2 commits into from
May 22, 2024

Conversation

mrnugget
Copy link
Member

@mrnugget mrnugget commented May 22, 2024

This adds support for runnables to Go.

It adds the following tasks:

  • go test $ZED_GO_PACKAGE -run $ZED_SYMBOL
  • go test $ZED_GO_PACKAGE
  • go test ./...
  • go run $ZED_GO_PACKAGE if it has a main function

Release Notes:

  • Added built-in Go runnables and tasks that allow users to run Go test functions, test packages, or run main functions.

Demo:

screenshot-2024-05-22-07.06.28.mp4
screenshot-2024-05-22-07.17.04.mp4

This adds support for runnables to Go.

It adds the following tasks:

- `go test $ZED_GO_PACKAGE -run $ZED_SYMBOL`
- `go test $ZED_GO_PACKAGE`
- `go test ./...`
- `go run $ZED_GO_PACKAGE` if it has a `main` function
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label May 22, 2024
Comment on lines +520 to +524
label: format!("go run {}", GO_PACKAGE_TASK_VARIABLE.template_value(),),
command: "go".into(),
args: vec!["run".into(), GO_PACKAGE_TASK_VARIABLE.template_value()],
tags: vec!["go-main".to_owned()],
..TaskTemplate::default()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osiewicz I assume it's not possible yet, but: is it possible for this task to only show up if there is something tagged with go-main? I only add the tag in the runnables.scm if there is a func main(), but this shows up everywhere. I don't think it's a blocker, because you can run packages without being on the main function, but still curious.

@mrnugget mrnugget merged commit 8168ec2 into main May 22, 2024
9 checks passed
@mrnugget mrnugget deleted the go-runnables branch May 22, 2024 05:18
@d1y d1y mentioned this pull request May 22, 2024
@joefitzgerald
Copy link

This looks very useful! However, my shell is fish, and running a test doesn't work:

fish: Variables cannot be bracketed. In fish, please use {$ZED_CUSTOM_GO_P…}.
go test ${ZED_CUSTOM_GO_PACKAGE} -run $ZED_SYMBOL
         ^

⏵ Task `go test ./http/middleware -run TestCacheBuster` finished with non-zero error code: 127
⏵ Command: '/opt/homebrew/bin/fish -i -c `go test ./http/middleware -run TestCacheBuster`'

@osiewicz
Copy link
Contributor

Hey Joe,
Yeah, that's related to #10964 - we need a way to pin execution of a task to a particular shell in order for fish and others to play nicely with language tasks

@sunliang711
Copy link

Thanks for your hard working, could you tell me how to add custom flags to 'go test', eg: 'go test -v -count=1 ...'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants