Skip to content

Commit

Permalink
optimize code style, according to review
Browse files Browse the repository at this point in the history
  • Loading branch information
hunshcn committed May 17, 2024
1 parent 86faa07 commit a46b206
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions gazelle/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ use_repo(
"org_golang_x_sync",
)

non_module_deps = use_extension("//:def.bzl", "non_module_deps")
python_stdlib_list = use_extension("//python:extensions.bzl", "python_stdlib_list")
use_repo(
non_module_deps,
python_stdlib_list,
"python_stdlib_list_3_10",
"python_stdlib_list_3_11",
"python_stdlib_list_3_12",
Expand Down
8 changes: 0 additions & 8 deletions gazelle/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,5 @@
"""This module contains the Gazelle runtime dependencies for the Python extension.
"""

load("@bazel_skylib//lib:modules.bzl", "modules")
load(":deps.bzl", "python_stdlib_list_deps")

GAZELLE_PYTHON_RUNTIME_DEPS = [
]

non_module_deps = modules.as_extension(
python_stdlib_list_deps,
doc = "This extension registers python stdlib list dependencies.",
)
5 changes: 5 additions & 0 deletions gazelle/python/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"python_stdlib_list module extension for use with bzlmod"

load("//python/private:extensions.bzl", _python_stdlib_list = "python_stdlib_list")

python_stdlib_list = _python_stdlib_list
Empty file.
9 changes: 9 additions & 0 deletions gazelle/python/private/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"python_stdlib_list module extension for use with bzlmod"

load("@bazel_skylib//lib:modules.bzl", "modules")
load("//:deps.bzl", "python_stdlib_list_deps")

python_stdlib_list = modules.as_extension(
python_stdlib_list_deps,
doc = "This extension registers python stdlib list dependencies.",
)
9 changes: 3 additions & 6 deletions gazelle/python/python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ const (
gazelleBinaryName = "gazelle_binary"
)

var gazellePath string

func TestGazelleBinary(t *testing.T) {
gazellePath = mustFindGazelle()
gazellePath := mustFindGazelle()
tests := map[string][]bazel.RunfileEntry{}

runfiles, err := bazel.ListRunfiles()
Expand All @@ -67,13 +65,12 @@ func TestGazelleBinary(t *testing.T) {
if len(tests) == 0 {
t.Fatal("no tests found")
}

for testName, files := range tests {
testPath(t, testName, files)
testPath(t, gazellePath, testName, files)
}
}

func testPath(t *testing.T, name string, files []bazel.RunfileEntry) {
func testPath(t *testing.T, gazellePath, name string, files []bazel.RunfileEntry) {
t.Run(name, func(t *testing.T) {
t.Parallel()
var inputs, goldens []testtools.FileSpec
Expand Down

0 comments on commit a46b206

Please sign in to comment.