aboutsummaryrefslogtreecommitdiff
path: root/tests/core/go_binary/README.rst
blob: a01bdf60323fc4b3b1dcb1f728a4dc3d588a63be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Basic go_binary functionality
=============================

.. _go_binary: /docs/go/core/rules.md#_go_binary
.. _#2168: https://github.com/bazelbuild/rules_go/issues/2168
.. _#2463: https://github.com/bazelbuild/rules_go/issues/2463

Tests to ensure the basic features of go_binary are working as expected.

hello
-----

Hello is a basic "hello world" program that doesn't do anything interesting.
Useful as a primitive smoke test -- if this doesn't build, nothing will.

out_test
--------

Tests that a `go_binary`_ rule can write its executable file with a custom name
in the package directory (not the mode directory).

package_conflict_test
---------------------

Tests that linking multiple packages with the same path (`importmap`) is an
error.

goos_pure_bin
-------------

Tests that specifying the `goos` attribute on a `go_binary`_ target to be
different than the host os forces the pure mode to be on. This is achieved
by including a broken cgo file in the sources for the build.

many_deps
---------

Test that a `go_binary`_ with many imports with long names can be linked. This
makes sure we don't exceed command-line length limits with -I and -L flags.
Verifies #1637.

stamp_test
----------
Test that the `go_binary`_ ``x_defs`` attribute works correctly, both in a
binary and in an embedded library. Tests regular stamps and stamps that
depend on values from the workspace status script. Verifies #2000.

pie_test
--------
Tests that specifying the ``linkmode`` attribute on a `go_binary`_ target to be
pie produces a position-independent executable and that no specifying it produces
a position-dependent binary.

static_test
-----------
Test that `go_binary`_ rules with ``static = "on"`` with and without cgo
produce static binaries. Verifies `#2168`_.

This test only runs on Linux. The darwin external linker cannot produce
static binaries since there is no static version of C runtime libraries.

tags_bin
--------
Checks that setting ``gotags`` affects source filtering. This binary won't build
without a specific tag being set.

prefix
------
This binary has a name that conflicts with a subdirectory. Its output file
name should not have this conflict. Verifies `#2463`_.