Skip to content

Commit

Permalink
refactor: embed gazelle generation_test_binary in gazelle_generation_…
Browse files Browse the repository at this point in the history
…test instead of recompiling
  • Loading branch information
jbedard authored and fmeum committed Aug 20, 2024
1 parent d12943c commit ba2c7f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
17 changes: 12 additions & 5 deletions internal/generationtest/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

# gazelle:exclude generation_test.go

exports_files([
"generation_test.go",
"generation_test_manifest.yaml.tpl",
])

filegroup(
name = "all_files",
testonly = True,
Expand All @@ -23,3 +19,14 @@ bzl_library(
visibility = ["//:__subpackages__"],
deps = ["@io_bazel_rules_go//go:def"],
)

go_library(
name = "generationtest_test",
testonly = True,
srcs = ["generation_test.go"],
visibility = ["//visibility:public"],
deps = [
"//testtools",
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
],
)
6 changes: 1 addition & 5 deletions internal/generationtest/generationtest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ def gazelle_generation_test(name, gazelle_binary, test_data, build_in_suffix = "
"""
go_test(
name = name,
srcs = [Label("//internal/generationtest:generation_test.go")],
deps = [
Label("//testtools"),
Label("@io_bazel_rules_go//go/tools/bazel:go_default_library"),
],
embed = [Label(":generationtest_test")],
args = [
"-gazelle_binary_path=$(rootpath %s)" % gazelle_binary,
"-build_in_suffix=%s" % build_in_suffix,
Expand Down

0 comments on commit ba2c7f2

Please sign in to comment.