aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSamuel Freilich <sfreilich@google.com>2021-10-04 12:03:48 -0400
committerGitHub <noreply@github.com>2021-10-04 12:03:48 -0400
commit506c17293ef4043c68f8cb0ba5fa05d758e1231a (patch)
treee2e9bd8bb1ed5d06437903e4bb9823cc749343d5 /docs
parentb2ed61686ebca2a44d44857fef5b3e1d31cc2483 (diff)
downloadbazel-skylib-506c17293ef4043c68f8cb0ba5fa05d758e1231a.tar.gz
Improve escaping in unittest failure message (#320)
Diffstat (limited to 'docs')
-rwxr-xr-xdocs/build_test_doc.md1
-rwxr-xr-xdocs/diff_test_doc.md1
-rwxr-xr-xdocs/native_binary_doc.md1
-rwxr-xr-xdocs/run_binary_doc.md1
-rwxr-xr-xdocs/unittest_doc.md17
5 files changed, 15 insertions, 6 deletions
diff --git a/docs/build_test_doc.md b/docs/build_test_doc.md
index 6b0d629..5974bc3 100755
--- a/docs/build_test_doc.md
+++ b/docs/build_test_doc.md
@@ -36,3 +36,4 @@ Typical usage:
| targets | A list of targets to ensure build. | none |
| kwargs | The &lt;a href="https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes-tests"&gt;common attributes for tests&lt;/a&gt;. | none |
+
diff --git a/docs/diff_test_doc.md b/docs/diff_test_doc.md
index cf1c2c5..fc66934 100755
--- a/docs/diff_test_doc.md
+++ b/docs/diff_test_doc.md
@@ -23,3 +23,4 @@ The test succeeds if the files' contents match.
| file2 | Label of the file to compare to &lt;code&gt;file1&lt;/code&gt;. | none |
| kwargs | The &lt;a href="https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes-tests"&gt;common attributes for tests&lt;/a&gt;. | none |
+
diff --git a/docs/native_binary_doc.md b/docs/native_binary_doc.md
index a610c3a..9979dd2 100755
--- a/docs/native_binary_doc.md
+++ b/docs/native_binary_doc.md
@@ -50,3 +50,4 @@ runfiles.
| data | list of labels; data dependencies | <code>None</code> |
| kwargs | The &lt;a href="https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes-tests"&gt;common attributes for tests&lt;/a&gt;. | none |
+
diff --git a/docs/run_binary_doc.md b/docs/run_binary_doc.md
index 9d7bb99..0f94f65 100755
--- a/docs/run_binary_doc.md
+++ b/docs/run_binary_doc.md
@@ -22,3 +22,4 @@ Runs a binary as a build action.<br/><br/>This rule does not require Bash (unlik
| srcs | Additional inputs of the action.&lt;br/&gt;&lt;br/&gt;These labels are available for &lt;code&gt;$(location)&lt;/code&gt; expansion in &lt;code&gt;args&lt;/code&gt; and &lt;code&gt;env&lt;/code&gt;. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| tool | The tool to run in the action.&lt;br/&gt;&lt;br/&gt;Must be the label of a *_binary rule, of a rule that generates an executable file, or of a file that can be executed as a subprocess (e.g. an .exe or .bat file on Windows or a binary with executable permission on Linux). This label is available for &lt;code&gt;$(location)&lt;/code&gt; expansion in &lt;code&gt;args&lt;/code&gt; and &lt;code&gt;env&lt;/code&gt;. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+
diff --git a/docs/unittest_doc.md b/docs/unittest_doc.md
index 2b97abe..db9a839 100755
--- a/docs/unittest_doc.md
+++ b/docs/unittest_doc.md
@@ -5,7 +5,8 @@
## unittest_toolchain
<pre>
-unittest_toolchain(<a href="#unittest_toolchain-name">name</a>, <a href="#unittest_toolchain-failure_templ">failure_templ</a>, <a href="#unittest_toolchain-file_ext">file_ext</a>, <a href="#unittest_toolchain-join_on">join_on</a>, <a href="#unittest_toolchain-success_templ">success_templ</a>)
+unittest_toolchain(<a href="#unittest_toolchain-name">name</a>, <a href="#unittest_toolchain-escape_chars_with">escape_chars_with</a>, <a href="#unittest_toolchain-escape_other_chars_with">escape_other_chars_with</a>, <a href="#unittest_toolchain-failure_templ">failure_templ</a>, <a href="#unittest_toolchain-file_ext">file_ext</a>,
+ <a href="#unittest_toolchain-join_on">join_on</a>, <a href="#unittest_toolchain-success_templ">success_templ</a>)
</pre>
@@ -16,10 +17,12 @@ unittest_toolchain(<a href="#unittest_toolchain-name">name</a>, <a href="#unitte
| Name | Description | Type | Mandatory | Default |
| :-------------: | :-------------: | :-------------: | :-------------: | :-------------: |
| name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
-| failure_templ | - | String | required | |
-| file_ext | - | String | required | |
-| join_on | - | String | required | |
-| success_templ | - | String | required | |
+| escape_chars_with | Dictionary of characters that need escaping in test failure message to prefix appended to escape those characters. For example, <code>{"%": "%", "&gt;": "^"}</code> would replace <code>%</code> with <code>%%</code> and <code>&gt;</code> with <code>^&gt;</code> in the failure message before that is included in <code>success_templ</code>. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| escape_other_chars_with | String to prefix every character in test failure message which is not a key in <code>escape_chars_with</code> before including that in <code>success_templ</code>. For example, <code>""</code> would prefix every character in the failure message (except those in the keys of <code>escape_chars_with</code>) with <code>\</code>. | String | optional | "" |
+| failure_templ | Test script template with a single <code>%s</code>. That placeholder is replaced with the lines in the failure message joined with the string specified in <code>join_with</code>. The resulting script should print the failure message and exit with non-zero status. | String | required | |
+| file_ext | File extension for test script, including leading dot. | String | required | |
+| join_on | String used to join the lines in the failure message before including the resulting string in the script specified in <code>failure_templ</code>. | String | required | |
+| success_templ | Test script generated when the test passes. Should exit with status 0. | String | required | |
<a name="#analysistest.make"></a>
@@ -27,7 +30,8 @@ unittest_toolchain(<a href="#unittest_toolchain-name">name</a>, <a href="#unitte
## analysistest.make
<pre>
-analysistest.make(<a href="#analysistest.make-impl">impl</a>, <a href="#analysistest.make-expect_failure">expect_failure</a>, <a href="#analysistest.make-attrs">attrs</a>, <a href="#analysistest.make-fragments">fragments</a>, <a href="#analysistest.make-config_settings">config_settings</a>)
+analysistest.make(<a href="#analysistest.make-impl">impl</a>, <a href="#analysistest.make-expect_failure">expect_failure</a>, <a href="#analysistest.make-attrs">attrs</a>, <a href="#analysistest.make-fragments">fragments</a>, <a href="#analysistest.make-config_settings">config_settings</a>,
+ <a href="#analysistest.make-extra_target_under_test_aspects">extra_target_under_test_aspects</a>)
</pre>
Creates an analysis test rule from its implementation function.
@@ -66,6 +70,7 @@ Recall that names of test rules must end in `_test`.
| attrs | An optional dictionary to supplement the attrs passed to the unit test's <code>rule()</code> constructor. | <code>{}</code> |
| fragments | An optional list of fragment names that can be used to give rules access to language-specific parts of configuration. | <code>[]</code> |
| config_settings | A dictionary of configuration settings to change for the target under test and its dependencies. This may be used to essentially change 'build flags' for the target under test, and may thus be utilized to test multiple targets with different flags in a single build | <code>{}</code> |
+| extra_target_under_test_aspects | An optional list of aspects to apply to the target_under_test in addition to those set up by default for the test harness itself. | <code>[]</code> |
<a name="#analysistest.begin"></a>