test_manifests.rst 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. .. _test_manifests:
  2. ==============
  3. Test Manifests
  4. ==============
  5. Many test suites have their test metadata defined in files called
  6. **test manifests**.
  7. Test manifests are divided into two flavors: :ref:`manifestparser_manifests`
  8. and :ref:`reftest_manifests`.
  9. Naming Convention
  10. =================
  11. The build system does not enforce file naming for test manifest files.
  12. However, the following convention is used.
  13. mochitest.ini
  14. For the *plain* flavor of mochitests.
  15. chrome.ini
  16. For the *chrome* flavor of mochitests.
  17. browser.ini
  18. For the *browser chrome* flavor of mochitests.
  19. a11y.ini
  20. For the *a11y* flavor of mochitests.
  21. xpcshell.ini
  22. For *xpcshell* tests.
  23. .. _manifestparser_manifests:
  24. ManifestParser Manifests
  25. ==========================
  26. ManifestParser manifests are essentially ini files that conform to a basic
  27. set of assumptions.
  28. The `reference documentation <http://mozbase.readthedocs.org/en/latest/manifestparser.html>`_
  29. for manifestparser manifests describes the basic format of test manifests.
  30. In summary, manifests are ini files with section names describing test files::
  31. [test_foo.js]
  32. [test_bar.js]
  33. Keys under sections can hold metadata about each test::
  34. [test_foo.js]
  35. skip-if = os == "win"
  36. [test_foo.js]
  37. skip-if = os == "linux" && debug
  38. [test_baz.js]
  39. fail-if = os == "mac" || os == "android"
  40. There is a special **DEFAULT** section whose keys/metadata apply to all
  41. sections/tests::
  42. [DEFAULT]
  43. property = value
  44. [test_foo.js]
  45. In the above example, **test_foo.js** inherits the metadata **property = value**
  46. from the **DEFAULT** section.
  47. Recognized Metadata
  48. -------------------
  49. Test manifests can define some common keys/metadata to influence behavior.
  50. Those keys are as follows:
  51. head
  52. List of files that will be executed before the test file. (Used in
  53. xpcshell tests.)
  54. tail
  55. List of files that will be executed after the test file. (Used in
  56. xpcshell tests.)
  57. support-files
  58. List of additional files required to run tests. This is typically
  59. defined in the **DEFAULT** section.
  60. Unlike other file lists, *support-files* supports a globbing mechanism
  61. to facilitate pulling in many files with minimal typing. This globbing
  62. mechanism is activated if an entry in this value contains a ``*``
  63. character. A single ``*`` will wildcard match all files in a directory.
  64. A double ``**`` will descend into child directories. For example,
  65. ``data/*`` will match ``data/foo`` but not ``data/subdir/bar`` where
  66. ``data/**`` will match ``data/foo`` and ``data/subdir/bar``.
  67. Support files starting with ``/`` are placed in a root directory, rather
  68. than a location determined by the manifest location. For mochitests,
  69. this allows for the placement of files at the server root. The source
  70. file is selected from the base name (e.g., ``foo`` for ``/path/foo``).
  71. Files starting with ``/`` cannot be selected using globbing.
  72. Some support files are used by tests across multiple directories. In
  73. this case, a test depending on a support file from another directory
  74. must note that dependency with the path to the required support file
  75. in its own **support-files** entry. These use a syntax where paths
  76. starting with ``!/`` will indicate the beginning of the path to a
  77. shared support file starting from the root of the srcdir. For example,
  78. if a manifest at ``dom/base/test/mochitest.ini`` has a support file,
  79. ``dom/base/test/server-script.sjs``, and a mochitest in
  80. ``dom/workers/test`` depends on that support file, the test manifest
  81. at ``dom/workers/test/mochitest.ini`` must include
  82. ``!/dom/base/test/server-script.sjs`` in its **support-files** entry.
  83. generated-files
  84. List of files that are generated as part of the build and don't exist in
  85. the source tree.
  86. The build system assumes that each manifest file, test file, and file
  87. listed in **head**, **tail**, and **support-files** is static and
  88. provided by the source tree (and not automatically generated as part
  89. of the build). This variable tells the build system not to make this
  90. assumption.
  91. This variable will likely go away sometime once all generated files are
  92. accounted for in the build config.
  93. If a generated file is not listed in this key, a clobber build will
  94. likely fail.
  95. dupe-manifest
  96. Record that this manifest duplicates another manifest.
  97. The common scenario is two manifest files will include a shared
  98. manifest file via the ``[include:file]`` special section. The build
  99. system enforces that each test file is only provided by a single
  100. manifest. Having this key present bypasses that check.
  101. The value of this key is ignored.
  102. skip-if
  103. Skip this test if the specified condition is true.
  104. See :ref:`manifest_filter_language`.
  105. fail-if
  106. Expect test failure if the specified condition is true.
  107. See :ref:`manifest_filter_language`.
  108. run-sequentially
  109. If present, the test should not be run in parallel with other tests.
  110. Some test harnesses support parallel test execution on separate processes
  111. and/or threads (behavior varies by test harness). If this key is present,
  112. the test harness should not attempt to run this test in parallel with any
  113. other test.
  114. By convention, the value of this key is a string describing why the test
  115. can't be run in parallel.
  116. .. _manifest_filter_language:
  117. Manifest Filter Language
  118. ------------------------
  119. Some manifest keys accept a special filter syntax as their values. These
  120. values are essentially boolean expressions that are evaluated at test
  121. execution time.
  122. The expressions can reference a well-defined set of variables, such as
  123. ``os`` and ``debug``. These variables are populated from the
  124. ``mozinfo.json`` file. For the full list of available variables, see
  125. the :ref:`mozinfo documentation <mozinfo_attributes>`.
  126. See
  127. `the source <https://hg.mozilla.org/mozilla-central/file/default/testing/mozbase/manifestparser/manifestparser/manifestparser.py>`_ for the full documentation of the
  128. expression syntax until it is documented here.
  129. .. todo::
  130. Document manifest filter language.
  131. .. _manifest_file_installation:
  132. File Installation
  133. -----------------
  134. Files referenced by manifests are automatically installed into the object
  135. directory into paths defined in
  136. :py:func:`mozbuild.frontend.emitter.TreeMetadataEmitter._process_test_manifest`.
  137. Relative paths resolving to parent directory (e.g.
  138. ``support-files = ../foo.txt`` have special behavior.
  139. For ``support-files``, the file will be installed to the default destination
  140. for that manifest. Only the file's base name is used to construct the final
  141. path: directories are irrelevant. Files starting with ``/`` are an exception,
  142. these are installed relative to the root of the destination; the base name is
  143. instead used to select the file..
  144. For all other entry types, the file installation is skipped.
  145. .. _reftest_manifests:
  146. Reftest Manifests
  147. =================
  148. See `MDN <https://developer.mozilla.org/en-US/docs/Creating_reftest-based_unit_tests>`_.