Skip to content

Commit

Permalink
Add lost x_defs on test execution regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
bozaro committed Apr 29, 2022
1 parent 383c3b9 commit 5f9f15b
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/core/go_test/x_defs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

test_suite(
name = "x_defs",
)

go_test(
name = "foo_test",
srcs = ["foo_test.go"],
embed = [":foo"],
importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/foo",
pure = "on",
deps = [":bar"],
)

go_library(
name = "bar",
srcs = ["bar.go"],
importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/bar",
visibility = ["//visibility:public"],
x_defs = {"Bar": "Bar"},
deps = [
":baz",
":foo",
],
)

go_library(
name = "baz",
srcs = ["baz.go"],
importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/baz",
visibility = ["//visibility:public"],
x_defs = {"Baz": "Baz"},
deps = [":qux"],
)

go_library(
name = "foo",
srcs = ["foo.go"],
importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/foo",
visibility = ["//visibility:public"],
)

go_library(
name = "qux",
srcs = ["qux.go"],
importpath = "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/qux",
visibility = ["//visibility:public"],
x_defs = {"Qux": "Qux"},
)
10 changes: 10 additions & 0 deletions tests/core/go_test/x_defs/bar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package bar

import (
"github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/baz"
_ "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/foo"
)

var Bar string
var Qux = baz.Qux
var Baz = baz.Baz
6 changes: 6 additions & 0 deletions tests/core/go_test/x_defs/baz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package baz

import "github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/qux"

var Baz string
var Qux = qux.Qux
1 change: 1 addition & 0 deletions tests/core/go_test/x_defs/foo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package foo
28 changes: 28 additions & 0 deletions tests/core/go_test/x_defs/foo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package foo_test

import (
"testing"

"github.com/bazelbuild/rules_go/tests/core/go_test/x_defs/bar"
)

func TestBar(t *testing.T) {
Equal(t, "Bar", bar.Bar)
}

func TestBaz(t *testing.T) {
Equal(t, "Baz", bar.Baz)
}

func TestQux(t *testing.T) {
Equal(t, "Qux", bar.Qux)
}

func Equal(t *testing.T, expected string, actual string) bool {
if expected != actual {
t.Errorf("Not equal: \n"+
"expected: %s\n"+
"actual : %s", expected, actual)
}
return true
}
3 changes: 3 additions & 0 deletions tests/core/go_test/x_defs/qux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package qux

var Qux string
48 changes: 48 additions & 0 deletions tests/core/go_test_x_defs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "bar",
srcs = ["bar.go"],
importpath = "github.com/bozaro/rules_go_xdefs/bar",
visibility = ["//visibility:public"],
x_defs = {"Bar": "Bar"},
deps = [
"//baz",
"//foo",
],
)

go_library(
name = "baz",
srcs = ["baz.go"],
importpath = "github.com/bozaro/rules_go_xdefs/baz",
visibility = ["//visibility:public"],
x_defs = {"Baz": "Baz"},
deps = ["//qux"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "foo",
srcs = ["foo.go"],
importpath = "github.com/bozaro/rules_go_xdefs/foo",
visibility = ["//visibility:public"],
)

go_test(
name = "foo_test",
srcs = ["foo_test.go"],
embed = [":foo"],
importpath = "github.com/bozaro/rules_go_xdefs/foo",
pure = "on",
deps = ["//bar"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "qux",
srcs = ["qux.go"],
importpath = "github.com/bozaro/rules_go_xdefs/qux",
visibility = ["//visibility:public"],
x_defs = {"Qux": "Qux"},
)

0 comments on commit 5f9f15b

Please sign in to comment.