| 1 | // Copyright (c) 2019, Daniel Martà <[email protected]> |
| 2 | // See LICENSE for licensing information |
| 3 | |
| 4 | package mainscip-go gomod mvdan.cc/gofumpt . `mvdan.cc/gofumpt`/ |
| 5 | |
| 6 | import ( |
| 7 | "encoding/jsonscip-go gomod github.com/golang/go/src go1.20 `encoding/json`/" |
| 8 | "flagscip-go gomod github.com/golang/go/src go1.20 flag/" |
| 9 | "osscip-go gomod github.com/golang/go/src go1.20 os/" |
| 10 | "os/execscip-go gomod github.com/golang/go/src go1.20 `os/exec`/" |
| 11 | "path/filepathscip-go gomod github.com/golang/go/src go1.20 `path/filepath`/" |
| 12 | "testingscip-go gomod github.com/golang/go/src go1.20 testing/" |
| 13 | |
| 14 | qtscip-go gomod github.com/frankban/quicktest v1.14.6 `github.com/frankban/quicktest`/ "github.com/frankban/quicktestscip-go gomod github.com/frankban/quicktest v1.14.6 `github.com/frankban/quicktest`/" |
| 15 | |
| 16 | "github.com/rogpeppe/go-internal/gotooltestscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/gotooltest`/" |
| 17 | "github.com/rogpeppe/go-internal/testscriptscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/" |
| 18 | ) |
| 19 | |
| 20 | func TestMainscip-go gomod mvdan.cc/gofumpt . `mvdan.cc/gofumpt`/TestMain().(m *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Mscip-go gomod github.com/golang/go/src go1.20 testing/M#) { |
| 21 | osscip-go gomod github.com/golang/go/src go1.20 os/.Exitscip-go gomod github.com/golang/go/src go1.20 os/Exit().(testscriptscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/.RunMainscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/RunMain().(m, map[string]func() int{ |
| 22 | "gofumpt": main1scip-go gomod mvdan.cc/gofumpt . `mvdan.cc/gofumpt`/main1()., |
| 23 | })) |
| 24 | } |
| 25 | |
| 26 | var updatescip-go gomod mvdan.cc/gofumpt . `mvdan.cc/gofumpt`/update. = flagscip-go gomod github.com/golang/go/src go1.20 flag/.Boolscip-go gomod github.com/golang/go/src go1.20 flag/Bool().("u", false, "update testscript output files") |
| 27 | |
| 28 | func TestScriptscip-go gomod mvdan.cc/gofumpt . `mvdan.cc/gofumpt`/TestScript().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 29 | t.Parallelscip-go gomod github.com/golang/go/src go1.20 testing/T#Parallel().() |
| 30 | |
| 31 | var goEnv struct { |
| 32 | GOCACHE string |
| 33 | GOMODCACHE string |
| 34 | GOMOD string |
| 35 | } |
| 36 | out, err := execscip-go gomod github.com/golang/go/src go1.20 `os/exec`/.Commandscip-go gomod github.com/golang/go/src go1.20 `os/exec`/Command().("go", "env", "-json").CombinedOutputscip-go gomod github.com/golang/go/src go1.20 `os/exec`/Cmd#CombinedOutput().() |
| 37 | if err != nil { |
| 38 | t.Fatalscip-go gomod github.com/golang/go/src go1.20 testing/common#Fatal().(err) |
| 39 | } |
| 40 | if err := jsonscip-go gomod github.com/golang/go/src go1.20 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.20 `encoding/json`/Unmarshal().(out, &goEnv); err != nil { |
| 41 | t.Fatalscip-go gomod github.com/golang/go/src go1.20 testing/common#Fatal().(err) |
| 42 | } |
| 43 | |
| 44 | p := testscriptscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/.Paramsscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Params#{ |
| 45 | Dirscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Params#Dir.: filepathscip-go gomod github.com/golang/go/src go1.20 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.20 `path/filepath`/Join().("testdata", "script"), |
| 46 | UpdateScriptsscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Params#UpdateScripts.: *updatescip-go gomod mvdan.cc/gofumpt . `mvdan.cc/gofumpt`/update., |
| 47 | RequireExplicitExecscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Params#RequireExplicitExec.: true, |
| 48 | Setupscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Params#Setup.: func(env *testscriptscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/.Envscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Env#) error { |
| 49 | env.Setenvscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Env#Setenv().("GOCACHE", goEnv.GOCACHE) |
| 50 | env.Setenvscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Env#Setenv().("GOMODCACHE", goEnv.GOMODCACHE) |
| 51 | env.Setenvscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Env#Setenv().("GOMOD_DIR", filepathscip-go gomod github.com/golang/go/src go1.20 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.20 `path/filepath`/Dir().(goEnv.GOMOD)) |
| 52 | return nil |
| 53 | }, |
| 54 | } |
| 55 | err = gotooltestscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/gotooltest`/.Setupscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/gotooltest`/Setup().(&p) |
| 56 | qtscip-go gomod github.com/frankban/quicktest v1.14.6 `github.com/frankban/quicktest`/.Assertscip-go gomod github.com/frankban/quicktest v1.14.6 `github.com/frankban/quicktest`/Assert().(t, err, qtscip-go gomod github.com/frankban/quicktest v1.14.6 `github.com/frankban/quicktest`/.IsNilscip-go gomod github.com/frankban/quicktest v1.14.6 `github.com/frankban/quicktest`/IsNil.) |
| 57 | testscriptscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/.Runscip-go gomod github.com/rogpeppe/go-internal v1.12.0 `github.com/rogpeppe/go-internal/testscript`/Run().(t, p) |
| 58 | } |