• Home
Name Date Size #Lines LOC

..--

x_defs/04-Jul-2025-166132

BUILD.bazelD04-Jul-20255.2 KiB262226

README.rstD04-Jul-20253.7 KiB12791

binary_env_test.goD04-Jul-20251.2 KiB5635

data_test.goD04-Jul-20251.2 KiB4628

data_test_dep.goD04-Jul-2025638 161

data_test_embed.goD04-Jul-2025638 161

env_inherit_test.goD04-Jul-20251.4 KiB6240

env_test.goD04-Jul-20251.1 KiB4019

example_test.goD04-Jul-2025502 3319

external_importmap_dep.goD04-Jul-2025210 128

external_importmap_lib.goD04-Jul-202579 64

external_importmap_test.goD04-Jul-2025290 116

external_test.goD04-Jul-2025770 3011

flag_test.goD04-Jul-2025832 3112

fuzz_test.goD04-Jul-2025810 3010

indirect_import_dep.goD04-Jul-2025154 85

indirect_import_i_test.goD04-Jul-202598 85

indirect_import_lib.goD04-Jul-202550 42

indirect_import_x_test.goD04-Jul-2025279 1612

internal_test.goD04-Jul-2025750 2910

lib.goD04-Jul-2025627 213

only_testmain_test.goD04-Jul-2025102 118

pwd_test.goD04-Jul-2025317 1714

same_package_test.goD04-Jul-202574 85

sharding_test.goD04-Jul-2025260 1411

tags_bad_test.goD04-Jul-202592 105

tags_good_test.goD04-Jul-202580 83

test_fail_fast_test.goD04-Jul-20251.9 KiB7649

test_filter_test.goD04-Jul-20251.2 KiB5530

testmain_import_indirect_test.goD04-Jul-2025106 85

testmain_import_main_test.goD04-Jul-2025122 128

testmain_without_exit_test.goD04-Jul-20251.5 KiB6035

wrapped_test.goD04-Jul-2025683 203

wrapper_test.goD04-Jul-20251.2 KiB4728

xD04-Jul-20250

xmlreport_test.goD04-Jul-20254.1 KiB164131

yD04-Jul-20250

zD04-Jul-20250

README.rst

1Basic go_test functionality
2===========================
3
4.. _go_test: /docs/go/core/rules.md#_go_test
5.. _#1877: https://github.com/bazelbuild/rules_go/issues/1877
6.. _#34129: https:////github.com/golang/go/issues/34129
7.. _#2749: https://github.com/bazelbuild/rules_go/issues/2749
8
9Tests to ensure that basic features of `go_test`_ are working as expected.
10
11.. contents::
12
13internal_test
14-------------
15
16Test that a `go_test`_ rule that adds white box tests to an embedded package works.
17This builds a library with `lib.go <lib.go>`_ and then a package with an
18`internal test <internal_test.go>`_ that contains the test case.
19It uses x_def stamped values to verify the library names are correct.
20
21external_test
22-------------
23
24Test that a `go_test`_ rule that adds black box tests for a dependant package works.
25This builds a library with `lib.go <lib.go>`_ and then a package with an
26`external test <external_test.go>`_ that contains the test case.
27It uses x_def stamped values to verify the library names are correct.
28
29combined_test
30-------------
31Test that a `go_test`_ rule that adds both white and black box tests for a
32package works.
33This builds a library with `lib.go <lib.go>`_ and then a one merged with the
34`internal test <internal_test.go>`_, and then another one that depends on it
35with the `external test <external_test.go>`_.
36It uses x_def stamped values to verify that all library names are correct.
37Verifies #413
38
39flag_test
40---------
41Test that a `go_test`_ rule that adds flags, even in the main package, can read
42the flag.
43This does not even build a library, it's a test in the main package with no
44dependancies that checks it can declare and then read a flag.
45Verifies #838
46
47only_testmain_test
48------------------
49Test that an `go_test`_ that contains a ``TestMain`` function but no tests
50still builds and passes.
51
52external_importmap_test
53----------------------
54
55Test that an external test package in `go_test`_ is compiled with the correct
56``importmap`` for the library under test. This is verified by defining an
57interface in the library under test and implementing it in a separate
58dependency.
59
60Verifies #1538.
61
62pwd_test
63--------
64
65Checks that the ``PWD`` environment variable is set to the current directory
66in the generated test main before running a test. This matches functionality
67in ``go test``.
68
69Verifies #1561.
70
71data_test
72---------
73
74Checks that data dependencies, including those inherited from ``deps`` and
75``embed``, are visible to tests at run-time. Source files should not be
76visible at run-time.
77
78test_fail_fast_test
79----------------
80
81Checks that ``--test_runner_fail_fast`` actually enables stopping test execution after
82the first failure.
83
84Verifies #3055.
85
86test_filter_test
87----------------
88
89Checks that ``--test_filter`` actually filters out test cases.
90
91testmain_import_test
92----------------
93
94Check if all packages in all source files are imported to test main, to ensure
95a consistent test behaviour. This ensures a consistent behaviour when thinking
96about global indirect depencencies.
97
98tags_test
99---------
100
101Checks that setting ``gotags`` affects source filtering. The test will fail
102unless a specific tag is set.
103
104indirect_import_test
105--------------------
106
107Checks that an external test can import another package that imports the library
108under test. The other package should be compiled against the internal test
109package, not the library under test. Verifies `#1877`_.
110
111testmain_without_exit
112---------------------
113
114Checks that TestMain without calling os.Exit directly works.
115Verifies `#34129`_ from Go 1.15.
116
117wrapper_test
118------------
119
120Checks that a ``go_test`` can be executed by another test in a subdirectory.
121Verifies `#2749`_.
122
123fuzz_test
124---------
125
126Checks that a ``go_test`` with a fuzz target builds correctly.
127