Skip to content

Commit

Permalink
update got version
Browse files Browse the repository at this point in the history
Here's the code we use to refactor

```go
func main() {
	_ = filepath.Walk(".", func(path string, info fs.FileInfo, err error) error {
		if !strings.HasSuffix(path, "_test.go") || strings.HasPrefix(path, "lib/proto/") {
			return nil
		}

		fmt.Println(path)

		f, _ := os.ReadFile(path)

		ms := regexp.MustCompile(`(?m)^func \(t T\)`).FindAllIndex(f, -1)
		for _, m := range ms {
			cmd := fmt.Sprintf("gopls -remote=127.0.0.1:8888 rename -w %s:#%d g", path, m[0]+6)
			utils.ExecLine(cmd)
		}

		f, _ = os.ReadFile(path)
		f = regexp.MustCompile(`(?m)^func \(g T\) ([^\s]+)\(\) \{`).
			ReplaceAll(f, []byte("func Test$1(t *testing.T) {\n\tg := setup(t)\n"))

		err = os.WriteFile(path, f, info.Mode())
		return err
	})
}
```
  • Loading branch information
ysmood committed Mar 30, 2022
1 parent 742c7ad commit dc4a004
Show file tree
Hide file tree
Showing 21 changed files with 1,980 additions and 1,495 deletions.
12 changes: 2 additions & 10 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,10 @@ The `cdp` requests of each test will be recorded and output to folder `tmp/cdp-l
[artifacts](https://docs.github.com/en/actions/guides/storing-workflow-data-as-artifacts) so that we can download
them for debugging.

### Filter tests

Use regex: `go test -run /^Click$`.

Test a specific package: `go test ./lib/launcher`.

Run all tests: `go test ./...`

### Disable headless mode

```bash
rod=show,trace,slow=2s go test -run /Click
rod=show,trace,slow=2s go test
```

Check type `defaults.ResetWithEnv` for how it works.
Expand Down Expand Up @@ -98,7 +90,7 @@ There are several helper functions for it:

1. Run lint in the container: `go run ./lib/utils/lint`

1. Run tests in the container: `go test -run /Click`
1. Run tests in the container: `go test`

1. After you exit the container with `exit`, you can restart it by: `docker start -i rod`

Expand Down
Loading

0 comments on commit dc4a004

Please sign in to comment.