forked from bazel-contrib/bazel-gazelle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a go_test directive to enable generating go_test targets per _tes…
…t.go file (bazel-contrib#1597) * add a go_test directive to enable generating go_test targets per _test.go file * address comments * add new tests for updating to per-file mode --------- Co-authored-by: Fabian Meumertzheim <[email protected]>
- Loading branch information
1 parent
f09c9de
commit fc149a2
Showing
22 changed files
with
389 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# gazelle:go_test file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "tests_per_file", | ||
srcs = ["lib.go"], | ||
_gazelle_imports = [], | ||
importpath = "example.com/repo/tests_per_file", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_test( | ||
name = "bar_test", | ||
srcs = ["bar_test.go"], | ||
_gazelle_imports = ["testing"], | ||
embed = [":tests_per_file"], | ||
) | ||
|
||
go_test( | ||
name = "external_test", | ||
srcs = ["external_test.go"], | ||
_gazelle_imports = [ | ||
"example.com/repo/tests_per_file", | ||
"testing", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "foo_test", | ||
srcs = ["foo_test.go"], | ||
_gazelle_imports = [ | ||
"github.com/bazelbuild/bazel-gazelle/testtools", | ||
"testing", | ||
], | ||
embed = [":tests_per_file"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package tests_per_file | ||
|
||
import "testing" | ||
|
||
func TestStuff(t *testing.T) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package tests_per_file_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"example.com/repo/tests_per_file" | ||
) | ||
|
||
func TestStuff(t *testing.T) { | ||
var _ tests_per_file.Type | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package tests_per_file | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/bazelbuild/bazel-gazelle/testtools" | ||
) | ||
|
||
type fileSpec testtools.FileSpec | ||
|
||
func TestStuff(t *testing.T) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package tests_per_file | ||
|
||
type Type int |
29 changes: 29 additions & 0 deletions
29
language/go/testdata/tests_per_file_from_default/BUILD.old
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# gazelle:go_test file | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "tests_per_file_from_default", | ||
srcs = ["lib.go"], | ||
_gazelle_imports = [], | ||
importpath = "example.com/repo/tests_per_file_from_default", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_test( | ||
name = "test_per_file_from_default_test", | ||
srcs = [ | ||
"bar_test.go", | ||
"foo_test.go", | ||
], | ||
_gazelle_imports = ["testing"], | ||
embed = [":tests_per_file_from_default"], | ||
) | ||
|
||
go_test( | ||
name = "external_test", | ||
srcs = ["external_test.go"], | ||
_gazelle_imports = [ | ||
"example.com/repo/tests_per_file_from_default", | ||
"testing", | ||
], | ||
) |
Oops, something went wrong.