Skip to content

Commit

Permalink
Add documentation body for Bazel java_test, sh_binary, sh_test, test_…
Browse files Browse the repository at this point in the history
…suite.

--
MOS_MIGRATED_REVID=88535323
  • Loading branch information
laszlocsomor authored and hanwen committed Mar 13, 2015
1 parent 4a11c3a commit 56326d1
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,47 @@ tests still need to be legal (e.g. not blocked by visibility or obsoleteness con
.build();
}
}

/*<!-- #BLAZE_RULE (NAME = test_suite, TYPE = TEST, FAMILY = General)[GENERIC_RULE] -->
${ATTRIBUTE_SIGNATURE}
<p>
A <code>test_suite</code> defines a set of tests that are considered "useful" to humans. This
allows projects to define sets of tests, such as "tests you must run before checkin", "our
project's stress tests" or "all small tests."
</p>
${ATTRIBUTE_DEFINITION}
<h4 id="test_suite_examples">Examples</h4>
<p>A test suite to run all of the small tests in the current package.</p>
<pre class="code">
test_suite(
name = "small_tests",
tags = ["small"],
)
</pre>
<p>A test suite that runs a specified set of tests:</p>
<pre class="code">
test_suite(
name = "smoke_tests",
tests = [
"system_unittest",
"public_api_unittest",
],
)
</pre>
<p>A test suite to run all tests in the current package which are not flaky.</p>
<pre class="code">
test_suite(
name = "non_flaky_test",
tags = ["-flaky"],
)
</pre>
<!-- #END_BLAZE_RULE -->*/
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,47 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
.override(attr(":java_launcher", LABEL).value(JavaSemantics.JAVA_LAUNCHER))
.build();
}
}
}

/*<!-- #BLAZE_RULE (NAME = java_test, TYPE = TEST, FAMILY = Java) -->
${ATTRIBUTE_SIGNATURE}
<p>
A <code>java_test()</code> rule compiles a Java test. A test is a binary wrapper around your
test code. The test runner's main method is invoked instead of the main class being compiled.
</p>
${IMPLICIT_OUTPUTS}
${ATTRIBUTE_DEFINITION}
<p>
See the section on <a href="#java_binary_args">java_binary()</a> arguments, with the <i>caveat</i>
that there is no <code>main_class</code> argument. This rule also supports all
<a href="#common-attributes-tests">attributes common to all test rules (*_test)</a>.
</p>
<h4 id="java_test_examples">Examples</h4>
<pre class="code">
java_library(
name = "tests",
srcs = glob(["*.java"]),
deps = [
"//java/com/foo/base:testResources",
"//java/com/foo/testing/util",
],
)
java_test(
name = "AllTests",
size = "small",
runtime_deps = [
":tests",
"//util/mysql",
],
)
</pre>
<!-- #END_BLAZE_RULE -->*/
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,32 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) {
return builder.build();
}
}

/*<!-- #BLAZE_RULE (NAME = sh_binary, TYPE = BINARY, FAMILY = Shell) -->
<p>
The <code>sh_binary</code> rule is used to declare executable Bourne shell scripts.
(<code>sh_binary</code> is a misnomer: its outputs aren't necessarily binaries.) This rule ensures
that all dependencies are built, and appear in the <code>runfiles</code> area at execution time.
We recommend that you name your <code>sh_binary()</code> rules after the name of the script minus
the extension (e.g. <code>.sh</code>); do not give the rule and the file the same name.
</p>
${ATTRIBUTE_SIGNATURE}
${ATTRIBUTE_DEFINITION}
<h4 id="sh_binary_examples">Example</h4>
<p>For a simple shell script with no dependencies or data:
</p>
<pre class="code">
sh_binary(
name = "foo",
srcs = ["foo.sh"],
data = glob(["datafiles/*.txt"]),
)
</pre>
<!-- #END_BLAZE_RULE -->*/
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,27 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) {
return builder.build();
}
}

/*<!-- #BLAZE_RULE (NAME = sh_test, TYPE = TEST, FAMILY = Shell) -->
${ATTRIBUTE_SIGNATURE}
<p>A <code>sh_test()</code> rule creates a test written as a Bourne shell script.</p>
${ATTRIBUTE_DEFINITION}
<p>See the <a href="#common-attributes-tests">attributes common to all test rules (*_test)</a>.</p>
<h4 id="sh_test_examples">Examples</h4>
<pre class="code">
sh_test(
name = "foo_integration_test",
size = "small",
srcs = ["foo_integration_test.sh"],
deps = [":foo_sh_lib"],
data = glob(["testdata/*.txt"]),
)
</pre>
<!-- #END_BLAZE_RULE -->*/

0 comments on commit 56326d1

Please sign in to comment.