xref: /aosp_15_r20/external/bazelbuild-rules_go/tests/README.rst (revision 9bb1b549b6a84214c53be0924760be030e66b93a)
1*9bb1b549SSpandan DasGo rules test suite
2*9bb1b549SSpandan Das===================
3*9bb1b549SSpandan Das
4*9bb1b549SSpandan DasMain test areas
5*9bb1b549SSpandan Das---------------
6*9bb1b549SSpandan Das
7*9bb1b549SSpandan Das.. Child list start
8*9bb1b549SSpandan Das
9*9bb1b549SSpandan Das* `Core Go rules tests <core/README.rst>`_
10*9bb1b549SSpandan Das* `Integration tests <integration/README.rst>`_
11*9bb1b549SSpandan Das* `Legacy tests <legacy/README.rst>`_
12*9bb1b549SSpandan Das* `Go rules examples <examples/README.rst>`_
13*9bb1b549SSpandan Das
14*9bb1b549SSpandan Das.. Child list end
15*9bb1b549SSpandan Das
16*9bb1b549SSpandan DasAdding a new test
17*9bb1b549SSpandan Das-----------------
18*9bb1b549SSpandan Das
19*9bb1b549SSpandan DasAll tests in the test suite are expected to obey certain rules.
20*9bb1b549SSpandan Das
21*9bb1b549SSpandan DasThey must be documented
22*9bb1b549SSpandan Das    Each test folder must contain a README.rst that documents the area of
23*9bb1b549SSpandan Das    reponsability for the folder. That README must have a section with
24*9bb1b549SSpandan Das    the same name as each of the test rules that documents exactly what the
25*9bb1b549SSpandan Das    test is supposed to be checking for.
26*9bb1b549SSpandan Das    If the test is in response to a previous issue, the documentation must
27*9bb1b549SSpandan Das    also link to the issue being addressed.
28*9bb1b549SSpandan Das
29*9bb1b549SSpandan DasTest one thing at a time
30*9bb1b549SSpandan Das    Each test should have a clear and specific responsability, and it should be
31*9bb1b549SSpandan Das    as tightly targeted as possible.
32*9bb1b549SSpandan Das    Prefer writing multiple tests in a single folder to a single test that
33*9bb1b549SSpandan Das    excercises multiple things.
34*9bb1b549SSpandan Das
35*9bb1b549SSpandan DasThey must be turned on
36*9bb1b549SSpandan Das    Test that do not run by default on the CI machines are not much use,
37*9bb1b549SSpandan Das    especially as it's often the only way changes get tested in environments
38*9bb1b549SSpandan Das    that are not the one they are authored on, and the rules are very sensitive
39*9bb1b549SSpandan Das    to platform specific variations.
40*9bb1b549SSpandan Das
41*9bb1b549SSpandan DasThey must not be flakey
42*9bb1b549SSpandan Das    We will generally just delete tests that flake, and if features cannot be
43*9bb1b549SSpandan Das    tested without flakes we will probably delete the feature as well.
44*9bb1b549SSpandan Das
45*9bb1b549SSpandan DasThey must work on all platforms
46*9bb1b549SSpandan Das    We support mac, linux and windows, and all our code must work across all
47*9bb1b549SSpandan Das    hosts. There are some tests that need to be platform specific, but it's
48*9bb1b549SSpandan Das    very rare, and needs a really strong rationale to be accepted.
49*9bb1b549SSpandan Das
50*9bb1b549SSpandan DasThey must be as fast as possible
51*9bb1b549SSpandan Das    Some tests need to be large and expensive, but most do not. In particular,
52*9bb1b549SSpandan Das    downloading large external dependancies to perform a small unit test is not
53*9bb1b549SSpandan Das    ok, prefer creating a small local replication of the problem instead.
54*9bb1b549SSpandan Das    Anything that requires external dependancies beyond those of the rules
55*9bb1b549SSpandan Das    belongs in the integration tests.