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

update tests for Go 1.19 and test with a fresh cache #262

Merged
merged 5 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
go: ['1.17', '1.18']
go: ['1.17', '1.18', '1.19']
node: ['16']
include:
- os: ubuntu-latest
Expand All @@ -23,6 +23,9 @@ jobs:
- os: macos-latest
go: 1.18
node: 18
- os: macos-latest
go: 1.19
node: 18

steps:
- name: Check out bud
Expand Down Expand Up @@ -61,6 +64,10 @@ jobs:
path: $TMPDIR/bud/snapshot
key: ${{ runner.os }}

- name: Run Go Format on Go 1.19
if: matrix.go == '1.19'
run: make go.fmt

- name: Run CI (Ubuntu Linux)
if: matrix.os == 'ubuntu-latest'
run: make ci.ubuntu
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ budjs.test:

test: test.dev
test.dev: go.tools go.generate go.fmt go.vet budjs.check budjs.test go.test
test.all: go.tools go.generate go.fmt go.vet budjs.check budjs.test go.test
test.all: go.tools go.generate go.vet budjs.check budjs.test go.test

##
# CI
Expand Down
2 changes: 1 addition & 1 deletion framework/public/public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestPlugin(t *testing.T) {
ctx := context.Background()
dir := t.TempDir()
td := testdir.New(dir)
td.Modules["github.com/livebud/bud-test-plugin"] = "v0.0.8"
td.Modules["github.com/livebud/bud-test-plugin"] = "v0.0.9"
is.NoErr(td.Write(ctx))
cli := testcli.New(dir)
app, err := cli.Start(ctx, "run")
Expand Down
1 change: 1 addition & 0 deletions framework/web/welcome/welcome.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

// Files are built in https://github.com/livebud/welcome and manually copied
// over.
//
//go:embed build/index.html build/bud/view/_index.svelte.js
var embeds embed.FS

Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/gitchander/permutation v0.0.0-20201214100618-1f3e7285f953
github.com/keegancsmith/rpc v1.3.0
github.com/lithammer/dedent v1.1.0
github.com/livebud/bud-test-plugin v0.0.9
github.com/matthewmueller/diff v0.0.0-20220104030700-cb2fe910d90c
github.com/matthewmueller/gotext v0.0.0-20210424201144-265ed61725ac
github.com/matthewmueller/text v0.0.0-20210424201111-ec1e4af8dfe8
Expand All @@ -22,9 +23,9 @@ require (
github.com/timewasted/go-accept-headers v0.0.0-20130320203746-c78f304b1b09
github.com/xlab/treeprint v1.1.0
go.kuoruan.net/v8go-polyfills v0.5.1-0.20220727011656-c74c5b408ebd
golang.org/x/mod v0.5.1
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/tools v0.1.9
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f
rogchap.com/v8go v0.7.0
src.techknowlogick.com/xgo v1.4.1-0.20220413212431-091a0a22b814
)
Expand All @@ -34,12 +35,12 @@ require (
github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/livebud/bud-test-nested-plugin v0.0.5 // indirect
github.com/pointlander/compress v1.1.1-0.20190518213731-ff44bd196cc3 // indirect
github.com/pointlander/jetset v1.0.1-0.20190518214125-eee7eff80bd4 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffktY=
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
github.com/livebud/bud-test-nested-plugin v0.0.5 h1:MpPp20Gng0F+Kvl+L9kttu6nsJIYkIUfvuFMCGe/BeA=
github.com/livebud/bud-test-nested-plugin v0.0.5/go.mod h1:M3QujkGG4ggZ6h75t5zF8MEJFrLTwa2USeIYHQdO2YQ=
github.com/livebud/bud-test-plugin v0.0.9 h1:JmS4aj+NV52RUroteLs+ld6rcbkBwio7p9qPNutTsqM=
github.com/livebud/bud-test-plugin v0.0.9/go.mod h1:GTxMZ8W4BIyGIOgAA4hvPHMDDTkaZtfcuhnOcSu3y8M=
github.com/matthewmueller/diff v0.0.0-20220104030700-cb2fe910d90c h1:yjGBNrCIE7IghJAwrFcyDzwzwJKf0oRPeOHx60wfkmA=
github.com/matthewmueller/diff v0.0.0-20220104030700-cb2fe910d90c/go.mod h1:xIxeV0n2W+WNB3ik/j9lUkcrQAk71VrvT9ch8u4pcvM=
github.com/matthewmueller/gotext v0.0.0-20210424201144-265ed61725ac h1:SjopLdUF96kdJU8ynYmGVHoJmngpwFHRvR5p2plBXG4=
Expand Down Expand Up @@ -83,8 +87,8 @@ github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
go.kuoruan.net/v8go-polyfills v0.5.1-0.20220727011656-c74c5b408ebd h1:lMfOO39WTD+CxBPmqZvLdISrLVsEjgNfWoV4viBt15M=
go.kuoruan.net/v8go-polyfills v0.5.1-0.20220727011656-c74c5b408ebd/go.mod h1:egHzK8RIHR7dPOYzhnRsomClFTVmYCtvhTWqec4JXaY=
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
Expand All @@ -99,10 +103,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8=
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f h1:OKYpQQVE3DKSc3r3zHVzq46vq5YH7x8xpR3/k9ixmUg=
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
10 changes: 5 additions & 5 deletions internal/cli/bud/bud.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ type Command struct {

// Run a custom command
// TODO: finish supporting custom commands
// 1. Compile
// a. Generate generator (later!)
// i. Generate bud/internal/generator
// 1. Compile
// a. Generate generator (later!)
// i. Generate bud/internal/generator
// ii. Build bud/generator
// iii. Run bud/generator
// b. Generate custom command
// b. Generate custom command
// i. Generate bud/internal/command/${name}/
// ii. Build bud/command/${name}
// 2. Run bud/command/${name}
// 2. Run bud/command/${name}
func (c *Command) Run(ctx context.Context) error {
return commander.Usage()
}
Expand Down
1 change: 1 addition & 0 deletions internal/cli/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestCreateOutsideGoPath(t *testing.T) {
cli := testcli.New(dir)
is.NoErr(td.NotExists(".gitignore"))
result, err := cli.Run(ctx, "create", dir)
is.NoErr(err)
is.Equal(result.Stdout(), "")
is.Equal(result.Stderr(), "")
is.Equal(fileFirstLine(filepath.Join(dir, "go.mod")), "module change.me\n")
Expand Down
2 changes: 1 addition & 1 deletion internal/entrypoint/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func route(dir, name string) string {

// The client path's entrypoint
//
// e.g. view/index.jsx => bud/view/_index.jsx
// e.g. view/index.jsx => bud/view/_index.jsx
//
// We use the _ because this is a generated entrypoint
// that
Expand Down
2 changes: 1 addition & 1 deletion internal/gois/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,5 @@ var stdlib = map[string]struct{}{
"vendor/golang.org/x/text/secure/bidirule": {},
"vendor/golang.org/x/text/transform": {},
"vendor/golang.org/x/text/unicode/bidi": {},
"vendor/golang.org/x/text/unicode/norm ": {},
"vendor/golang.org/x/text/unicode/norm ": {},
}
11 changes: 6 additions & 5 deletions internal/prompter/prompter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// output during `bud run`.
//
// The public methods must be called in the right order:
// 1. Init
// 2. Reloading
// 3. SuccessReload or FailReload or NoReload
// 4. Reloading
// 1. Init
// 2. Reloading
// 3. SuccessReload or FailReload or NoReload
// 4. Reloading
//
// So the cursor can moves and clear lines properly. The behavior of the cursor
// across the different states looks like the following:
Expand Down Expand Up @@ -80,7 +80,8 @@ func (p *Prompter) startTimer() {
}

// Init -> Reloading -> `Success reload` or `Fail reload` or `Made no reload` ->
// Reloading -> ...
//
// Reloading -> ...
var nextState = map[string]string{
"init": "reload",
reload: "fail/success/no re",
Expand Down
1 change: 0 additions & 1 deletion livebud/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livebud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
"ts-eager": "2.0.2",
"typescript": "4.3.4"
}
}
}
23 changes: 21 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package/di/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ func (fn *Function) Generate(g Generator, ins []*Variable) (outs []*Variable) {
// Given the following dependency: *Web, tryFunction will match on the
// following functions:
//
// func ...(...) *Web
// func ...(...) Web
// func ...(...) (*Web, error)
// func ...(...) (Web, error)
//
// func ...(...) *Web
// func ...(...) Web
// func ...(...) (*Web, error)
// func ...(...) (Web, error)
func tryFunction(fn *parser.Function, importPath, dataType string) (*function, error) {
if fn.Private() || fn.Receiver() != nil {
return nil, ErrNoMatch
Expand Down
37 changes: 18 additions & 19 deletions package/di/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,30 @@ func (g *generator) WriteString(code string) (n int, err error) {
//
// For example, given the `web`, `log`, and `console` packages:
//
// package web
// func Load(log log.Log) *Web {}
// type Web struct {}
// package web
// func Load(log log.Log) *Web {}
// type Web struct {}
//
// package log
// type Log interface {
// Log(msg string)
// }
// package log
// type Log interface {
// Log(msg string)
// }
//
// package console
// type Console struct {}
// func (c *Console) Log(msg string)
// package console
// type Console struct {}
// func (c *Console) Log(msg string)
//
// If we generate into the `genweb` package for `*Web`, the `log` package isn't
// actually referenced.
//
// package genweb
// import "web"
// import "console"
// func Load() *web.Web {
// consoleConsole := &console.Console{}
// webWeb := Load(consoleConsole)
// return webWeb
// }
//
// package genweb
// import "web"
// import "console"
// func Load() *web.Web {
// consoleConsole := &console.Console{}
// webWeb := Load(consoleConsole)
// return webWeb
// }
func (g *generator) Variable(importPath, typeName string) string {
if typeName == "error" {
return "err"
Expand Down
3 changes: 1 addition & 2 deletions package/di/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ func (s *StructField) Find(finder Finder) (Declaration, error) {
// Given the following dependency: Web, tryStruct will match on the
// following functions:
//
// type Web struct { ... }
//
// type Web struct { ... }
func tryStruct(stct *parser.Struct, dataType string) (*Struct, error) {
if stct.Private() {
return nil, ErrNoMatch
Expand Down
4 changes: 2 additions & 2 deletions package/gomod/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ func TestLocalResolveDirectory(t *testing.T) {
module, err := gomod.Parse("go.mod", []byte(`module app.test`))
is.NoErr(err)
modFile := module.File()
modFile.AddRequire("github.com/livebud/bud-test-plugin", "v0.0.2")
modFile.AddRequire("github.com/livebud/bud-test-plugin", "v0.0.9")
dir, err := module.ResolveDirectory("github.com/livebud/bud-test-plugin")
is.NoErr(err)
is.Equal(dir, filepath.Join(modcache.Default().Directory(), "github.com/livebud", "bud-test-plugin@v0.0.2"))
is.Equal(dir, filepath.Join(modcache.Default().Directory(), "github.com/livebud", "bud-test-plugin@v0.0.9"))
}

func TestFindRequire(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions package/gomod/mod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TestFindNested(t *testing.T) {
dir, err := filepath.EvalSymlinks(t.TempDir())
is.NoErr(err)
td := testdir.New(dir)
td.Modules["github.com/livebud/bud-test-plugin"] = "v0.0.8"
td.Modules["github.com/livebud/bud-test-plugin"] = "v0.0.9"
err = td.Write(ctx)
is.NoErr(err)
modCache := modcache.Default()
Expand All @@ -171,7 +171,7 @@ func TestFindNested(t *testing.T) {
module2, err := module1.Find("github.com/livebud/bud-test-plugin")
is.NoErr(err)
is.Equal(module2.Import(), "github.com/livebud/bud-test-plugin")
is.Equal(module2.Directory(), modCache.Directory("github.com/livebud", "bud-test-plugin@v0.0.8"))
is.Equal(module2.Directory(), modCache.Directory("github.com/livebud", "bud-test-plugin@v0.0.9"))
data, err = fs.ReadFile(module2, "go.mod")
is.NoErr(err)
m2, err := gomod.Parse("go.mod", data)
Expand All @@ -197,7 +197,7 @@ func TestFindNested(t *testing.T) {

// Ensure module2 is not overridden
is.Equal(module2.Import(), "github.com/livebud/bud-test-plugin")
is.Equal(module2.Directory(), modCache.Directory("github.com/livebud", "bud-test-plugin@v0.0.8"))
is.Equal(module2.Directory(), modCache.Directory("github.com/livebud", "bud-test-plugin@v0.0.9"))
}

func TestOpen(t *testing.T) {
Expand Down
Loading